1818
1919import com .boylegu .springboot_vue .controller .pagination .PaginationMultiTypeValuesHelper ;
2020import com .boylegu .springboot_vue .dao .PersonsRepository ;
21+ import com .boylegu .springboot_vue .controller .pagination .PaginationFormatting ;
2122
2223import java .util .*;
2324
2627@ RequestMapping ("/api/persons" )
2728public class MainController {
2829
29- /**
30- * @api {GET} /api/persons/sex Get all sexList
31- * @apiName GetAllSexList
32- * @apiGroup Info Manage
33- * @apiVersion 1.0.0
34- * @apiExample {httpie} Example usage:
35- * <p>
36- * http /api/persons/sex
37- * @apiSuccess {String} label
38- * @apiSuccess {String} value
39- */
40-
4130 @ Autowired
4231 private PersonsRepository personsRepository ;
4332
@@ -47,6 +36,18 @@ public class MainController {
4736 @ RequestMapping (value = "/sex" , method = RequestMethod .GET )
4837 public ResponseEntity <?> getSexAll () {
4938
39+ /*
40+ * @api {GET} /api/persons/sex Get all sexList
41+ * @apiName GetAllSexList
42+ * @apiGroup Info Manage
43+ * @apiVersion 1.0.0
44+ * @apiExample {httpie} Example usage:
45+ * <p>
46+ * http /api/persons/sex
47+ * @apiSuccess {String} label
48+ * @apiSuccess {String} value
49+ */
50+
5051 ArrayList <Map <String , String >> results = new ArrayList <>();
5152
5253 for (Object value : personsRepository .findSex ()) {
@@ -62,7 +63,6 @@ public ResponseEntity<?> getSexAll() {
6263 }
6364
6465 @ RequestMapping (method = RequestMethod .GET , produces = MediaType .APPLICATION_JSON_VALUE )
65- //public Map<String, PaginationMultiTypeValuesHelper> getPersonsAll
6666 public Map <String , PaginationMultiTypeValuesHelper > getPersonsAll (
6767 @ RequestParam (value = "page" , required = false ) Integer pages ,
6868 @ RequestParam ("sex" ) String sex ,
@@ -79,36 +79,35 @@ public Map<String, PaginationMultiTypeValuesHelper> getPersonsAll(
7979 PaginationMultiTypeValuesHelper multiValue = new PaginationMultiTypeValuesHelper ();
8080 Map <String , PaginationMultiTypeValuesHelper > results = new HashMap <>();
8181
82- Integer count , page_number ;
83- Object content ;
84- Long total ;
85- if (sex .length () == 0 && email .length () == 0 ) {
86- count = personsRepository .findAll (pageable ).getSize ();
87- page_number = personsRepository .findAll (pageable ).getNumber ();
88- content = personsRepository .findAll (pageable ).getContent ();
89- total = personsRepository .findAll (pageable ).getTotalElements ();
90-
91- } else if (sex .length () > 0 && email .length () > 0 ) {
92- count = personsRepository .findBySexAndEmailContains (sex , email , pageable ).getSize ();
93- page_number = personsRepository .findBySexAndEmailContains (sex , email , pageable ).getNumber ();
94- content = personsRepository .findBySexAndEmailContains (sex , email , pageable ).getContent ();
95- total = personsRepository .findBySexAndEmailContains (sex , email , pageable ).getTotalElements ();
96-
97- } else {
98- count = personsRepository .findBySex (sex , pageable ).getSize ();
99- page_number = personsRepository .findBySex (sex , pageable ).getNumber ();
100- content = personsRepository .findBySex (sex , pageable ).getContent ();
101- total = personsRepository .findBySex (sex , pageable ).getTotalElements ();
102-
103- }
104-
105- multiValue .setCount (count );
106- multiValue .setPage (page_number + 1 );
107- multiValue .setResults (content );
108- multiValue .setTotal (total );
109- results .put ("data" , multiValue );
110-
111- return results ;
82+ // Integer count, page_number;
83+ // Object content;
84+ // Long total;
85+ // if (sex.length() == 0 && email.length() == 0) {
86+ // count = personsRepository.findAll(pageable).getSize();
87+ // page_number = personsRepository.findAll(pageable).getNumber();
88+ // content = personsRepository.findAll(pageable).getContent();
89+ // total = personsRepository.findAll(pageable).getTotalElements();
90+ // } else if (sex.length() > 0 && email.length() > 0) {
91+ // count = personsRepository.findBySexAndEmailContains(sex, email, pageable).getSize();
92+ // page_number = personsRepository.findBySexAndEmailContains(sex, email, pageable).getNumber();
93+ // content = personsRepository.findBySexAndEmailContains(sex, email, pageable).getContent();
94+ // total = personsRepository.findBySexAndEmailContains(sex, email, pageable).getTotalElements();
95+ // } else {
96+ // count = personsRepository.findBySex(sex, pageable).getSize();
97+ // page_number = personsRepository.findBySex(sex, pageable).getNumber();
98+ // content = personsRepository.findBySex(sex, pageable).getContent();
99+ // total = personsRepository.findBySex(sex, pageable).getTotalElements();
100+ // }
101+ PaginationFormatting ss = new PaginationFormatting ();
102+
103+
104+ // multiValue.setCount(count);
105+ // multiValue.setPage(page_number + 1);
106+ // multiValue.setResults(content);
107+ // multiValue.setTotal(total);
108+ // results.put("data", multiValue);
109+
110+ return ss .filterQuery (sex , email , pageable );
112111 }
113112
114113}
0 commit comments