|
|
@@ -1,31 +1,38 @@
|
|
|
package com.mooctest.crowd.site.controller;
|
|
|
|
|
|
+import com.google.gson.Gson;
|
|
|
+import com.mooctest.crowd.domain.domainobject.DeletedStatus;
|
|
|
+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;
|
|
|
+import com.mooctest.crowd.site.data.response.ServerCode;
|
|
|
import com.mooctest.crowd.site.data.vo.CrowdProjectVO;
|
|
|
import com.mooctest.crowd.site.data.vo.CrowdTaskVO;
|
|
|
import com.mooctest.crowd.site.data.vo.CrowdTestProjectVO;
|
|
|
+import com.mooctest.crowd.site.data.vo.SearchConditionVO;
|
|
|
import com.mooctest.crowd.site.service.CommonService;
|
|
|
import com.mooctest.crowd.site.service.CrowdProjectService;
|
|
|
import com.mooctest.crowd.site.service.CrowdTaskService;
|
|
|
-import org.jetbrains.annotations.NotNull;
|
|
|
+import com.mooctest.crowd.site.util.DataUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.data.domain.*;
|
|
|
+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.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
-import java.util.Iterator;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
-import java.util.function.Function;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @author:xx
|
|
|
* @date:2020/6/20
|
|
|
- * @description:
|
|
|
+ * @description:群智慧项目2.0众测广场所有接口
|
|
|
*/
|
|
|
|
|
|
@RestController
|
|
|
@@ -46,56 +53,68 @@ public class CrowTestSquareController {
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("/list")
|
|
|
- public CrowdTestSquareIndexDTO getAll() {
|
|
|
+ public ResponseVO getAll() {
|
|
|
CrowdTestSquareIndexDTO crowdTestSquareIndexDTO = new CrowdTestSquareIndexDTO();
|
|
|
List<CrowdTestProjectVO> list = crowdProjectService.findAll();
|
|
|
List<CrowdTaskVO> crowdTestTasks = crowdTaskService.findAll();
|
|
|
crowdTestSquareIndexDTO.setCrowdTestProjectVOs(list);
|
|
|
crowdTestSquareIndexDTO.setCrowdTestTaskVOS(crowdTestTasks);
|
|
|
crowdTestSquareIndexDTO.initHotTaskAndProject();
|
|
|
- return crowdTestSquareIndexDTO;
|
|
|
+ return new ResponseVO(ServerCode.SUCCESS, crowdTestSquareIndexDTO);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 众测项目分页查询接口
|
|
|
*/
|
|
|
-
|
|
|
@GetMapping("/project/list")
|
|
|
- public Page<CrowdProjectVO> findAllprojectByPage(
|
|
|
- @RequestParam("pageNum") int pageNum, @RequestParam("pageSize") int pageSize) {
|
|
|
- Pageable pageable = PageRequest.of(pageNum - 1, pageSize);
|
|
|
- Page<CrowdProjectVO> page = commonService.getProjectInfo(pageable, null, 0);
|
|
|
- return page;
|
|
|
+ public ResponseVO findAllprojectByPage(@RequestParam(name = "searchCondition") String searchCondition){
|
|
|
+ Gson gson = new Gson();
|
|
|
+ SearchConditionVO searchConditionVO = gson.fromJson(searchCondition, SearchConditionVO.class);
|
|
|
+ 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);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 众测任务分页查询接口
|
|
|
*/
|
|
|
@GetMapping("/task/list")
|
|
|
- public Page<CrowdTaskVO> getAllTaskByPage(
|
|
|
- @RequestParam("pageNum") int pageNum, @RequestParam("pageSize") int pageSize) {
|
|
|
- Pageable pageable = PageRequest.of(pageNum - 1, pageSize);
|
|
|
+ public ResponseVO<Page<CrowdTaskVO>> getAllTaskByPage(@RequestParam(name = "searchCondition") String searchCondition){
|
|
|
+ Gson gson = new Gson();
|
|
|
+ SearchConditionVO searchConditionVO = gson.fromJson(searchCondition, SearchConditionVO.class);
|
|
|
+ Pageable pageable = this.getPageable(searchConditionVO);
|
|
|
+ String keyword = searchConditionVO.getKeyword();
|
|
|
Page<CrowdTaskVO> page = commonService.getTaskinfo(pageable, null, 0);
|
|
|
- return page;
|
|
|
+ return new ResponseVO<>(ServerCode.SUCCESS, page);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 搜索框模糊查询接口
|
|
|
*/
|
|
|
@GetMapping("search/list")
|
|
|
- public ResponseVO<Page<ProjectAndTaskDTO>> findByNameLike(@RequestParam("name") String name){
|
|
|
+ public ResponseVO<Page<ProjectAndTaskDTO>> findByNameLike(@RequestParam("searchCondition") String searchCondition,
|
|
|
+ @RequestParam("pageNum") int pageNum,
|
|
|
+ @RequestParam("pageSize") int pageSize){
|
|
|
ProjectAndTaskDTO projectAndTaskDTO = new ProjectAndTaskDTO();
|
|
|
- List<CrowdTestProjectVO> list = crowdProjectService.findByNameLike(name);
|
|
|
- List<CrowdTaskVO> taskVOList = crowdTaskService.findByNameLike(name);
|
|
|
+ List<CrowdTestProjectVO> list = crowdProjectService.findByNameLike(searchCondition);
|
|
|
+ List<CrowdTaskVO> taskVOList = crowdTaskService.findByNameLike(searchCondition);
|
|
|
projectAndTaskDTO.setCrowdTaskVOList(taskVOList);
|
|
|
projectAndTaskDTO.setProjectVOList(list);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- return null;
|
|
|
-
|
|
|
+ List projectAndTaskDTOList = new ArrayList<>();
|
|
|
+ projectAndTaskDTOList.addAll(list);
|
|
|
+ projectAndTaskDTOList.addAll(taskVOList);
|
|
|
+ Pageable pageable = PageRequest.of(pageNum - 1, pageSize);
|
|
|
+ Page<ProjectAndTaskDTO> projectAndTaskDTOPage = DataUtils.listToPage(projectAndTaskDTOList, pageable);
|
|
|
+ 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);
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|