|
|
@@ -1,21 +1,23 @@
|
|
|
package com.izouma.dingdong.web;
|
|
|
+
|
|
|
import com.izouma.dingdong.domain.MoneyRecord;
|
|
|
import com.izouma.dingdong.service.MoneyRecordService;
|
|
|
import com.izouma.dingdong.dto.PageQuery;
|
|
|
import com.izouma.dingdong.exception.BusinessException;
|
|
|
import com.izouma.dingdong.repo.MoneyRecordRepo;
|
|
|
import com.izouma.dingdong.utils.ObjUtils;
|
|
|
-import com.izouma.dingdong.utils.SecurityUtils;
|
|
|
import com.izouma.dingdong.utils.excel.ExcelUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageImpl;
|
|
|
-import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.persistence.criteria.Predicate;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping("/moneyRecord")
|
|
|
@@ -39,7 +41,7 @@ public class MoneyRecordController extends BaseController {
|
|
|
//@PreAuthorize("hasRole('ADMIN')")
|
|
|
@GetMapping("/all")
|
|
|
public Page<MoneyRecord> all(PageQuery pageQuery) {
|
|
|
- return moneyRecordRepo.findAll(toSpecification(pageQuery,MoneyRecord.class), toPageRequest(pageQuery));
|
|
|
+ return moneyRecordRepo.findAll(toSpecification(pageQuery, MoneyRecord.class), toPageRequest(pageQuery));
|
|
|
}
|
|
|
|
|
|
@GetMapping("/get/{id}")
|
|
|
@@ -60,8 +62,17 @@ public class MoneyRecordController extends BaseController {
|
|
|
}
|
|
|
|
|
|
@GetMapping("/my")
|
|
|
- public Page<MoneyRecord> my(PageQuery pageQuery){
|
|
|
- return new PageImpl<>(moneyRecordRepo.findAllByUserId(SecurityUtils.getAuthenticatedUser().getId()),toPageRequest(pageQuery),pageQuery.getSize());
|
|
|
+ public Page<MoneyRecord> my(PageQuery pageQuery, Long userId) {
|
|
|
+// Map<String, Object> query = pageQuery.getQuery();
|
|
|
+// query.put("time","2020-05-14 00:00:00,2020-05-14 13:59:59");
|
|
|
+ List<MoneyRecord> all = moneyRecordRepo.findAll(toSpecification(pageQuery, MoneyRecord.class));
|
|
|
+ List<MoneyRecord> my = new ArrayList<>();
|
|
|
+ all.forEach(a -> {
|
|
|
+ if (a.getUserId().equals(userId))
|
|
|
+ my.add(a);
|
|
|
+ }
|
|
|
+ );
|
|
|
+ return new PageImpl<>(my, toPageRequest(pageQuery), pageQuery.getSize());
|
|
|
}
|
|
|
}
|
|
|
|