|
@@ -1,7 +1,5 @@
|
|
|
package com.mooctest.crowd.site.controller;
|
|
|
|
|
|
-import com.google.gson.Gson;
|
|
|
-import com.mooctest.crowd.site.constants.CommonConstant;
|
|
|
import com.mooctest.crowd.site.data.dto.CrowdTestSquareIndexDTO;
|
|
|
import com.mooctest.crowd.site.data.dto.ProjectAndTaskDTO;
|
|
|
import com.mooctest.crowd.site.data.response.ResponseVO;
|
|
@@ -15,13 +13,13 @@ import com.mooctest.crowd.site.service.CrowdTaskService;
|
|
|
import com.mooctest.crowd.site.util.DataUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
-import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
-import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -32,7 +30,7 @@ import java.util.List;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping("/api/square")
|
|
|
-public class CrowTestSquareController extends BaseController{
|
|
|
+public class CrowTestSquareController extends BaseSearchController{
|
|
|
|
|
|
@Autowired
|
|
|
private CrowdProjectService crowdProjectService;
|
|
@@ -62,11 +60,9 @@ public class CrowTestSquareController extends BaseController{
|
|
|
* 众测项目分页查询接口
|
|
|
*/
|
|
|
@GetMapping("/project/list")
|
|
|
- public ResponseVO findAllprojectByPage(@RequestParam(name = "searchCondition") String searchCondition) {
|
|
|
- Gson gson = new Gson();
|
|
|
- SearchConditionVO searchConditionVO = gson.fromJson(searchCondition, SearchConditionVO.class);
|
|
|
+ public ResponseVO findAllprojectByPage(@RequestBody SearchConditionVO searchConditionVO) {
|
|
|
+ Map<String, String> extraCondition = searchConditionVO.getColumnFilters() == null ? new HashMap<>() : super.getExtraCondition(searchConditionVO);
|
|
|
Pageable pageable = this.getPageable(searchConditionVO);
|
|
|
- String keyword = searchConditionVO.getKeyword();
|
|
|
List<CrowdTestProjectVO> list = crowdProjectService.findAll(pageable);
|
|
|
Page<CrowdTestProjectVO> page = DataUtils.listToPage(list, pageable);
|
|
|
return new ResponseVO<>(ServerCode.SUCCESS, page);
|
|
@@ -76,11 +72,9 @@ public class CrowTestSquareController extends BaseController{
|
|
|
* 众测任务分页查询接口
|
|
|
*/
|
|
|
@GetMapping("/task/list")
|
|
|
- public ResponseVO<Page<CrowdTaskVO>> getAllTaskByPage(@RequestParam(name = "searchCondition") String searchCondition){
|
|
|
- Gson gson = new Gson();
|
|
|
- SearchConditionVO searchConditionVO = gson.fromJson(searchCondition, SearchConditionVO.class);
|
|
|
+ public ResponseVO<Page<CrowdTaskVO>> getAllTaskByPage(@RequestBody SearchConditionVO searchConditionVO) {
|
|
|
+ Map<String, String> extraCondition = searchConditionVO.getColumnFilters() == null ? new HashMap<>() : super.getExtraCondition(searchConditionVO);
|
|
|
Pageable pageable = this.getPageable(searchConditionVO);
|
|
|
- String keyword = searchConditionVO.getKeyword();
|
|
|
Page<CrowdTaskVO> page = commonService.getTaskinfo(pageable, null, 0);
|
|
|
return new ResponseVO<>(ServerCode.SUCCESS, page);
|
|
|
}
|
|
@@ -89,29 +83,36 @@ public class CrowTestSquareController extends BaseController{
|
|
|
* 搜索框模糊查询接口
|
|
|
*/
|
|
|
@PostMapping("search/list")
|
|
|
- public ResponseVO<Page<ProjectAndTaskDTO>> findByNameLike(@RequestParam("searchCondition")String searchCondition){
|
|
|
- Gson gson = new Gson();
|
|
|
- SearchConditionVO searchConditionVO = gson.fromJson(searchCondition, SearchConditionVO.class);
|
|
|
- Pageable pageable = this.getPageable(searchConditionVO);
|
|
|
- String keyword = searchConditionVO.getKeyword();
|
|
|
- ProjectAndTaskDTO projectAndTaskDTO = new ProjectAndTaskDTO();
|
|
|
- List<CrowdTestProjectVO> list = crowdProjectService.findByNameLike(keyword);
|
|
|
- List<CrowdTaskVO> taskVOList = crowdTaskService.findByNameLike(keyword);
|
|
|
- projectAndTaskDTO.setCrowdTaskVOList(taskVOList);
|
|
|
- projectAndTaskDTO.setProjectVOList(list);
|
|
|
- List projectAndTaskDTOList = new ArrayList<>();
|
|
|
- projectAndTaskDTOList.addAll(list);
|
|
|
- projectAndTaskDTOList.addAll(taskVOList);
|
|
|
- Page<ProjectAndTaskDTO> projectAndTaskDTOPage = DataUtils.listToPage(projectAndTaskDTOList, pageable);
|
|
|
- return new ResponseVO<>(ServerCode.SUCCESS, projectAndTaskDTOPage);
|
|
|
+ public ResponseVO findByNameLike(@RequestBody SearchConditionVO searchConditionVO) {
|
|
|
+ Map<String, String> extraCondition = searchConditionVO.getColumnFilters() == null ? new HashMap<>() : super.getExtraCondition(searchConditionVO);
|
|
|
+ LOG.info("想要查询的是" + searchConditionVO.getColumnFilters().get(0).getType());
|
|
|
+ Pageable pageable = this.getPageable(searchConditionVO);
|
|
|
+ String keyword = searchConditionVO.getKeyword();
|
|
|
+ ProjectAndTaskDTO projectAndTaskDTO = new ProjectAndTaskDTO();
|
|
|
+ List<CrowdTestProjectVO> list = crowdProjectService.findByNameLike(keyword);
|
|
|
+ List<CrowdTaskVO> taskVOList = crowdTaskService.findByNameLike(keyword);
|
|
|
+ projectAndTaskDTO.setCrowdTaskVOList(taskVOList);
|
|
|
+ projectAndTaskDTO.setProjectVOList(list);
|
|
|
+ List projectAndTaskDTOList = new ArrayList<>();
|
|
|
+ projectAndTaskDTOList.addAll(list);
|
|
|
+ projectAndTaskDTOList.addAll(taskVOList);
|
|
|
+ Page<ProjectAndTaskDTO> projectAndTaskDTOPage = DataUtils.listToPage(projectAndTaskDTOList, pageable);
|
|
|
+ Page<CrowdTestProjectVO> projectVOPage = DataUtils.listToPage(list, pageable);
|
|
|
+ Page<CrowdTaskVO> crowdTaskVOPage = DataUtils.listToPage(taskVOList, pageable);
|
|
|
+ if (searchConditionVO.getColumnFilters().get(0).getType().equals("项目")) {
|
|
|
+ return new ResponseVO<>(ServerCode.SUCCESS, projectVOPage);
|
|
|
+ } else if (searchConditionVO.getColumnFilters().get(0).getType().equals("任务")) {
|
|
|
+ return new ResponseVO(ServerCode.SUCCESS, crowdTaskVOPage);
|
|
|
}
|
|
|
+ return new ResponseVO<>(ServerCode.SUCCESS, projectAndTaskDTOPage);
|
|
|
+ }
|
|
|
|
|
|
- Pageable getPageable(SearchConditionVO searchConditionVO) {
|
|
|
- int activePage = searchConditionVO.getActivePage() == 0 ? 1 : searchConditionVO.getActivePage();
|
|
|
- Sort sort = new Sort(Sort.Direction.DESC, "id");
|
|
|
- return new PageRequest(activePage - 1, CommonConstant.DEFAULT_ROWS_ON_PAGE, sort);
|
|
|
+ @Override
|
|
|
+ public Page<?> search(String searchCondition) {
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|