“xubinhui před 2 roky
rodič
revize
1726500f2d

+ 4 - 0
src/main/java/com/izouma/zhirongip/domain/resource/PolicyLaw.java

@@ -45,6 +45,10 @@ public class PolicyLaw extends BaseEntity {
     @ApiModelProperty(value = "发文时间")
     private LocalDate issuedAt;
 
+
+    @ApiModelProperty(value = "发文年份")
+    private int year;
+
     @SearchableOne
     @ApiModelProperty(value = "发文单位")
     private String issuedBy;

+ 0 - 32
src/main/java/com/izouma/zhirongip/dto/Criteria.java

@@ -1,32 +0,0 @@
-package com.izouma.zhirongip.dto;
-
-import lombok.Data;
-
-@Data
-public class Criteria {
-    private String key;
-    private Object value;
-    private String operator;
-
-    public Criteria() {}
-
-    public Criteria(String key, String operator, Object value) {
-        this.key = key;
-        this.operator = operator;
-        this.value = value;
-    }
-
-    public Criteria andGreaterThanOrEqualTo(String key, Object value) {
-        this.key = key;
-        this.operator = ">=";
-        this.value = value;
-        return this;
-    }
-
-    public Criteria andLessThanOrEqualTo(String key, Object value) {
-        this.key = key;
-        this.operator = "<=";
-        this.value = value;
-        return this;
-    }
-}

+ 0 - 7
src/main/java/com/izouma/zhirongip/dto/PageQuery.java

@@ -17,12 +17,5 @@ public class PageQuery {
     private Map<String, Object> query = new HashMap<>();
 
 
-    private List<Criteria> criteriaList = new ArrayList<>();
 
-    public Criteria getCriteria() {
-        if (criteriaList.isEmpty()) {
-           criteriaList.add(new Criteria());
-        }
-        return criteriaList.get(0);
-    }
 }

+ 6 - 13
src/main/java/com/izouma/zhirongip/web/resource/PolicyLawController.java

@@ -1,6 +1,5 @@
 package com.izouma.zhirongip.web.resource;
 
-import com.izouma.zhirongip.domain.resource.NumOfIp;
 import com.izouma.zhirongip.web.BaseController;
 import com.izouma.zhirongip.domain.resource.PolicyLaw;
 import com.izouma.zhirongip.service.resource.PolicyLawService;
@@ -17,7 +16,6 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
-
 import java.time.LocalDate;
 import java.util.List;
 
@@ -36,18 +34,17 @@ public class PolicyLawController extends BaseController {
             ObjUtils.merge(orig, record);
             return policyLawRepo.save(orig);
         }
+        PolicyLaw policyLaw = policyLawRepo.save(record);
+        LocalDate issuedAt = policyLaw.getIssuedAt();
+        int year = issuedAt.getYear();
+        policyLaw.setYear(year);
         return policyLawRepo.save(record);
     }
 
 
     //@PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/all")
-    public Page<PolicyLaw> all(@RequestParam(name = "year", required = false) Integer year, @RequestBody PageQuery pageQuery) {
-        LocalDate starDate = LocalDate.of(year, 1, 1);
-        LocalDate endDate = starDate.plusYears(1).minusDays(1);
-        pageQuery.getCriteria()
-                 .andGreaterThanOrEqualTo("issuedAt", starDate)
-                 .andLessThanOrEqualTo("issuedAt", endDate);
+    public Page<PolicyLaw> all(@RequestBody PageQuery pageQuery) {
         return policyLawService.all(pageQuery);
     }
 
@@ -64,12 +61,8 @@ public class PolicyLawController extends BaseController {
     @GetMapping("/excel")
     @ResponseBody
     public void excel(HttpServletResponse response, PageQuery pageQuery) throws IOException {
-        List<PolicyLaw> data = alll(pageQuery).getContent();
+        List<PolicyLaw> data = all(pageQuery).getContent();
         ExcelUtils.export(response, data);
     }
-
-    public Page<PolicyLaw> alll( @RequestBody PageQuery pageQuery) {
-        return policyLawService.all(pageQuery);
-    }
 }