2021-3-19
修改了调查对象与流调记录部分接口
This commit is contained in:
parent
b51c453bba
commit
dcf4b04e43
BIN
log/survey-INFO-2021-03-04_1.log.gz
Normal file
BIN
log/survey-INFO-2021-03-04_1.log.gz
Normal file
Binary file not shown.
BIN
log/survey-INFO-2021-03-12_1.log.gz
Normal file
BIN
log/survey-INFO-2021-03-12_1.log.gz
Normal file
Binary file not shown.
BIN
log/survey-INFO-2021-03-18_1.log.gz
Normal file
BIN
log/survey-INFO-2021-03-18_1.log.gz
Normal file
Binary file not shown.
@ -1,11 +1,10 @@
|
||||
package com.example.survey.config;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.util.TokenUtil;
|
||||
import com.example.survey.vo.ResultVo;
|
||||
import com.example.survey.vo.ResultVO;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@ -20,7 +19,7 @@ import java.util.Set;
|
||||
* 权限过滤器
|
||||
*/
|
||||
@Log4j2
|
||||
@Configuration
|
||||
//@Configuration
|
||||
public class AuthFilterConfig implements Filter {
|
||||
|
||||
/**
|
||||
@ -29,8 +28,6 @@ public class AuthFilterConfig implements Filter {
|
||||
private static final Set<String> URIS = new HashSet<String>() {{
|
||||
add("/user/login");
|
||||
add("/user/signup");
|
||||
// add("/user/userRole");
|
||||
// add("/role/role");
|
||||
|
||||
}};
|
||||
|
||||
@ -65,13 +62,13 @@ public class AuthFilterConfig implements Filter {
|
||||
}
|
||||
if (token == null) {
|
||||
log.error("请求无token");
|
||||
returnJson(response, new ResultVo(ResultVo.FAILED, "请先登录!", null));
|
||||
returnJson(response, new ResultVO(ResultEnum.NO_TOKEN));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TokenUtil.isPass(token, uri, method)) {
|
||||
log.error("token错误");
|
||||
returnJson(response, new ResultVo(ResultVo.FAILED, "权限不够!", null));
|
||||
log.error("非法token或权限不够");
|
||||
returnJson(response, new ResultVO(ResultEnum.INSUFFICIENT_PRIVILEGE));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -85,7 +82,7 @@ public class AuthFilterConfig implements Filter {
|
||||
}
|
||||
|
||||
|
||||
public static void returnJson(HttpServletResponse response, ResultVo resultVo) {
|
||||
public static void returnJson(HttpServletResponse response, ResultVO resultVo) {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setContentType("application/json;charset=utf-8");
|
||||
try (PrintWriter writer = response.getWriter()) {
|
||||
|
@ -1,120 +0,0 @@
|
||||
package com.example.survey.controller;
|
||||
|
||||
import com.example.survey.entity.InvestigationRecord;
|
||||
import com.example.survey.service.InvestigationRecordService;
|
||||
import com.example.survey.vo.InvestigationRecordVo;
|
||||
import com.example.survey.vo.ResultVo;
|
||||
import com.example.survey.vo.ReviewVo;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Log4j2
|
||||
@RestController
|
||||
@RequestMapping("/investigationRecord")
|
||||
public class InvestigationRecordController {
|
||||
|
||||
@Autowired
|
||||
private InvestigationRecordService investigationRecordService;
|
||||
|
||||
@GetMapping("/underReviewRecord")
|
||||
public ResultVo getUnderReviewRecord(@RequestParam(value = "currentPage") Integer currentPage,
|
||||
@RequestParam(value = "pageSize", defaultValue = "30") Integer pageSize,
|
||||
@RequestParam(value = "userPhone", required = false) String userPhone,
|
||||
@RequestParam(value = "state", required = false) String state,
|
||||
@RequestParam(value = "idNumber", required = false) String idNumber,
|
||||
@RequestParam(value = "version", required = false) String version,
|
||||
@RequestParam(value = "questionnaireNumber", required = false) String questionnaireNumber,
|
||||
@RequestParam(value = "diseased", required = false) Boolean diseased) {
|
||||
|
||||
ResultVo resultVo = new ResultVo();
|
||||
resultVo.setCode(ResultVo.SUCCESS);
|
||||
resultVo.setMsg("查询成功");
|
||||
Map<String, Object> resultMap = new HashMap<>(16, 0.75F);
|
||||
List<InvestigationRecord> records = investigationRecordService.listUnderReviewRecordLimit(userPhone, currentPage, pageSize, state, idNumber, version, questionnaireNumber, diseased);
|
||||
resultMap.put("totalCount", records.size());
|
||||
resultMap.put("currentPage", currentPage);
|
||||
resultMap.put("pageSize", pageSize);
|
||||
resultMap.put("data", records);
|
||||
resultVo.setData(resultMap);
|
||||
|
||||
return resultVo;
|
||||
}
|
||||
|
||||
@GetMapping("/underReviewRecordCount")
|
||||
public ResultVo countUnderReviewRecord(@RequestParam(value = "userPhone") String userPhone) {
|
||||
ResultVo resultVo = new ResultVo();
|
||||
|
||||
resultVo.setCode(ResultVo.SUCCESS);
|
||||
resultVo.setMsg("查询成功");
|
||||
resultVo.setData(investigationRecordService.countUnderReviewRecord(userPhone));
|
||||
|
||||
return resultVo;
|
||||
}
|
||||
|
||||
|
||||
@PutMapping("/underReviewRecord")
|
||||
public ResultVo reviewRecord(@RequestBody ReviewVo reviewVo) {
|
||||
ResultVo resultVo = new ResultVo();
|
||||
|
||||
boolean result = investigationRecordService.reviewRecord(reviewVo);
|
||||
if (result) {
|
||||
resultVo.setCode(ResultVo.SUCCESS);
|
||||
resultVo.setMsg("审核成功");
|
||||
} else {
|
||||
resultVo.setCode(ResultVo.FAILED);
|
||||
resultVo.setMsg("审核失败");
|
||||
}
|
||||
|
||||
resultVo.setCode(ResultVo.SUCCESS);
|
||||
resultVo.setData(result);
|
||||
|
||||
return resultVo;
|
||||
}
|
||||
|
||||
@PutMapping("/investigationRecord")
|
||||
public ResultVo updateInvestigationRecord(@RequestBody InvestigationRecordVo investigationRecordVo) {
|
||||
ResultVo resultVo = new ResultVo();
|
||||
|
||||
investigationRecordService.changeInvestigationRecord(investigationRecordVo);
|
||||
|
||||
resultVo.setCode(ResultVo.SUCCESS);
|
||||
resultVo.setMsg("修改提交成功,等待审核");
|
||||
resultVo.setData(true);
|
||||
|
||||
return resultVo;
|
||||
}
|
||||
|
||||
@PostMapping("/investigationRecord")
|
||||
public ResultVo addInvestigationRecord(@RequestBody InvestigationRecordVo investigationRecordVo) {
|
||||
|
||||
ResultVo resultVo = new ResultVo();
|
||||
boolean result = investigationRecordService.addInvestigationRecord(investigationRecordVo);
|
||||
if (result) {
|
||||
resultVo.setCode(ResultVo.SUCCESS);
|
||||
resultVo.setMsg("提交成功");
|
||||
} else {
|
||||
resultVo.setCode(ResultVo.FAILED);
|
||||
resultVo.setMsg("提交失败");
|
||||
}
|
||||
resultVo.setCode(ResultVo.SUCCESS);
|
||||
resultVo.setData(result);
|
||||
return resultVo;
|
||||
}
|
||||
|
||||
@GetMapping("/record2word")
|
||||
public void record2Word(@RequestParam("token") String token,
|
||||
@RequestParam("idNumber") String idNumber,
|
||||
HttpServletResponse response) {
|
||||
investigationRecordService.export2Word(idNumber, response);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package com.example.survey.controller;
|
||||
|
||||
import com.example.survey.dto.metaData.CreateMetaDataDTO;
|
||||
import com.example.survey.dto.metaData.DeleteMetaDataDTO;
|
||||
import com.example.survey.dto.metaData.ModifyMetaDataDTO;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.service.MetaDataService;
|
||||
import com.example.survey.vo.ResultVO;
|
||||
import lombok.Getter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/metaData")
|
||||
public class MetaDataController {
|
||||
|
||||
@Autowired
|
||||
MetaDataService metaDataService;
|
||||
|
||||
@PostMapping("/metaData")
|
||||
public ResultVO createMetaData(@RequestBody CreateMetaDataDTO createMetaDataDTO){
|
||||
metaDataService.addMetaData(createMetaDataDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@GetMapping("/metaDataList")
|
||||
public ResultVO listMetaData(@RequestParam(value = "name",required = false) String name,
|
||||
@RequestParam("currentPage")int currentPage,
|
||||
@RequestParam(value = "pageSize",defaultValue = "30")int pageSize){
|
||||
Map<String, Object> resultMap = new HashMap<>(16,0.75F);
|
||||
resultMap.put("totalCount", metaDataService.countMetaData(name));
|
||||
resultMap.put("currentPage", currentPage);
|
||||
resultMap.put("pageSize", pageSize);
|
||||
resultMap.put("data", metaDataService.listMetaDataLimit(name,currentPage,pageSize));
|
||||
|
||||
ResultVO resultVO = new ResultVO(ResultEnum.SUCCESS);
|
||||
resultVO.setData(resultMap);
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
@GetMapping("/nameList")
|
||||
public ResultVO getNameList(){
|
||||
ResultVO resultVO = new ResultVO(ResultEnum.SUCCESS);
|
||||
resultVO.setData(metaDataService.getNameList());
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
@PutMapping("/metaData")
|
||||
public ResultVO modifyMetaData(@RequestBody ModifyMetaDataDTO modifyMetaDataDTO){
|
||||
metaDataService.modifyMetaData(modifyMetaDataDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@GetMapping("/metaData")
|
||||
public ResultVO getMetaData(@RequestParam("name")String name){
|
||||
ResultVO resultVO = new ResultVO();
|
||||
resultVO.setData(metaDataService.getMetaData(name));
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
@DeleteMapping("/metaData")
|
||||
public ResultVO deleteMetaData(@RequestBody DeleteMetaDataDTO deleteMetaDataDTO){
|
||||
metaDataService.deleteMetaData(deleteMetaDataDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package com.example.survey.controller;
|
||||
|
||||
import com.example.survey.dto.project.CreateProjectDTO;
|
||||
import com.example.survey.dto.project.ModifyProjectDTO;
|
||||
import com.example.survey.dto.project.ModifyStateDTO;
|
||||
import com.example.survey.enumeration.RespondentStateEnum;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.service.ProjectService;
|
||||
import com.example.survey.vo.ProjectVO;
|
||||
import com.example.survey.vo.ResultVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/project")
|
||||
public class ProjectController {
|
||||
|
||||
@Autowired
|
||||
ProjectService projectService;
|
||||
|
||||
|
||||
@PostMapping("/project")
|
||||
public ResultVO createProject(@RequestBody CreateProjectDTO createProjectDTO) {
|
||||
projectService.createProject(createProjectDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@GetMapping("/projectList")
|
||||
public ResultVO getProject(@RequestParam(value = "name",required = false) String name,
|
||||
@RequestParam(value = "currentPage") int currentPage,
|
||||
@RequestParam(value = "pageSize", defaultValue = "30") int pageSize) {
|
||||
Map<String, Object> resultMap = new HashMap<>(16,0.75F);
|
||||
resultMap.put("totalCount", projectService.countProject(name));
|
||||
resultMap.put("currentPage", currentPage);
|
||||
resultMap.put("pageSize", pageSize);
|
||||
resultMap.put("data", projectService.listProjectLimit(name, currentPage, pageSize));
|
||||
ResultVO resultVO = new ResultVO(ResultEnum.SUCCESS);
|
||||
resultVO.setData(resultMap);
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
@GetMapping("/respondentCount")
|
||||
public ResultVO getRespondentCount(@RequestParam(value = "name") String name) {
|
||||
|
||||
Map<String, Object> resultMap = new HashMap<>(16, 0.75F);
|
||||
resultMap.put("respondentCount", projectService.countRespondent(name));
|
||||
resultMap.put("notInvestigatedRespondentCount", projectService.countRespondent(name, RespondentStateEnum.NOT_INVESTIGATED.getValue()));
|
||||
|
||||
ResultVO resultVO = new ResultVO(ResultEnum.SUCCESS);
|
||||
resultVO.setData(resultMap);
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
@PutMapping("/projectState")
|
||||
public ResultVO modifyProjectState(@RequestBody ModifyStateDTO modifyStateDTO){
|
||||
projectService.modifyProjectState(modifyStateDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@PutMapping("/project")
|
||||
public ResultVO modifyProject(@RequestBody ModifyProjectDTO modifyProjectDTO){
|
||||
projectService.modifyProject(modifyProjectDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
package com.example.survey.controller;
|
||||
|
||||
import com.example.survey.dto.record.ModifyRecordDTO;
|
||||
import com.example.survey.dto.record.ReviewRecordDTO;
|
||||
import com.example.survey.dto.record.SubmitRecordDTO;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.service.RecordService;
|
||||
import com.example.survey.vo.ResultVO;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Log4j2
|
||||
@RestController
|
||||
@RequestMapping("/record")
|
||||
public class RecordController {
|
||||
|
||||
@Autowired
|
||||
private RecordService recordService;
|
||||
|
||||
@GetMapping("/recordList")
|
||||
public ResultVO getRecord(@RequestParam(value = "idNumber", required = false) String idNumber,
|
||||
@RequestParam(value = "userPhone", required = false) String userPhone,
|
||||
@RequestParam(value = "projectName", required = false) String projectName,
|
||||
@RequestParam(value = "state", required = false) String state,
|
||||
@RequestParam(value = "version", required = false) String version,
|
||||
@RequestParam(value = "questionnaireNumber", required = false) String questionnaireNumber,
|
||||
@RequestParam(value = "currentPage") Integer currentPage,
|
||||
@RequestParam(value = "pageSize", defaultValue = "30") Integer pageSize
|
||||
) {
|
||||
Map<String, Object> resultMap = new HashMap<>(16, 0.75F);
|
||||
resultMap.put("totalCount", recordService.countRecord(idNumber, userPhone, projectName, state, version, questionnaireNumber));
|
||||
resultMap.put("currentPage", currentPage);
|
||||
resultMap.put("pageSize", pageSize);
|
||||
resultMap.put("data", recordService.listRecordLimit(idNumber, userPhone, projectName, state, version, questionnaireNumber, currentPage, pageSize));
|
||||
ResultVO resultVo = new ResultVO(ResultEnum.SUCCESS);
|
||||
resultVo.setData(resultMap);
|
||||
|
||||
return resultVo;
|
||||
}
|
||||
|
||||
@GetMapping("/recordValues")
|
||||
public ResultVO getRecordValue(@RequestParam("projectName")String projectName,
|
||||
@RequestParam("idNumber")String idNumber,
|
||||
@RequestParam(value = "version",required = false) String version){
|
||||
ResultVO resultVO = new ResultVO(ResultEnum.SUCCESS);
|
||||
resultVO.setData(recordService.getRecordValues(projectName,idNumber,version));
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
@GetMapping("/underReviewRecordCount")
|
||||
public ResultVO countUnderReviewRecord(@RequestParam(value = "userPhone") String userPhone,
|
||||
@RequestParam(value = "projectName")String projectName) {
|
||||
ResultVO resultVo = new ResultVO(ResultEnum.SUCCESS);
|
||||
resultVo.setData(recordService.countRecord(userPhone, projectName));
|
||||
return resultVo;
|
||||
}
|
||||
|
||||
@PutMapping("/underReviewRecord")
|
||||
public ResultVO reviewRecord(@RequestBody ReviewRecordDTO reviewRecordDTO) {
|
||||
recordService.reviewRecord(reviewRecordDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@PutMapping("/record")
|
||||
public ResultVO modifyRecord(@RequestBody ModifyRecordDTO modifyRecordDTO) {
|
||||
recordService.modifyRecord(modifyRecordDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@PostMapping("/record")
|
||||
public ResultVO submitRecord(@RequestBody SubmitRecordDTO submitRecordDTO) {
|
||||
recordService.createRecord(submitRecordDTO);
|
||||
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,15 +1,13 @@
|
||||
package com.example.survey.controller;
|
||||
|
||||
import com.example.survey.entity.inner.AdministrativeArea;
|
||||
import com.example.survey.dto.respondent.*;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.service.RespondentService;
|
||||
import com.example.survey.dto.RespondentDto;
|
||||
import com.example.survey.vo.CreateRespondentVo;
|
||||
import com.example.survey.vo.ResultVo;
|
||||
import com.example.survey.vo.ResultVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -23,44 +21,52 @@ public class RespondentController {
|
||||
private RespondentService respondentService;
|
||||
|
||||
@PostMapping("/respondent")
|
||||
public ResultVo addRespondent(@RequestBody CreateRespondentVo createRespondentVo) {
|
||||
ResultVo resultVo = new ResultVo();
|
||||
|
||||
boolean result = respondentService.addRespondent(createRespondentVo);
|
||||
if (result) {
|
||||
resultVo.setCode(ResultVo.SUCCESS);
|
||||
resultVo.setMsg("创建成功");
|
||||
} else {
|
||||
resultVo.setCode(ResultVo.FAILED);
|
||||
resultVo.setMsg("创建失败");
|
||||
}
|
||||
resultVo.setData(result);
|
||||
|
||||
return resultVo;
|
||||
public ResultVO addRespondent(@RequestBody CreateRespondentDTO createRespondentDTO) {
|
||||
respondentService.createRespondent(createRespondentDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@GetMapping("/respondent")
|
||||
public ResultVo countRespondent(@RequestParam(value = "userPhone") String userPhone,
|
||||
@RequestParam(value = "state", required = false) String state,
|
||||
@RequestParam(value = "province", required = false) String province,
|
||||
@RequestParam(value = "city", required = false) String city,
|
||||
@RequestParam(value = "county", required = false) String county,
|
||||
@RequestParam(value = "currentPage") int currentPage,
|
||||
@RequestParam(value = "pageSize", defaultValue = "30") int pageSize) {
|
||||
ResultVo resultVo = new ResultVo();
|
||||
@GetMapping("/respondentList")
|
||||
public ResultVO listRespondent(@RequestParam(value = "userPhone", required = false) String userPhone,
|
||||
@RequestParam(value = "projectName", required = false) String projectName,
|
||||
@RequestParam(value = "state", required = false) String state,
|
||||
@RequestParam(value = "idNumber", required = false) String idNumber,
|
||||
@RequestParam(value = "name", required = false) String name,
|
||||
@RequestParam(value = "phone", required = false) String phone,
|
||||
@RequestParam(value = "province", required = false) String province,
|
||||
@RequestParam(value = "city", required = false) String city,
|
||||
@RequestParam(value = "county", required = false) String county,
|
||||
@RequestParam(value = "currentPage") int currentPage,
|
||||
@RequestParam(value = "pageSize", defaultValue = "30") int pageSize
|
||||
) {
|
||||
Map<String, Object> resultMap = new HashMap<>(16, 0.75F);
|
||||
AdministrativeArea administrativeArea = new AdministrativeArea(province, city, county);
|
||||
List<RespondentDto> voList = respondentService.listRespondentLimit(userPhone, state, administrativeArea, currentPage, pageSize);
|
||||
resultMap.put("totalCount", respondentService.countRespondent(userPhone, state, administrativeArea));
|
||||
resultMap.put("totalCount", respondentService.countRespondent(userPhone, state, idNumber, name, phone, province, city, county, projectName));
|
||||
resultMap.put("currentPage", currentPage);
|
||||
resultMap.put("pageSize", pageSize);
|
||||
resultMap.put("data", voList);
|
||||
resultMap.put("data", respondentService.listRespondentLimit(userPhone, state, idNumber, name, phone, province, city, county, projectName, currentPage, pageSize));
|
||||
|
||||
resultVo.setCode(ResultVo.SUCCESS);
|
||||
resultVo.setMsg("查询成功");
|
||||
ResultVO resultVo = new ResultVO(ResultEnum.SUCCESS);
|
||||
resultVo.setData(resultMap);
|
||||
|
||||
return resultVo;
|
||||
}
|
||||
|
||||
@PutMapping("/respondent")
|
||||
public ResultVO modifyRespondent(@RequestBody ModifyRespondentDTO modifyRespondentDTO) {
|
||||
respondentService.modifyRespondent(modifyRespondentDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@DeleteMapping("/respondent")
|
||||
public ResultVO deleteRespondent(@RequestBody DeleteRespondentDTO deleteRespondentDTO) {
|
||||
respondentService.deleteRespondent(deleteRespondentDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@PutMapping("/user")
|
||||
public ResultVO modifyUser(@RequestBody ModifyRespondentUserDTO modifyRespondentUserDTO) {
|
||||
respondentService.modifyUser(modifyRespondentUserDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
package com.example.survey.controller;
|
||||
|
||||
import com.example.survey.enumeration.AuthEnum;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.service.RoleService;
|
||||
import com.example.survey.vo.DeleteRoleVo;
|
||||
import com.example.survey.vo.CreateRoleVo;
|
||||
import com.example.survey.vo.ModifyRoleVo;
|
||||
import com.example.survey.vo.ResultVo;
|
||||
import com.example.survey.dto.role.DeleteRoleDTO;
|
||||
import com.example.survey.dto.role.CreateRoleDTO;
|
||||
import com.example.survey.dto.role.ModifyRoleDTO;
|
||||
import com.example.survey.vo.ResultVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -23,78 +23,43 @@ public class RoleController {
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
|
||||
@GetMapping("/role")
|
||||
public ResultVo getRole(@RequestParam(value = "pageSize", defaultValue = "30") int pageSize,
|
||||
@PostMapping("/role")
|
||||
public ResultVO addRole(@RequestBody CreateRoleDTO createRoleDTO) {
|
||||
roleService.addRole(createRoleDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@GetMapping("/roleList")
|
||||
public ResultVO getRole(@RequestParam(value = "pageSize", defaultValue = "30") int pageSize,
|
||||
@RequestParam(value = "currentPage") int currentPage,
|
||||
@RequestParam(value = "roleName", required = false) String roleName) {
|
||||
ResultVo resultVo = new ResultVo();
|
||||
|
||||
|
||||
List<CreateRoleVo> roleVoList = roleService.getRole(roleName, currentPage, pageSize);
|
||||
@RequestParam(value = "name", required = false) String name) {
|
||||
Map<String, Object> resultMap = new HashMap<>(16, 0.75F);
|
||||
resultMap.put("totalCount",roleVoList.size());
|
||||
resultMap.put("totalCount",roleService.countRole(name));
|
||||
resultMap.put("pageSize", pageSize);
|
||||
resultMap.put("currentPage", currentPage);
|
||||
resultMap.put("data",roleVoList);
|
||||
resultMap.put("data",roleService.listRoleLimit(name, currentPage, pageSize));
|
||||
|
||||
resultVo.setCode(ResultVo.SUCCESS);
|
||||
resultVo.setMsg("查询成功");
|
||||
ResultVO resultVo = new ResultVO(ResultEnum.SUCCESS);
|
||||
resultVo.setData(resultMap);
|
||||
|
||||
return resultVo;
|
||||
}
|
||||
|
||||
@PostMapping("/role")
|
||||
public ResultVo addRole(@RequestBody CreateRoleVo createRoleVo) {
|
||||
ResultVo resultVo = new ResultVo();
|
||||
|
||||
boolean result = roleService.addRole(createRoleVo);
|
||||
if (result) {
|
||||
resultVo.setCode(ResultVo.SUCCESS);
|
||||
resultVo.setMsg("创建成功");
|
||||
} else {
|
||||
resultVo.setCode(ResultVo.FAILED);
|
||||
resultVo.setMsg("创建失败");
|
||||
}
|
||||
resultVo.setData(result);
|
||||
return resultVo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@DeleteMapping("/role")
|
||||
public ResultVo deleteRole(@RequestBody DeleteRoleVo deleteRoleVo) {
|
||||
ResultVo resultVo = new ResultVo();
|
||||
|
||||
roleService.deleteRole(deleteRoleVo.getRoleName());
|
||||
|
||||
resultVo.setCode(ResultVo.SUCCESS);
|
||||
resultVo.setMsg("删除成功");
|
||||
return resultVo;
|
||||
public ResultVO deleteRole(@RequestBody DeleteRoleDTO deleteRoleDTO) {
|
||||
roleService.deleteRole(deleteRoleDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@PutMapping("/role")
|
||||
public ResultVo modifyRole(@RequestBody ModifyRoleVo modifyRoleVo) {
|
||||
ResultVo resultVo = new ResultVo();
|
||||
|
||||
roleService.modifyRole(modifyRoleVo);
|
||||
|
||||
resultVo.setCode(ResultVo.SUCCESS);
|
||||
resultVo.setMsg("修改成功");
|
||||
|
||||
return resultVo;
|
||||
public ResultVO modifyRole(@RequestBody ModifyRoleDTO modifyRoleDTO) {
|
||||
roleService.modifyRole(modifyRoleDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@GetMapping("/authList")
|
||||
public ResultVo getAuthList() {
|
||||
ResultVo resultVo = new ResultVo();
|
||||
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
resultMap.put("authList", AuthEnum.getNameList());
|
||||
resultVo.setCode(ResultVo.SUCCESS);
|
||||
resultVo.setMsg("查询成功");
|
||||
resultVo.setData(resultMap);
|
||||
|
||||
@GetMapping("/authorityList")
|
||||
public ResultVO getAuthList() {
|
||||
ResultVO resultVo = new ResultVO(ResultEnum.SUCCESS);
|
||||
resultVo.setData(AuthEnum.getNameList());
|
||||
return resultVo;
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,13 @@
|
||||
package com.example.survey.controller;
|
||||
|
||||
import com.example.survey.dto.LoginDto;
|
||||
import com.example.survey.dto.UserDto;
|
||||
import com.example.survey.dto.user.*;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.service.UserService;
|
||||
import com.example.survey.vo.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@ -22,122 +21,66 @@ public class UserController {
|
||||
@Autowired
|
||||
UserService userService;
|
||||
|
||||
@GetMapping("/user")
|
||||
public ResultVo getUser(@RequestParam(value = "pageSize", defaultValue = "30") int pageSize,
|
||||
@GetMapping("/userList")
|
||||
public ResultVO getUser(@RequestParam(value = "pageSize", defaultValue = "30") int pageSize,
|
||||
@RequestParam(value = "currentPage") int currentPage,
|
||||
@RequestParam(value = "username", required = false) String username,
|
||||
@RequestParam(value = "phoneNumber", required = false) String phoneNumber) {
|
||||
ResultVo resultVo = new ResultVo();
|
||||
@RequestParam(value = "phone", required = false) String phone) {
|
||||
|
||||
|
||||
List<UserDto> userDtoList = userService.listUserLimit(username, phoneNumber, currentPage, pageSize);
|
||||
Map<String, Object> resultMap = new HashMap<>(16, 0.75F);
|
||||
resultMap.put("totalCount", userDtoList.size());
|
||||
resultMap.put("totalCount", userService.countUser(username,phone));
|
||||
resultMap.put("pageSize", pageSize);
|
||||
resultMap.put("currentPage", currentPage);
|
||||
resultMap.put("data", userDtoList);
|
||||
resultMap.put("data", userService.listUserLimit(username, phone, currentPage, pageSize));
|
||||
|
||||
resultVo.setCode(ResultVo.SUCCESS);
|
||||
resultVo.setMsg("查询成功");
|
||||
ResultVO resultVo = new ResultVO(ResultEnum.SUCCESS);
|
||||
resultVo.setData(resultMap);
|
||||
return resultVo;
|
||||
}
|
||||
|
||||
@DeleteMapping("/user")
|
||||
public ResultVo deleteUser(@RequestBody DeleteUserVo deleteUserVo) {
|
||||
ResultVo resultVo = new ResultVo();
|
||||
|
||||
boolean result = userService.deleteUser(deleteUserVo.getPhoneNumber());
|
||||
if (result) {
|
||||
resultVo.setCode(ResultVo.SUCCESS);
|
||||
resultVo.setMsg("删除成功");
|
||||
} else {
|
||||
resultVo.setCode(ResultVo.FAILED);
|
||||
resultVo.setMsg("删除失败");
|
||||
}
|
||||
return resultVo;
|
||||
public ResultVO deleteUser(@RequestBody DeleteUserDTO deleteUserDTO) {
|
||||
userService.deleteUser(deleteUserDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@PostMapping("/login")
|
||||
public ResultVo login(@RequestBody LoginVo loginVo) {
|
||||
ResultVo resultVo = new ResultVo();
|
||||
public ResultVO login(@RequestBody LoginDTO loginDTO) {
|
||||
//用户名密码验证
|
||||
LoginDto loginDto = userService.matchAuth(loginVo);
|
||||
if (loginDto == null) {
|
||||
LoginVO loginVO = userService.matchAuth(loginDTO);
|
||||
if (loginVO == null) {
|
||||
//登录失败
|
||||
resultVo.setCode(ResultVo.FAILED);
|
||||
resultVo.setMsg("登录失败");
|
||||
return resultVo;
|
||||
return new ResultVO(ResultEnum.WRONG_PASSWORD);
|
||||
}
|
||||
resultVo.setCode(ResultVo.SUCCESS);
|
||||
resultVo.setMsg("登录成功");
|
||||
resultVo.setData(loginDto);
|
||||
ResultVO resultVo = new ResultVO(ResultEnum.SUCCESS);
|
||||
resultVo.setData(loginVO);
|
||||
return resultVo;
|
||||
}
|
||||
|
||||
|
||||
@PutMapping("/userRole")
|
||||
public ResultVo modifyUserRoles(@RequestBody UserRoleVo userRoleVo) {
|
||||
ResultVo resultVo = new ResultVo();
|
||||
|
||||
userService.modifyRole(userRoleVo);
|
||||
resultVo.setCode(0);
|
||||
resultVo.setMsg("修改成功");
|
||||
|
||||
return resultVo;
|
||||
public ResultVO modifyUserRole(@RequestBody ModifyUserRoleDTO modifyUserRoleDTO) {
|
||||
userService.modifyRole(modifyUserRoleDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@PutMapping("/userInfo")
|
||||
public ResultVo changeUserInfo(@RequestBody UserInfoVo userInfoVo) {
|
||||
ResultVo resultVo = new ResultVo();
|
||||
|
||||
userService.modifyUserInfo(userInfoVo);
|
||||
|
||||
resultVo.setCode(ResultVo.SUCCESS);
|
||||
resultVo.setMsg("修改成功");
|
||||
|
||||
return resultVo;
|
||||
public ResultVO changeUserInfo(@RequestBody ModifyUserInfoDTO modifyUserInfoDTO) {
|
||||
userService.modifyUserInfo(modifyUserInfoDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@PutMapping("/pwd")
|
||||
public ResultVo resetPwd(@RequestBody ResetPwdVo resetPwdVo) {
|
||||
ResultVo resultVo = new ResultVo();
|
||||
|
||||
userService.resetPwd(resetPwdVo.getPhoneNumber());
|
||||
|
||||
resultVo.setCode(ResultVo.SUCCESS);
|
||||
resultVo.setMsg("重置成功");
|
||||
|
||||
return resultVo;
|
||||
public ResultVO resetPwd(@RequestBody ResetPwdDTO resetPwdDTO) {
|
||||
userService.resetPwd(resetPwdDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@PostMapping("/user")
|
||||
public ResultVo createUser(@RequestBody CreateUserVo createUserVo) {
|
||||
ResultVo resultVo = new ResultVo();
|
||||
|
||||
userService.addUser(createUserVo);
|
||||
|
||||
resultVo.setCode(ResultVo.SUCCESS);
|
||||
resultVo.setMsg("创建成功");
|
||||
|
||||
return resultVo;
|
||||
public ResultVO createUser(@RequestBody CreateUserDTO createUserDTO) {
|
||||
userService.addUser(createUserDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
// @PostMapping("/signup")
|
||||
// public ResultVo signup(@RequestBody SignupVo signupVo) {
|
||||
// ResultVo resultVo = new ResultVo();
|
||||
//
|
||||
// resultVo.setCode(ResultVo.SUCCESS);
|
||||
// boolean result = userService.addUser(signupVo);
|
||||
// if (result) {
|
||||
// resultVo.setCode(ResultVo.SUCCESS);
|
||||
// resultVo.setMsg("注册成功");
|
||||
// } else {
|
||||
// resultVo.setCode(ResultVo.FAILED);
|
||||
// resultVo.setMsg("注册失败");
|
||||
// }
|
||||
// return resultVo;
|
||||
// }
|
||||
|
||||
}
|
||||
|
@ -1,76 +1,64 @@
|
||||
package com.example.survey.controller.advice;
|
||||
|
||||
import com.example.survey.exception.*;
|
||||
import com.example.survey.vo.ResultVo;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import com.example.survey.vo.ResultVO;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Log4j2
|
||||
@RestControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
@ExceptionHandler(UserException.class)
|
||||
public ResultVo handleUserException(UserException e) {
|
||||
ResultVo resultVo = new ResultVo();
|
||||
|
||||
resultVo.setCode(ResultVo.FAILED);
|
||||
resultVo.setMsg(e.getMessage());
|
||||
|
||||
return resultVo;
|
||||
public ResultVO handleUserException(UserException e) {
|
||||
log.error(e.getMessage());
|
||||
return new ResultVO(e.getResultEnum());
|
||||
}
|
||||
|
||||
|
||||
@ExceptionHandler(RecordException.class)
|
||||
public ResultVo handleRecordException(RecordException e) {
|
||||
ResultVo resultVo = new ResultVo();
|
||||
|
||||
resultVo.setCode(ResultVo.FAILED);
|
||||
resultVo.setMsg(e.getMessage());
|
||||
|
||||
return resultVo;
|
||||
public ResultVO handleRecordException(RecordException e) {
|
||||
log.error(e.getMessage());
|
||||
return new ResultVO(e.getResultEnum());
|
||||
}
|
||||
|
||||
@ExceptionHandler(RespondentException.class)
|
||||
public ResultVo handleRespondentException(RespondentException e) {
|
||||
ResultVo resultVo = new ResultVo();
|
||||
|
||||
resultVo.setCode(ResultVo.FAILED);
|
||||
resultVo.setMsg(e.getMessage());
|
||||
|
||||
return resultVo;
|
||||
public ResultVO handleRespondentException(RespondentException e) {
|
||||
log.error(e.getMessage());
|
||||
return new ResultVO(e.getResultEnum());
|
||||
}
|
||||
|
||||
@ExceptionHandler(RoleException.class)
|
||||
public ResultVo handleRoleException(RoleException e) {
|
||||
ResultVo resultVo = new ResultVo();
|
||||
|
||||
resultVo.setCode(ResultVo.FAILED);
|
||||
resultVo.setMsg(e.getMessage());
|
||||
|
||||
return resultVo;
|
||||
public ResultVO handleRoleException(RoleException e) {
|
||||
log.error(e.getMessage());
|
||||
return new ResultVO(e.getResultEnum());
|
||||
}
|
||||
|
||||
@ExceptionHandler(DepartmentException.class)
|
||||
public ResultVo handleDepartmentException(DepartmentException e) {
|
||||
ResultVo resultVo = new ResultVo();
|
||||
|
||||
resultVo.setCode(ResultVo.FAILED);
|
||||
resultVo.setMsg(e.getMessage());
|
||||
|
||||
return resultVo;
|
||||
public ResultVO handleDepartmentException(DepartmentException e) {
|
||||
log.error(e.getMessage());
|
||||
return new ResultVO(e.getResultEnum());
|
||||
}
|
||||
|
||||
@ExceptionHandler(AuthException.class)
|
||||
public ResultVo handleAuthException(AuthException e) {
|
||||
ResultVo resultVo = new ResultVo();
|
||||
|
||||
resultVo.setCode(ResultVo.FAILED);
|
||||
resultVo.setMsg(e.getMessage());
|
||||
|
||||
return resultVo;
|
||||
public ResultVO handleAuthException(AuthException e) {
|
||||
log.error(e.getMessage());
|
||||
return new ResultVO(e.getResultEnum());
|
||||
}
|
||||
|
||||
@ExceptionHandler(ProjectException.class)
|
||||
public ResultVO handleProjectException(ProjectException e) {
|
||||
log.error(e.getMessage());
|
||||
return new ResultVO(e.getResultEnum());
|
||||
}
|
||||
|
||||
@ExceptionHandler(MetaDataException.class)
|
||||
public ResultVO handleMetaDataException(MetaDataException e) {
|
||||
log.error(e.getMessage());
|
||||
return new ResultVO(e.getResultEnum());
|
||||
}
|
||||
}
|
||||
|
@ -1,88 +0,0 @@
|
||||
package com.example.survey.dao;
|
||||
|
||||
import com.example.survey.entity.InvestigationRecord;
|
||||
import com.example.survey.entity.User;
|
||||
import com.example.survey.entity.inner.OperationInformation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
public interface InvestigationRecordDao {
|
||||
|
||||
/**
|
||||
* 插入调查记录
|
||||
*
|
||||
* @param record 调查记录
|
||||
* @return 是否插入成功
|
||||
*/
|
||||
boolean insertInvestigationRecord(InvestigationRecord record);
|
||||
|
||||
/**
|
||||
* 根据筛选条件分页查询记录
|
||||
*
|
||||
* @param userPhone 用户电话号码
|
||||
* @param offset 偏移量
|
||||
* @param number 数量
|
||||
* @param state 调查记录状态
|
||||
* @param idNumber 调查对象身份证号
|
||||
* @param version 调查记录版本
|
||||
* @param questionnaireNumber 问卷编号
|
||||
* @param diseased 调查对象是否患病
|
||||
* @return 筛选结果
|
||||
*/
|
||||
List<InvestigationRecord> listInvestigationRecordLimit(String userPhone, int offset, int number, String state, String idNumber, String version, String questionnaireNumber, Boolean diseased);
|
||||
|
||||
/**
|
||||
* 根据流调人员电话号码查询对应状态的记录数量
|
||||
*
|
||||
* @param userPhone 流调人员电话号码
|
||||
* @param state 记录状态
|
||||
* @return 记录数量
|
||||
*/
|
||||
long countInvestigationRecordByUserPhone(String userPhone, String state);
|
||||
|
||||
/**
|
||||
* 更新记录状态
|
||||
*
|
||||
* @param idNumber 调查对象的身份证号
|
||||
* @param oldState 旧状态
|
||||
* @param newState 新状态
|
||||
*/
|
||||
void updateRecordState(String idNumber, String oldState, String newState);
|
||||
|
||||
/**
|
||||
* 根据调查对象身份证号与记录状态查询记录
|
||||
*
|
||||
* @param idNumber 调查对象的身份证号
|
||||
* @param state 记录状态
|
||||
* @return 相应记录
|
||||
*/
|
||||
InvestigationRecord selectInvestigationRecord(String idNumber, String state);
|
||||
|
||||
/**
|
||||
* 将待审核调查记录修改为审核后的结果
|
||||
*
|
||||
* @param record 审核后的记录
|
||||
*/
|
||||
void reviewRecord(InvestigationRecord record);
|
||||
|
||||
/**
|
||||
* 是否存在当前状态调查记录
|
||||
*
|
||||
* @param idNumber 调查对象身份证号
|
||||
* @param states 调查记录状态
|
||||
* @return 是否存在
|
||||
*/
|
||||
boolean existInvestigationRecord(String idNumber, String... states);
|
||||
|
||||
|
||||
/**
|
||||
* 更新所有匹配的调查记录的userPhone字段
|
||||
*
|
||||
* @param oldUserPhone 旧的userPhone字段
|
||||
* @param newUserPhone 新的userPhone字段
|
||||
*/
|
||||
void updateManyRecordUserPhone(String oldUserPhone, String newUserPhone);
|
||||
}
|
67
src/main/java/com/example/survey/dao/MetaDataDao.java
Normal file
67
src/main/java/com/example/survey/dao/MetaDataDao.java
Normal file
@ -0,0 +1,67 @@
|
||||
package com.example.survey.dao;
|
||||
|
||||
import com.example.survey.entity.MetaData;
|
||||
import com.example.survey.vo.MetaDataVO;
|
||||
import org.springframework.data.mongodb.core.query.Meta;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
public interface MetaDataDao {
|
||||
|
||||
/**
|
||||
* 判断元数据是否存在
|
||||
*
|
||||
* @param name 元数据名
|
||||
* @return 是否存在
|
||||
*/
|
||||
boolean existMetaData(String name);
|
||||
|
||||
/**
|
||||
* 查询元数据
|
||||
*
|
||||
* @param name 元数据名
|
||||
* @return 元数据
|
||||
*/
|
||||
MetaData selectMetaData(String name);
|
||||
|
||||
/**
|
||||
* 创建元数据,若已有元数据则更新
|
||||
*
|
||||
* @param metaData 元数据
|
||||
*/
|
||||
void saveMetaData(MetaData metaData);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param name 元数据名
|
||||
* @param offset 偏移量
|
||||
* @param pageSize 页大小
|
||||
* @return 元数据
|
||||
*/
|
||||
List<MetaData> listMetaDataLimit(String name, int offset, int pageSize);
|
||||
|
||||
/**
|
||||
* 根据元数据名查询数量
|
||||
*
|
||||
* @param name 元数据名
|
||||
* @return 数量
|
||||
*/
|
||||
long countMetaData(String name);
|
||||
|
||||
/**
|
||||
* 获取所有元数据
|
||||
* @return 元数据列表
|
||||
*/
|
||||
List<MetaData> selectAllMetaData();
|
||||
|
||||
/**
|
||||
* 删除元数据
|
||||
*
|
||||
* @param name 名字
|
||||
*/
|
||||
void deleteMetaData(String name);
|
||||
}
|
53
src/main/java/com/example/survey/dao/ProjectDao.java
Normal file
53
src/main/java/com/example/survey/dao/ProjectDao.java
Normal file
@ -0,0 +1,53 @@
|
||||
package com.example.survey.dao;
|
||||
|
||||
import com.example.survey.entity.Project;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
public interface ProjectDao {
|
||||
|
||||
|
||||
/**
|
||||
* 根据项目名查询项目是否存在
|
||||
*
|
||||
* @param name 项目名
|
||||
* @return 项目是否存在
|
||||
*/
|
||||
boolean existProject(String name);
|
||||
|
||||
/**
|
||||
* 根据项目名查询项目
|
||||
*
|
||||
* @param name 项目名
|
||||
* @return 项目
|
||||
*/
|
||||
Project selectProject(String name);
|
||||
|
||||
/**
|
||||
* 插入项目
|
||||
*
|
||||
* @param project 项目
|
||||
*/
|
||||
void saveProject(Project project);
|
||||
|
||||
/**
|
||||
* 根绝筛选条件分页查询项目
|
||||
*
|
||||
* @param name 项目名
|
||||
* @param offset 偏移量
|
||||
* @param pageSize 页大小
|
||||
* @return 项目列表
|
||||
*/
|
||||
List<Project> listProjectLimit(String name, int offset, int pageSize);
|
||||
|
||||
/**
|
||||
* 根据项目名查询数量
|
||||
*
|
||||
* @param name 项目名
|
||||
* @return 数量
|
||||
*/
|
||||
long countProject(String name);
|
||||
}
|
78
src/main/java/com/example/survey/dao/RecordDao.java
Normal file
78
src/main/java/com/example/survey/dao/RecordDao.java
Normal file
@ -0,0 +1,78 @@
|
||||
package com.example.survey.dao;
|
||||
|
||||
import com.example.survey.entity.Project;
|
||||
import com.example.survey.entity.Record;
|
||||
import com.example.survey.entity.Respondent;
|
||||
import com.example.survey.entity.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
public interface RecordDao {
|
||||
/**
|
||||
* 判断是否存在符合条件的流调记录
|
||||
*
|
||||
* @param respondent 调查对象
|
||||
* @param project 项目
|
||||
* @param state 流调记录状态
|
||||
* @return 是否存在符合条件的流调记录
|
||||
*/
|
||||
boolean existRecord(Respondent respondent, Project project, String state);
|
||||
|
||||
/**
|
||||
* 根据调查对象身份证号与流调记录状态查询流调记录
|
||||
*
|
||||
* @param respondent 调查对象
|
||||
* @param project 项目
|
||||
* @param state 流调记录状态
|
||||
* @return 流调记录
|
||||
*/
|
||||
Record getRecord(Respondent respondent,Project project, String state);
|
||||
|
||||
/**
|
||||
* 保存流调记录,若已有相同id的则更新
|
||||
*
|
||||
* @param record 流调记录
|
||||
*/
|
||||
void saveRecord(Record record);
|
||||
|
||||
/**
|
||||
* 根据筛选条件查询流调记录数量
|
||||
*
|
||||
* @param respondent 调查对象
|
||||
* @param user 分配的人员
|
||||
* @param project 项目
|
||||
* @param state 流调记录状态
|
||||
* @param version 流调记录版本
|
||||
* @param questionnaireNumber 问卷编号
|
||||
* @return 数量
|
||||
*/
|
||||
long countRecord(Respondent respondent, User user, Project project, String state, String version, String questionnaireNumber);
|
||||
|
||||
/**
|
||||
* 根据筛选条件分页查询流调记录
|
||||
*
|
||||
* @param respondent 调查对象
|
||||
* @param user 分配的人员
|
||||
* @param project 项目
|
||||
* @param state 流调记录状态
|
||||
* @param version 流调记录版本
|
||||
* @param questionnaireNumber 问卷编号
|
||||
* @param offset 偏移量
|
||||
* @param pageSize 页大小
|
||||
* @return 流调记录
|
||||
*/
|
||||
List<Record> listRecordLimit(Respondent respondent, User user, Project project, String state, String version, String questionnaireNumber, int offset, int pageSize);
|
||||
|
||||
/**
|
||||
* 根据筛选条件查询流调记录
|
||||
*
|
||||
* @param respondent 调查对象
|
||||
* @param project 项目
|
||||
* @param version 版本号
|
||||
* @return 流调记录
|
||||
*/
|
||||
Record selectRecord(Respondent respondent, Project project, String version);
|
||||
}
|
@ -1,47 +1,99 @@
|
||||
package com.example.survey.dao;
|
||||
|
||||
import com.example.survey.entity.Project;
|
||||
import com.example.survey.entity.Respondent;
|
||||
import com.example.survey.entity.inner.AdministrativeArea;
|
||||
import com.example.survey.entity.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*
|
||||
*/
|
||||
public interface RespondentDao {
|
||||
/**
|
||||
* 插入待调查对象
|
||||
*
|
||||
* @param respondent 待调查对象
|
||||
* @return 是否插入成功
|
||||
*/
|
||||
boolean insertRespondent(Respondent respondent);
|
||||
void saveRespondent(Respondent respondent);
|
||||
|
||||
/**
|
||||
* 根据流调人员电话号码分页查询待调查对象列表
|
||||
* @param userPhone 分配的人员电话号码
|
||||
* @param state 状态
|
||||
* @param administrativeArea 行政区划
|
||||
* @param offset 偏移量
|
||||
* @param number 大小
|
||||
*
|
||||
* @param user 分配的人员
|
||||
* @param state 状态
|
||||
* @param idNumber 身份证号
|
||||
* @param name 调查对象姓名
|
||||
* @param phone 调查对象电话
|
||||
* @param province 省份
|
||||
* @param city 城市
|
||||
* @param county 区县
|
||||
* @param project 项目
|
||||
* @param offset 偏移量
|
||||
* @param pageSize 大小
|
||||
* @return 待调查对象列表
|
||||
*/
|
||||
List<Respondent> listRespondentLimit(String userPhone, String state, AdministrativeArea administrativeArea, int offset, int number);
|
||||
List<Respondent> listRespondentLimit(User user, String state, String idNumber, String name, String phone, String province, String city, String county, Project project, int offset, int pageSize);
|
||||
|
||||
/**
|
||||
* 判断是否存在对应id的调查对象
|
||||
*
|
||||
* @param idNumber 身份证号
|
||||
* @return 是否存在该调查对象
|
||||
*/
|
||||
boolean existRespondent(String idNumber);
|
||||
|
||||
/**
|
||||
* 判断是否存在符合条件的调查对象
|
||||
*
|
||||
* @param idNumber 身份证号
|
||||
* @param state 调查对象状态
|
||||
* @return 是否存在该调查对象
|
||||
*/
|
||||
boolean existRespondent(String idNumber, String state);
|
||||
|
||||
/**
|
||||
* 根绝筛选条件获取调查对象数量
|
||||
*
|
||||
* @param userPhone 分配的人员电话号码
|
||||
* @param state 状态
|
||||
* @param administrativeArea 行政区划
|
||||
* @param user 分配的人员
|
||||
* @param state 状态
|
||||
* @param idNumber 身份证号
|
||||
* @param name 调查对象姓名
|
||||
* @param phone 调查对象电话
|
||||
* @param province 省份
|
||||
* @param city 城市
|
||||
* @param county 区县
|
||||
* @param project 项目
|
||||
* @return 数量
|
||||
*/
|
||||
long countRespondent(String userPhone, String state, AdministrativeArea administrativeArea);
|
||||
long countRespondent(User user, String state, String idNumber, String name, String phone, String province, String city, String county, Project project);
|
||||
|
||||
|
||||
/**
|
||||
* 根据身份证号查询调查对象
|
||||
*
|
||||
* @param idNumber 身份证号
|
||||
* @param project 项目
|
||||
* @return 调查对象
|
||||
*/
|
||||
Respondent selectRespondent(String idNumber,Project project);
|
||||
|
||||
/**
|
||||
* 删除调查对象
|
||||
*
|
||||
* @param idNumber 身份证号
|
||||
*/
|
||||
void deleteRespondent(String idNumber);
|
||||
|
||||
|
||||
/**
|
||||
* 根据项目与调查对象状态查询调查对象数量
|
||||
*
|
||||
* @param project 项目
|
||||
* @param state 调查对象状态
|
||||
* @return 调查对象数量
|
||||
*/
|
||||
long countRespondent(Project project, String state);
|
||||
|
||||
|
||||
}
|
||||
|
@ -12,12 +12,12 @@ import java.util.Set;
|
||||
public interface RoleDao {
|
||||
|
||||
/**
|
||||
* 插入新权限
|
||||
* 插入新角色,如果已有角色则更新
|
||||
*
|
||||
* @param role 新权限
|
||||
* @param role 新角色
|
||||
* @return 是否插入成功
|
||||
*/
|
||||
boolean insertRole(Role role);
|
||||
void saveRole(Role role);
|
||||
|
||||
/**
|
||||
* 根据权限名查询对应权限
|
||||
@ -37,18 +37,27 @@ public interface RoleDao {
|
||||
/**
|
||||
* 根据角色名模糊匹配角色
|
||||
*
|
||||
* @param name 角色名 模糊匹配
|
||||
* @param offset 偏移量
|
||||
* @param limit 大小
|
||||
* @return
|
||||
* @param name 角色名 模糊匹配
|
||||
* @param offset 偏移量
|
||||
* @param pageSize 页大小
|
||||
* @return 角色列表
|
||||
*/
|
||||
List<Role> listLimitRole(String name, int offset, int limit);
|
||||
List<Role> listRoleLimit(String name, int offset, int pageSize);
|
||||
|
||||
|
||||
/**
|
||||
* 更改角色的权限列表
|
||||
* 根据角色名模糊查询角色数量
|
||||
*
|
||||
* @param roleName 角色名
|
||||
* @param authEnumSet 权限集合
|
||||
* @param name 角色名
|
||||
* @return 角色数量
|
||||
*/
|
||||
void updateRole(String roleName, Set<AuthEnum> authEnumSet);
|
||||
long countRole(String name);
|
||||
|
||||
/**
|
||||
* 根据角色名判断角色是否存在
|
||||
*
|
||||
* @param name 角色名
|
||||
* @return 是否存在
|
||||
*/
|
||||
boolean existRole(String name);
|
||||
}
|
||||
|
@ -2,8 +2,6 @@ package com.example.survey.dao;
|
||||
|
||||
import com.example.survey.entity.Role;
|
||||
import com.example.survey.entity.User;
|
||||
import com.example.survey.vo.UserInfoVo;
|
||||
import org.bson.types.ObjectId;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -12,24 +10,6 @@ import java.util.List;
|
||||
*/
|
||||
public interface UserDao {
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户名密码查询用户
|
||||
*
|
||||
* @param phoneNumber 用户电话号码
|
||||
* @param password 密码
|
||||
* @return 对应用户
|
||||
*/
|
||||
User selectUser(String phoneNumber, String password);
|
||||
|
||||
/**
|
||||
* 插入用户
|
||||
*
|
||||
* @param user 用户
|
||||
* @return 是否插入成功
|
||||
*/
|
||||
boolean insertUser(User user);
|
||||
|
||||
/**
|
||||
* 根据筛选条件分页查询用户
|
||||
*
|
||||
@ -52,9 +32,9 @@ public interface UserDao {
|
||||
/**
|
||||
* 删除用户
|
||||
*
|
||||
* @param phoneNumber 电话号码
|
||||
* @param phone 电话号码
|
||||
*/
|
||||
void deleteUser(String phoneNumber);
|
||||
void deleteUser(String phone);
|
||||
|
||||
|
||||
/**
|
||||
@ -64,42 +44,27 @@ public interface UserDao {
|
||||
*/
|
||||
void clearRole(Role role);
|
||||
|
||||
/**
|
||||
* 更改用户角色
|
||||
*
|
||||
* @param phoneNumber 电话号码
|
||||
* @param roleList 角色列表
|
||||
*/
|
||||
void updateUserRole(String phoneNumber, List<Role> roleList);
|
||||
|
||||
/**
|
||||
* 根据调查人员电话查询用户名
|
||||
*
|
||||
* @param investigatorPhone 调查人员电话号码
|
||||
* @return 用户名
|
||||
*/
|
||||
String selectUsername(String investigatorPhone);
|
||||
|
||||
/**
|
||||
* 根据电话号码查询用户
|
||||
*
|
||||
* @param phoneNumber 电话
|
||||
* @param phone 电话
|
||||
* @return 用户
|
||||
*/
|
||||
User selectUser(String phoneNumber);
|
||||
|
||||
User selectUser(String phone);
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
* 根据用户名与电话号码查询用户数量
|
||||
*
|
||||
* @param phoneNumber 电话号码
|
||||
* @param username 用户名
|
||||
* @param phone 电话号码
|
||||
* @return 用户数量
|
||||
*/
|
||||
void resetPwd(String phoneNumber);
|
||||
long countUser(String username, String phone);
|
||||
|
||||
/**
|
||||
* 更新用户信息
|
||||
* 保存用户至数据库,如果是已有用户则更新信息
|
||||
*
|
||||
* @param userInfoVo 用户信息
|
||||
* @param user 用户
|
||||
*/
|
||||
void modifyUser(UserInfoVo userInfoVo);
|
||||
void saveUser(User user);
|
||||
}
|
||||
|
@ -25,11 +25,6 @@ public class DepartmentDaoImpl implements DepartmentDao {
|
||||
try {
|
||||
mongoTemplate.save(department);
|
||||
}catch (Exception e){
|
||||
|
||||
log.error("部门插入失败");
|
||||
log.error(e.getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1,125 +0,0 @@
|
||||
package com.example.survey.dao.impl;
|
||||
|
||||
import com.example.survey.dao.InvestigationRecordDao;
|
||||
import com.example.survey.entity.InvestigationRecord;
|
||||
import com.example.survey.entity.inner.OperationInformation;
|
||||
import com.example.survey.exception.RecordException;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.aggregation.ArrayOperators;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.data.mongodb.core.query.Update;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Log4j2
|
||||
@Repository
|
||||
public class InvestigationRecordDaoImpl implements InvestigationRecordDao {
|
||||
|
||||
@Autowired
|
||||
MongoTemplate mongoTemplate;
|
||||
|
||||
@Override
|
||||
public boolean insertInvestigationRecord(InvestigationRecord record) {
|
||||
try {
|
||||
mongoTemplate.save(record);
|
||||
} catch (Exception e) {
|
||||
log.error("调查记录插入失败");
|
||||
log.error(e.getMessage());
|
||||
throw new RecordException("已存在对应调查对象的调查记录");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InvestigationRecord> listInvestigationRecordLimit(String investigatorPhone, int offset, int number, String state, String idNumber, String version, String questionnaireNumber, Boolean diseased) {
|
||||
;
|
||||
|
||||
Criteria criteria = new Criteria();
|
||||
//流调人员电话号码
|
||||
if (investigatorPhone != null) {
|
||||
criteria.and("investigatorPhone").is(investigatorPhone);
|
||||
}
|
||||
|
||||
//调查记录状态
|
||||
if (state != null) {
|
||||
criteria.and("state").is(state);
|
||||
} else {
|
||||
criteria.and("state").in(InvestigationRecord.UNDER_REVIEW, InvestigationRecord.REVIEWED);
|
||||
}
|
||||
|
||||
//调查对象身份证号
|
||||
if (idNumber != null) {
|
||||
criteria.and("idNumber").is(idNumber);
|
||||
}
|
||||
|
||||
//版本
|
||||
if (version != null) {
|
||||
criteria.and("version").is(version);
|
||||
}
|
||||
|
||||
//问卷编号
|
||||
if (questionnaireNumber != null) {
|
||||
criteria.and("questionnaireNumber").is(questionnaireNumber);
|
||||
}
|
||||
|
||||
//是否患病
|
||||
if (diseased != null) {
|
||||
criteria.and("diseased").is(diseased);
|
||||
}
|
||||
Query query = new Query(criteria);
|
||||
query = query.skip(offset).limit(number);
|
||||
return mongoTemplate.find(query, InvestigationRecord.class);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countInvestigationRecordByUserPhone(String userPhone, String state) {
|
||||
Query query = new Query(Criteria.where("userPhone").is(userPhone).and("state").is(state));
|
||||
return mongoTemplate.count(query, InvestigationRecord.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateRecordState(String idNumber, String oldState, String newState) {
|
||||
Query query = new Query(Criteria.where("idNumber").is(idNumber).and("state").is(oldState));
|
||||
Update update = new Update().set("state", newState);
|
||||
mongoTemplate.updateFirst(query, update, InvestigationRecord.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InvestigationRecord selectInvestigationRecord(String idNumber, String state) {
|
||||
Query query = new Query(Criteria.where("idNumber").is(idNumber).and("state").is(state));
|
||||
return mongoTemplate.findOne(query, InvestigationRecord.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reviewRecord(InvestigationRecord record) {
|
||||
Query query = new Query(Criteria.where("idNumber").is(record.getIdNumber()).and("state").is(InvestigationRecord.UNDER_REVIEW));
|
||||
Update update = new Update()
|
||||
.set("state", record.getState())
|
||||
.set("operationInformationList", record.getOperationInformationList());
|
||||
mongoTemplate.updateFirst(query, update, InvestigationRecord.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existInvestigationRecord(String idNumber, String... states) {
|
||||
Query query = new Query(Criteria.where("idNumber").is(idNumber).and("state").in(states));
|
||||
return mongoTemplate.exists(query, InvestigationRecord.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateManyRecordUserPhone(String oldUserPhone, String newUserPhone) {
|
||||
Query query = new Query(Criteria.where("userPhone").is(oldUserPhone));
|
||||
Update update = new Update().set("userPhone", newUserPhone);
|
||||
mongoTemplate.updateMulti(query, update, InvestigationRecord.class);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package com.example.survey.dao.impl;
|
||||
|
||||
import com.example.survey.dao.MetaDataDao;
|
||||
import com.example.survey.entity.MetaData;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.exception.MetaDataException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Repository
|
||||
public class MetaDataDaoImpl implements MetaDataDao {
|
||||
|
||||
@Autowired
|
||||
MongoTemplate mongoTemplate;
|
||||
|
||||
@Override
|
||||
public boolean existMetaData(String name) {
|
||||
Query query = new Query(Criteria.where("name").is(name));
|
||||
return mongoTemplate.exists(query, MetaData.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaData selectMetaData(String name) {
|
||||
Query query = new Query(Criteria.where("name").is(name));
|
||||
return mongoTemplate.findOne(query, MetaData.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveMetaData(MetaData metaData) {
|
||||
try {
|
||||
mongoTemplate.save(metaData);
|
||||
} catch (Exception e) {
|
||||
throw new MetaDataException(ResultEnum.ALREADY_EXIST_METADATA);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MetaData> listMetaDataLimit(String name, int offset, int pageSize) {
|
||||
Criteria criteria = new Criteria();
|
||||
if (name != null) {
|
||||
criteria.and("name").regex(name);
|
||||
}
|
||||
Query query = new Query(criteria).skip(offset).limit(pageSize);
|
||||
return mongoTemplate.find(query, MetaData.class);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countMetaData(String name) {
|
||||
Criteria criteria = new Criteria();
|
||||
if (name != null) {
|
||||
criteria.and("name").regex(name);
|
||||
}
|
||||
Query query = new Query(criteria);
|
||||
return mongoTemplate.count(query, MetaData.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MetaData> selectAllMetaData() {
|
||||
return mongoTemplate.findAll(MetaData.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteMetaData(String name) {
|
||||
Query query = new Query(Criteria.where("name").is(name));
|
||||
mongoTemplate.remove(query,MetaData.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package com.example.survey.dao.impl;
|
||||
|
||||
import com.example.survey.dao.ProjectDao;
|
||||
import com.example.survey.entity.Project;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.exception.ProjectException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Repository
|
||||
public class ProjectDaoImpl implements ProjectDao {
|
||||
|
||||
@Autowired
|
||||
private MongoTemplate mongoTemplate;
|
||||
|
||||
@Override
|
||||
public boolean existProject(String name) {
|
||||
Query query = new Query(Criteria.where("name").is(name));
|
||||
return mongoTemplate.exists(query, Project.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project selectProject(String name) {
|
||||
Query query = new Query(Criteria.where("name").is(name));
|
||||
return mongoTemplate.findOne(query, Project.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveProject(Project project) {
|
||||
try {
|
||||
mongoTemplate.save(project);
|
||||
} catch (Exception e) {
|
||||
throw new ProjectException(ResultEnum.ALREADY_EXIST_PROJECT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Project> listProjectLimit(String name, int offset, int pageSize) {
|
||||
Criteria criteria = new Criteria();
|
||||
if (name != null) {
|
||||
criteria.and("name").regex(name);
|
||||
}
|
||||
Query query = new Query(criteria).skip(offset).limit(pageSize);
|
||||
return mongoTemplate.find(query, Project.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long countProject(String name) {
|
||||
Criteria criteria = new Criteria();
|
||||
if (name != null) {
|
||||
criteria.and("name").regex(name);
|
||||
}
|
||||
Query query = new Query(criteria);
|
||||
return mongoTemplate.count(query, Project.class);
|
||||
}
|
||||
}
|
124
src/main/java/com/example/survey/dao/impl/RecordDaoImpl.java
Normal file
124
src/main/java/com/example/survey/dao/impl/RecordDaoImpl.java
Normal file
@ -0,0 +1,124 @@
|
||||
package com.example.survey.dao.impl;
|
||||
|
||||
import com.example.survey.dao.RecordDao;
|
||||
import com.example.survey.entity.Project;
|
||||
import com.example.survey.entity.Record;
|
||||
import com.example.survey.entity.Respondent;
|
||||
import com.example.survey.entity.User;
|
||||
import com.example.survey.enumeration.RecordStateEnum;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Log4j2
|
||||
@Repository
|
||||
public class RecordDaoImpl implements RecordDao {
|
||||
|
||||
@Autowired
|
||||
MongoTemplate mongoTemplate;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean existRecord(Respondent respondent, Project project, String state) {
|
||||
Criteria criteria = new Criteria()
|
||||
.and("respondent.$id").is(respondent.getId())
|
||||
.elemMatch(Criteria.where("project.$id").is(project.getId()).and("state").is(state));
|
||||
Query query = new Query(criteria);
|
||||
return mongoTemplate.exists(query, Record.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record getRecord(Respondent respondent, Project project, String state) {
|
||||
Criteria criteria = new Criteria()
|
||||
.and("respondent.$id").is(respondent.getId())
|
||||
.and("project.$id").is(project.getId())
|
||||
.and("state").is(state);
|
||||
Query query = new Query(criteria);
|
||||
|
||||
return mongoTemplate.findOne(query, Record.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveRecord(Record record) {
|
||||
mongoTemplate.save(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countRecord(Respondent respondent, User user, Project project, String state, String version, String questionnaireNumber) {
|
||||
Criteria criteria = new Criteria();
|
||||
if (respondent != null) {
|
||||
criteria.and("respondent.$id").is(respondent.getId());
|
||||
}
|
||||
if (user != null) {
|
||||
criteria.and("user.$id").is(user.getId());
|
||||
}
|
||||
if (project != null) {
|
||||
criteria.and("project.$id").is(project.getId());
|
||||
}
|
||||
|
||||
if (state != null) {
|
||||
criteria.and("state").is(state);
|
||||
} else {
|
||||
criteria.and("state").in(RecordStateEnum.REVIEWED.getValue(), RecordStateEnum.UNDER_REVIEW.getValue());
|
||||
}
|
||||
|
||||
if (version != null) {
|
||||
criteria.and("version").is(version);
|
||||
}
|
||||
if (questionnaireNumber != null) {
|
||||
criteria.and("value.questionnaireNumber").is(questionnaireNumber);
|
||||
}
|
||||
Query query = new Query(criteria);
|
||||
return mongoTemplate.count(query, Record.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Record> listRecordLimit(Respondent respondent, User user, Project project, String state, String version, String questionnaireNumber, int offset, int pageSize) {
|
||||
Criteria criteria = new Criteria();
|
||||
if (respondent != null) {
|
||||
criteria.and("respondent.$id").is(respondent.getId());
|
||||
}
|
||||
if (user != null) {
|
||||
criteria.and("user.$id").is(user.getId());
|
||||
}
|
||||
if (project != null) {
|
||||
criteria.and("project.$id").is(project.getId());
|
||||
}
|
||||
|
||||
if (state != null) {
|
||||
criteria.and("state").is(state);
|
||||
} else {
|
||||
criteria.and("state").in(RecordStateEnum.REVIEWED.getValue(), RecordStateEnum.UNDER_REVIEW.getValue());
|
||||
}
|
||||
|
||||
if (version != null) {
|
||||
criteria.and("version").is(version);
|
||||
}
|
||||
if (questionnaireNumber != null) {
|
||||
criteria.and("value.questionnaireNumber").is(questionnaireNumber);
|
||||
}
|
||||
Query query = new Query(criteria).skip(offset).limit(pageSize);
|
||||
return mongoTemplate.find(query, Record.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record selectRecord(Respondent respondent, Project project, String version) {
|
||||
|
||||
Criteria criteria = Criteria
|
||||
.where("respondent.$id").is(respondent.getId())
|
||||
.and("project.$id").is(project.getId());
|
||||
if (version != null) {
|
||||
criteria.and("version").is(version);
|
||||
}
|
||||
Query query = new Query(criteria);
|
||||
return mongoTemplate.findOne(query, Record.class);
|
||||
}
|
||||
}
|
@ -1,8 +1,10 @@
|
||||
package com.example.survey.dao.impl;
|
||||
|
||||
import com.example.survey.dao.RespondentDao;
|
||||
import com.example.survey.entity.Project;
|
||||
import com.example.survey.entity.Respondent;
|
||||
import com.example.survey.entity.inner.AdministrativeArea;
|
||||
import com.example.survey.entity.User;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.exception.RespondentException;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -24,42 +26,81 @@ public class RespondentDaoImpl implements RespondentDao {
|
||||
private MongoTemplate mongoTemplate;
|
||||
|
||||
@Override
|
||||
public boolean insertRespondent(Respondent respondent) {
|
||||
public void saveRespondent(Respondent respondent) {
|
||||
try {
|
||||
mongoTemplate.save(respondent);
|
||||
} catch (Exception e) {
|
||||
log.error("调查对象插入失败");
|
||||
log.error(e.getMessage());
|
||||
throw new RespondentException("调查对象已存在");
|
||||
throw new RespondentException(ResultEnum.ALREADY_EXIST_RESPONDENT);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Respondent> listRespondentLimit(String userPhone, String state, AdministrativeArea administrativeArea, int offset, int number) {
|
||||
public List<Respondent> listRespondentLimit(User user, String state, String idNumber, String name, String phone, String province, String city, String county, Project project, int offset, int pageSize) {
|
||||
Criteria criteria = new Criteria();
|
||||
|
||||
if (userPhone != null) {
|
||||
criteria.and("userPhone").is(userPhone);
|
||||
if (idNumber != null) {
|
||||
criteria.and("idNumber").is(idNumber);
|
||||
}
|
||||
if (name != null) {
|
||||
criteria.and("name").regex(name);
|
||||
}
|
||||
if (phone != null) {
|
||||
criteria.and("phone").is(phone);
|
||||
}
|
||||
|
||||
if (province != null) {
|
||||
criteria.and("administrativeArea.province").is(province);
|
||||
}
|
||||
if (city != null) {
|
||||
criteria.and("administrativeArea.city").is(city);
|
||||
}
|
||||
if (county != null) {
|
||||
criteria.and("administrativeArea.county").is(county);
|
||||
}
|
||||
|
||||
Criteria elementMatch = new Criteria();
|
||||
if (project != null) {
|
||||
elementMatch.and("project.$id").is(project.getId());
|
||||
}
|
||||
if (user != null) {
|
||||
elementMatch.and("user.$id").is(user.getId());
|
||||
}
|
||||
if (state != null) {
|
||||
criteria.and("state").is(state);
|
||||
elementMatch.and("state").is(state);
|
||||
}
|
||||
criteria.and("projectPartSet").elemMatch(elementMatch);
|
||||
|
||||
Query query = new Query(criteria).skip(offset).limit(pageSize);
|
||||
return mongoTemplate.find(query, Respondent.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countRespondent(User user, String state, String idNumber, String name, String phone, String province, String city, String county, Project project) {
|
||||
Criteria criteria = new Criteria();
|
||||
|
||||
if (province != null) {
|
||||
criteria.and("administrativeArea.province").is(province);
|
||||
}
|
||||
if (city != null) {
|
||||
criteria.and("administrativeArea.city").is(city);
|
||||
}
|
||||
if (county != null) {
|
||||
criteria.and("administrativeArea.county").is(county);
|
||||
}
|
||||
|
||||
if (administrativeArea != null) {
|
||||
if(administrativeArea.getProvince()!=null){
|
||||
criteria.and("administrativeArea.province").is(administrativeArea.getProvince());
|
||||
}
|
||||
if(administrativeArea.getCity()!=null){
|
||||
criteria.and("administrativeArea.city").is(administrativeArea.getCity());
|
||||
}
|
||||
if(administrativeArea.getCounty()!=null){
|
||||
criteria.and("administrativeArea.county").is(administrativeArea.getCounty());
|
||||
}
|
||||
Criteria elementMatch = new Criteria();
|
||||
if (project != null) {
|
||||
elementMatch.and("project.$id").is(project.getId());
|
||||
}
|
||||
Query query = new Query(criteria).skip(offset).limit(number);
|
||||
return mongoTemplate.find(query, Respondent.class);
|
||||
if (user != null) {
|
||||
elementMatch.and("user.$id").is(user.getId());
|
||||
}
|
||||
if (state != null) {
|
||||
elementMatch.and("state").is(state);
|
||||
}
|
||||
criteria.and("projectPartSet").elemMatch(elementMatch);
|
||||
Query query = new Query(criteria);
|
||||
return mongoTemplate.count(query, Respondent.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -69,29 +110,30 @@ public class RespondentDaoImpl implements RespondentDao {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countRespondent(String userPhone, String state, AdministrativeArea administrativeArea) {
|
||||
Criteria criteria = new Criteria();
|
||||
public boolean existRespondent(String idNumber, String state) {
|
||||
Query query = new Query(
|
||||
Criteria.where("idNumber").is(idNumber)
|
||||
.and("state").is(state));
|
||||
return mongoTemplate.exists(query, Respondent.class);
|
||||
}
|
||||
|
||||
if (userPhone != null) {
|
||||
criteria.and("userPhone").is(userPhone);
|
||||
}
|
||||
|
||||
if (state != null) {
|
||||
criteria.and("state").is(state);
|
||||
}
|
||||
@Override
|
||||
public Respondent selectRespondent(String idNumber, Project project) {
|
||||
Query query = new Query(Criteria.where("idNumber").is(idNumber).and("project.$id").is(project.getId()));
|
||||
return mongoTemplate.findOne(query, Respondent.class);
|
||||
}
|
||||
|
||||
if (administrativeArea != null) {
|
||||
if(administrativeArea.getProvince()!=null){
|
||||
criteria.and("administrativeArea.province").is(administrativeArea.getProvince());
|
||||
}
|
||||
if(administrativeArea.getCity()!=null){
|
||||
criteria.and("administrativeArea.city").is(administrativeArea.getCity());
|
||||
}
|
||||
if(administrativeArea.getCounty()!=null){
|
||||
criteria.and("administrativeArea.county").is(administrativeArea.getCounty());
|
||||
}
|
||||
}
|
||||
Query query = new Query(criteria);
|
||||
@Override
|
||||
public void deleteRespondent(String idNumber) {
|
||||
Query query = new Query(Criteria.where("idNumber").is(idNumber));
|
||||
mongoTemplate.remove(query, Respondent.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countRespondent(Project project, String state) {
|
||||
Criteria elementMatch = Criteria.where("project.$id").is(project.getId()).and("state").is(state);
|
||||
Query query = new Query(Criteria.where("projectPartSet").elemMatch(elementMatch));
|
||||
return mongoTemplate.count(query, Respondent.class);
|
||||
}
|
||||
|
||||
|
@ -2,17 +2,15 @@ package com.example.survey.dao.impl;
|
||||
|
||||
import com.example.survey.dao.RoleDao;
|
||||
import com.example.survey.entity.Role;
|
||||
import com.example.survey.entity.User;
|
||||
import com.example.survey.enumeration.AuthEnum;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.exception.RoleException;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.data.mongodb.core.query.Update;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -27,15 +25,12 @@ public class RoleDaoImpl implements RoleDao {
|
||||
private MongoTemplate mongoTemplate;
|
||||
|
||||
@Override
|
||||
public boolean insertRole(Role role) {
|
||||
public void saveRole(Role role) {
|
||||
try {
|
||||
mongoTemplate.save(role);
|
||||
} catch (Exception e) {
|
||||
log.error("权限插入失败");
|
||||
log.error(e.getMessage());
|
||||
throw new RoleException("已存在权限");
|
||||
throw new RoleException(ResultEnum.ALREADY_EXIST_ROLE);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -50,25 +45,30 @@ public class RoleDaoImpl implements RoleDao {
|
||||
mongoTemplate.remove(query, Role.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Role> listLimitRole(String name, int offset, int limit) {
|
||||
public List<Role> listRoleLimit(String name, int offset, int pageSize) {
|
||||
Criteria criteria = new Criteria();
|
||||
if (name != null) {
|
||||
criteria.and("name").regex(name);
|
||||
}
|
||||
Query query = new Query(criteria).skip(offset).limit(limit);
|
||||
Query query = new Query(criteria).skip(offset).limit(pageSize);
|
||||
return mongoTemplate.find(query, Role.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateRole(String roleName, Set<AuthEnum> authEnumSet) {
|
||||
Query query = new Query(Criteria.where("name").is(roleName));
|
||||
Role role = mongoTemplate.findOne(query, Role.class);
|
||||
if(role == null){
|
||||
throw new RoleException("角色不存在");
|
||||
public long countRole(String name) {
|
||||
Criteria criteria = new Criteria();
|
||||
if (name != null) {
|
||||
criteria.and("name").regex(name);
|
||||
}
|
||||
role.setAuthoritySet(authEnumSet);
|
||||
mongoTemplate.save(role);
|
||||
Query query = new Query(criteria);
|
||||
return mongoTemplate.count(query, Role.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existRole(String name) {
|
||||
Query query = new Query(Criteria.where("name").is(name));
|
||||
return mongoTemplate.exists(query,Role.class);
|
||||
}
|
||||
}
|
||||
|
@ -3,21 +3,19 @@ package com.example.survey.dao.impl;
|
||||
import com.example.survey.dao.UserDao;
|
||||
import com.example.survey.entity.Role;
|
||||
import com.example.survey.entity.User;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.exception.UserException;
|
||||
import com.example.survey.vo.UserInfoVo;
|
||||
import com.mongodb.client.result.DeleteResult;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.data.mongodb.core.query.Update;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
@ -29,24 +27,6 @@ public class UserDaoImpl implements UserDao {
|
||||
@Autowired
|
||||
private MongoTemplate mongoTemplate;
|
||||
|
||||
@Override
|
||||
public User selectUser(String phoneNumber, String password) {
|
||||
Query query = new Query(Criteria.where("phoneNumber").is(phoneNumber).and("password").is(password));
|
||||
return mongoTemplate.findOne(query, User.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean insertUser(User user) {
|
||||
try {
|
||||
mongoTemplate.save(user);
|
||||
} catch (Exception e) {
|
||||
log.error("用户插入失败");
|
||||
log.error(e.getMessage());
|
||||
throw new UserException("已存在用户");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> listUserLimit(String username, String phoneNumber, int offset, int limit) {
|
||||
Criteria criteria = new Criteria();
|
||||
@ -58,7 +38,7 @@ public class UserDaoImpl implements UserDao {
|
||||
|
||||
//电话号码精确查询
|
||||
if (phoneNumber != null) {
|
||||
criteria.and("phoneNumber").is(phoneNumber);
|
||||
criteria.and("phone").is(phoneNumber);
|
||||
}
|
||||
|
||||
Query query = new Query(criteria).skip(offset).limit(limit);
|
||||
@ -67,81 +47,62 @@ public class UserDaoImpl implements UserDao {
|
||||
|
||||
@Override
|
||||
public boolean existUser(String phoneNumber) {
|
||||
Query query = new Query(Criteria.where("phoneNumber").is(phoneNumber));
|
||||
|
||||
Query query = new Query(Criteria.where("phone").is(phoneNumber));
|
||||
return mongoTemplate.exists(query, User.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteUser(String phoneNumber) {
|
||||
Query query = new Query(Criteria.where("phoneNumber").is(phoneNumber));
|
||||
public void deleteUser(String phone) {
|
||||
Query query = new Query(Criteria.where("phone").is(phone));
|
||||
mongoTemplate.remove(query, User.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearRole(Role role) {
|
||||
Query query = new Query(Criteria.where("roleList").elemMatch(Criteria.where("$id").is(role.getId())));
|
||||
Query query = new Query(Criteria.where("roleSet").elemMatch(Criteria.where("$id").is(role.getId())));
|
||||
List<User> users = mongoTemplate.find(query, User.class);
|
||||
for (User user : users) {
|
||||
List<Role> roleList = user.getRoleList();
|
||||
Iterator<Role> it = roleList.iterator();
|
||||
Set<Role> roleSet = user.getRoleSet();
|
||||
Iterator<Role> it = roleSet.iterator();
|
||||
while (it.hasNext()) {
|
||||
if (role.getName().equals(it.next().getName())) {
|
||||
it.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
Query userQuery = new Query(Criteria.where("phoneNumber").is(user.getPhoneNumber()));
|
||||
Update update = new Update().set("roleList", roleList);
|
||||
Query userQuery = new Query(Criteria.where("phone").is(user.getPhone()));
|
||||
Update update = new Update().set("roleSet", roleSet);
|
||||
mongoTemplate.updateFirst(userQuery, update, User.class);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUserRole(String phoneNumber, List<Role> roleList) {
|
||||
Query query = new Query(Criteria.where("phoneNumber").is(phoneNumber));
|
||||
User user = mongoTemplate.findOne(query, User.class);
|
||||
if (user == null) {
|
||||
throw new UserException("用户不存在");
|
||||
}
|
||||
user.setRoleList(roleList);
|
||||
mongoTemplate.save(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String selectUsername(String phoneNumber) {
|
||||
Query query = new Query(Criteria.where("phoneNumber").is(phoneNumber));
|
||||
User user = mongoTemplate.findOne(query, User.class);
|
||||
if(user == null){
|
||||
log.error("用户不存在");
|
||||
throw new UserException("用户不存在");
|
||||
}
|
||||
return user.getUsername();
|
||||
}
|
||||
|
||||
@Override
|
||||
public User selectUser(String phoneNumber) {
|
||||
Query query = new Query(Criteria.where("phoneNumber").is(phoneNumber));
|
||||
public User selectUser(String phone) {
|
||||
Query query = new Query(Criteria.where("phone").is(phone));
|
||||
return mongoTemplate.findOne(query, User.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetPwd(String phoneNumber) {
|
||||
Query query = new Query(Criteria.where("phoneNumber").is(phoneNumber));
|
||||
Update update = new Update().set("password", "123456");
|
||||
|
||||
mongoTemplate.updateFirst(query, update, User.class);
|
||||
|
||||
public long countUser(String username, String phone) {
|
||||
Criteria criteria = new Criteria();
|
||||
if (username != null) {
|
||||
criteria.and("username").regex(username);
|
||||
}
|
||||
if (phone != null) {
|
||||
criteria.and("phone").is(phone);
|
||||
}
|
||||
Query query = new Query(criteria);
|
||||
return mongoTemplate.count(query, User.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyUser(UserInfoVo userInfoVo) {
|
||||
Query query = new Query(Criteria.where("phoneNumber").is(userInfoVo.getPhoneNumber()));
|
||||
Update update = new Update()
|
||||
.set("username", userInfoVo.getUsername())
|
||||
.set("idNumber", userInfoVo.getIdNumber())
|
||||
.set("administrativeArea", userInfoVo.getAdministrativeArea());
|
||||
mongoTemplate.updateFirst(query, update, User.class);
|
||||
public void saveUser(User user) {
|
||||
try {
|
||||
mongoTemplate.save(user);
|
||||
} catch (Exception e) {
|
||||
throw new UserException(ResultEnum.ALREADY_EXIST_USER);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,62 +0,0 @@
|
||||
package com.example.survey.dto;
|
||||
|
||||
import com.example.survey.dto.inner.RelevantUserInfo;
|
||||
import com.example.survey.entity.Respondent;
|
||||
import com.example.survey.entity.User;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class RespondentDto {
|
||||
|
||||
/**
|
||||
* 身份证号
|
||||
*/
|
||||
private String idNumber;
|
||||
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
private String phoneNumber;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 分配的人员
|
||||
*/
|
||||
private RelevantUserInfo relevantUserInfo;
|
||||
|
||||
/**
|
||||
* 是否发病
|
||||
*/
|
||||
private boolean diseased;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
private String gender;
|
||||
|
||||
public RespondentDto(Respondent respondent, User user){
|
||||
this.idNumber = respondent.getIdNumber();
|
||||
this.name = respondent.getName();
|
||||
this.phoneNumber = respondent.getPhoneNumber();
|
||||
this.relevantUserInfo = new RelevantUserInfo(user);
|
||||
this.diseased = respondent.isDiseased();
|
||||
this.gender = respondent.getGender();
|
||||
this.msg = respondent.getMsg();
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
package com.example.survey.dto;
|
||||
|
||||
import com.example.survey.dao.UserDao;
|
||||
import com.example.survey.entity.Department;
|
||||
import com.example.survey.entity.Role;
|
||||
import com.example.survey.entity.User;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UserDto {
|
||||
private String username;
|
||||
private String phoneNumber;
|
||||
private List<String> roleList;
|
||||
private List<Department> departmentList;
|
||||
|
||||
public UserDto(User user){
|
||||
username = user.getUsername();
|
||||
phoneNumber = user.getPhoneNumber();
|
||||
roleList = new LinkedList<>();
|
||||
for (Role role : user.getRoleList()) {
|
||||
roleList.add(role.getName());
|
||||
}
|
||||
departmentList = user.getDepartmentList();
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
package com.example.survey.dto.inner;
|
||||
|
||||
import com.example.survey.entity.User;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class RelevantUserInfo {
|
||||
/**
|
||||
* 身份证号
|
||||
*/
|
||||
private String idNumber;
|
||||
|
||||
/**
|
||||
* 电话号码
|
||||
*/
|
||||
private String phoneNumber;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
public RelevantUserInfo(User user) {
|
||||
this.idNumber = user.getIdNumber();
|
||||
this.phoneNumber = user.getPhoneNumber();
|
||||
this.username = user.getUsername();
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.example.survey.dto.metaData;
|
||||
|
||||
import com.example.survey.entity.inner.FieldToName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Data
|
||||
public class CreateMetaDataDTO {
|
||||
private String name;
|
||||
private Map<String,Object> form;
|
||||
private List<FieldToName> fieldToNameList;
|
||||
private Map<String, Object> config;
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.example.survey.dto.metaData;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Data
|
||||
public class DeleteMetaDataDTO {
|
||||
private String name;
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.example.survey.dto.metaData;
|
||||
|
||||
import com.example.survey.entity.inner.FieldToName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Data
|
||||
public class ModifyMetaDataDTO {
|
||||
private String name;
|
||||
private Map<String,Object> form;
|
||||
private List<FieldToName> fieldToNameList;
|
||||
private Map<String, Object> config;
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package com.example.survey.dto.project;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Data
|
||||
public class CreateProjectDTO {
|
||||
|
||||
/**
|
||||
* 项目名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述信息
|
||||
*/
|
||||
private String detail;
|
||||
|
||||
/**
|
||||
* 元数据名字
|
||||
*/
|
||||
private String metaDataName;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
* 负责人电话号码
|
||||
*/
|
||||
private String userPhone;
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.example.survey.dto.project;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Data
|
||||
public class ModifyProjectDTO {
|
||||
private String name;
|
||||
private String detail;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date startTime;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date endTime;
|
||||
private String userPhone;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.example.survey.dto.project;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Data
|
||||
public class ModifyStateDTO {
|
||||
private String name;
|
||||
private String state;
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.example.survey.dto.record;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Data
|
||||
public class ModifyRecordDTO {
|
||||
private String idNumber;
|
||||
private Map<String, Object> values;
|
||||
private String userPhone;
|
||||
private String msg;
|
||||
private String projectName;
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.example.survey.dto.record;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ReviewRecordDTO {
|
||||
private String idNumber;
|
||||
private String projectName;
|
||||
private Boolean pass;
|
||||
private String msg;
|
||||
private String reviewerPhone;
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.example.survey.dto.record;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SubmitRecordDTO {
|
||||
private String idNumber;
|
||||
|
||||
private Map<String, Object> values;
|
||||
|
||||
private String userPhone;
|
||||
|
||||
private String msg;
|
||||
|
||||
private String projectName;
|
||||
|
||||
}
|
@ -1,9 +1,12 @@
|
||||
package com.example.survey.vo;
|
||||
package com.example.survey.dto.respondent;
|
||||
|
||||
import com.example.survey.entity.Project;
|
||||
import com.example.survey.entity.inner.AdministrativeArea;
|
||||
import lombok.*;
|
||||
import org.springframework.data.mongodb.core.index.Indexed;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@ -12,7 +15,7 @@ import org.springframework.data.mongodb.core.index.Indexed;
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CreateRespondentVo {
|
||||
public class CreateRespondentDTO {
|
||||
/**
|
||||
* 身份证号
|
||||
*/
|
||||
@ -21,7 +24,7 @@ public class CreateRespondentVo {
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
private String phoneNumber;
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
@ -33,16 +36,6 @@ public class CreateRespondentVo {
|
||||
*/
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 分配的调查人员
|
||||
*/
|
||||
private String userPhone;
|
||||
|
||||
/**
|
||||
* 是否发病
|
||||
*/
|
||||
private boolean diseased;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
@ -52,4 +45,15 @@ public class CreateRespondentVo {
|
||||
* 行政区划
|
||||
*/
|
||||
private AdministrativeArea administrativeArea;
|
||||
|
||||
/**
|
||||
* 分配人员
|
||||
*/
|
||||
private String userPhone;
|
||||
|
||||
/**
|
||||
* 项目名集合
|
||||
*/
|
||||
private String projectName;
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.example.survey.dto.respondent;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DeleteRespondentDTO {
|
||||
|
||||
private String idNumber;
|
||||
private String projectName;
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package com.example.survey.dto.respondent;
|
||||
|
||||
import com.example.survey.entity.inner.AdministrativeArea;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ModifyRespondentDTO {
|
||||
|
||||
/**
|
||||
* 身份证号
|
||||
*/
|
||||
private String idNumber;
|
||||
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
private String gender;
|
||||
|
||||
/**
|
||||
* 行政区划
|
||||
*/
|
||||
private AdministrativeArea administrativeArea;
|
||||
|
||||
/**
|
||||
* 项目名
|
||||
*/
|
||||
private String projectName;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.example.survey.dto.respondent;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Data
|
||||
public class ModifyRespondentUserDTO {
|
||||
private String idNumber;
|
||||
private String projectName;
|
||||
private String userPhone;
|
||||
}
|
29
src/main/java/com/example/survey/dto/role/CreateRoleDTO.java
Normal file
29
src/main/java/com/example/survey/dto/role/CreateRoleDTO.java
Normal file
@ -0,0 +1,29 @@
|
||||
package com.example.survey.dto.role;
|
||||
|
||||
import com.example.survey.entity.Role;
|
||||
import com.example.survey.enumeration.AuthEnum;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CreateRoleDTO {
|
||||
private String name;
|
||||
private Set<String> authoritySet;
|
||||
|
||||
public CreateRoleDTO(Role role) {
|
||||
name = role.getName();
|
||||
authoritySet = new HashSet<>();
|
||||
for (AuthEnum authEnum : role.getAuthoritySet()) {
|
||||
authoritySet.add(authEnum.getName());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.example.survey.vo;
|
||||
package com.example.survey.dto.role;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@ -10,8 +10,8 @@ import lombok.*;
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DeleteRoleVo {
|
||||
public class DeleteRoleDTO {
|
||||
|
||||
private String roleName;
|
||||
private String name;
|
||||
|
||||
}
|
19
src/main/java/com/example/survey/dto/role/ModifyRoleDTO.java
Normal file
19
src/main/java/com/example/survey/dto/role/ModifyRoleDTO.java
Normal file
@ -0,0 +1,19 @@
|
||||
package com.example.survey.dto.role;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ModifyRoleDTO {
|
||||
private String name;
|
||||
private Set<String> authoritySet;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.example.survey.vo;
|
||||
package com.example.survey.dto.user;
|
||||
|
||||
import com.example.survey.entity.inner.AdministrativeArea;
|
||||
import lombok.*;
|
||||
@ -11,7 +11,7 @@ import lombok.*;
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CreateUserVo {
|
||||
public class CreateUserDTO {
|
||||
/**
|
||||
* 身份证号
|
||||
*/
|
||||
@ -23,7 +23,7 @@ public class CreateUserVo {
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String phoneNumber;
|
||||
private String phone;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
@ -1,4 +1,4 @@
|
||||
package com.example.survey.vo;
|
||||
package com.example.survey.dto.user;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@ -10,8 +10,8 @@ import lombok.*;
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DeleteUserVo {
|
||||
public class DeleteUserDTO {
|
||||
|
||||
private String phoneNumber;
|
||||
private String phone;
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.example.survey.vo;
|
||||
package com.example.survey.dto.user;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@ -10,7 +10,7 @@ import lombok.*;
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class LoginVo {
|
||||
private String phoneNumber;
|
||||
public class LoginDTO {
|
||||
private String phone;
|
||||
private String password;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.example.survey.vo;
|
||||
package com.example.survey.dto.user;
|
||||
|
||||
import com.example.survey.entity.Department;
|
||||
import com.example.survey.entity.inner.AdministrativeArea;
|
||||
@ -14,12 +14,12 @@ import java.util.List;
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UserInfoVo {
|
||||
public class ModifyUserInfoDTO {
|
||||
|
||||
/**
|
||||
* 电话号码
|
||||
*/
|
||||
private String phoneNumber;
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 用户名
|
@ -0,0 +1,19 @@
|
||||
package com.example.survey.dto.user;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ModifyUserRoleDTO {
|
||||
private String phone;
|
||||
private Set<String> roleSet;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.example.survey.vo;
|
||||
package com.example.survey.dto.user;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@ -10,10 +10,10 @@ import lombok.*;
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ResetPwdVo {
|
||||
public class ResetPwdDTO {
|
||||
|
||||
/**
|
||||
* 电话号码
|
||||
*/
|
||||
private String phoneNumber;
|
||||
private String phone;
|
||||
}
|
20
src/main/java/com/example/survey/entity/Audit.java
Normal file
20
src/main/java/com/example/survey/entity/Audit.java
Normal file
@ -0,0 +1,20 @@
|
||||
package com.example.survey.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Data
|
||||
@Document(collection = "audit")
|
||||
public class Audit {
|
||||
|
||||
private String userPhone;
|
||||
private String ip;
|
||||
private Date time;
|
||||
private String route;
|
||||
|
||||
}
|
@ -11,11 +11,7 @@ import java.util.List;
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@Document(collection = "department")
|
||||
public class Department {
|
||||
|
||||
|
@ -1,339 +0,0 @@
|
||||
package com.example.survey.entity;
|
||||
|
||||
import com.example.survey.entity.inner.*;
|
||||
import com.example.survey.vo.InvestigationRecordVo;
|
||||
import lombok.*;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.springframework.data.mongodb.core.index.Indexed;
|
||||
import org.springframework.data.mongodb.core.mapping.DBRef;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
* 调查记录表
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Document(collection = "investigationRecord")
|
||||
public class InvestigationRecord {
|
||||
|
||||
/**
|
||||
* 调查记录审核中状态
|
||||
*/
|
||||
public static final String UNDER_REVIEW = "待审核";
|
||||
|
||||
/**
|
||||
* 调查记录已审核状态
|
||||
*/
|
||||
public static final String REVIEWED = "已通过";
|
||||
|
||||
/**
|
||||
* 调查记录已删除状态
|
||||
*/
|
||||
public static final String DELETED = "已删除";
|
||||
|
||||
/**
|
||||
* 调查记录审核未通过状态
|
||||
*/
|
||||
public static final String NOT_PASS = "未通过";
|
||||
|
||||
/**
|
||||
* 调查记录旧档状态
|
||||
*/
|
||||
public static final String OUT_OF_DATE = "已归档";
|
||||
|
||||
/**
|
||||
* 调查对象性别为男
|
||||
*/
|
||||
public static final String MAN = "男";
|
||||
|
||||
/**
|
||||
* 调查对象性别为女
|
||||
*/
|
||||
public static final String WOMAN = "女";
|
||||
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private ObjectId id;
|
||||
|
||||
/**
|
||||
* 问卷编号
|
||||
*/
|
||||
private String questionnaireNumber;
|
||||
|
||||
/**
|
||||
* 身份证号
|
||||
* 唯一索引
|
||||
*/
|
||||
private String idNumber;
|
||||
|
||||
//==================================基本信息==================================
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
* true为男性,false为女性
|
||||
*/
|
||||
private String gender;
|
||||
|
||||
/**
|
||||
* 是否为境外病例
|
||||
*/
|
||||
private boolean overseasCase;
|
||||
|
||||
/**
|
||||
* 是否为病例
|
||||
* 区分病例与密切接触者
|
||||
*/
|
||||
private boolean diseased;
|
||||
|
||||
/**
|
||||
* 入境经历
|
||||
* 选填
|
||||
*/
|
||||
private EntryExperience entryExperience;
|
||||
|
||||
//==================================病例发现与就诊==================================
|
||||
|
||||
/**
|
||||
* 病例被发现途径
|
||||
*/
|
||||
private String wayOfBeingDiscovered;
|
||||
|
||||
/**
|
||||
* 入院时间
|
||||
*/
|
||||
private Date dateOfAdmission;
|
||||
|
||||
/**
|
||||
* 入院时症状和体征
|
||||
*/
|
||||
private List<String> symptomAndSign;
|
||||
|
||||
/**
|
||||
* 有无并发症
|
||||
*/
|
||||
private boolean existComplication;
|
||||
|
||||
/**
|
||||
* 并发症
|
||||
* 选填
|
||||
*/
|
||||
private List<String> complication;
|
||||
|
||||
/**
|
||||
* 并发症存在发热时记录最高体温
|
||||
*/
|
||||
private String maxTemp;
|
||||
|
||||
/**
|
||||
* 胸部X线或 CT 检测是否有肺炎影像学特征
|
||||
*/
|
||||
private boolean existImagingFeatureOfPneumonia;
|
||||
|
||||
/**
|
||||
* 如果肺炎影像学特征为是,此处填检测时间
|
||||
*/
|
||||
private Date testDate;
|
||||
|
||||
/**
|
||||
* 出院日期
|
||||
* 年月日
|
||||
*/
|
||||
private Date dateOfDischarge;
|
||||
|
||||
//==================================危险因素与暴露史==================================
|
||||
|
||||
/**
|
||||
* 是否为特定职业人群
|
||||
*/
|
||||
private String specificOccupation;
|
||||
|
||||
/**
|
||||
* 当specificOccupation为other时起作用
|
||||
*/
|
||||
private String otherSpecificOccupation;
|
||||
|
||||
/**
|
||||
* 如为医护人员,填写具体工作性质
|
||||
*/
|
||||
private String workInformation;
|
||||
|
||||
/**
|
||||
* 当workInformation为other时起作用
|
||||
*/
|
||||
private String otherWorkInformation;
|
||||
|
||||
/**
|
||||
* 是否为孕妇
|
||||
*/
|
||||
private boolean pregnant;
|
||||
|
||||
/**
|
||||
* 孕周
|
||||
*/
|
||||
private int pregnantWeek;
|
||||
|
||||
/**
|
||||
* 病史
|
||||
*/
|
||||
private List<String> medicalHistory;
|
||||
|
||||
/**
|
||||
* 对既往病史的详细描述
|
||||
*/
|
||||
private String medicalHistoryDetail;
|
||||
|
||||
//==================================发病或检测阳性前14天内是否有以下暴露史或接触史==================================
|
||||
|
||||
/**
|
||||
* 是否有境外疫情严重国家或地区的旅行史或居住史
|
||||
*/
|
||||
private boolean nearSeriousRegion;
|
||||
|
||||
/**
|
||||
* 是否接触过来自境外疫情严重的国家或地区的发热或有呼吸道症状的患者
|
||||
*/
|
||||
private boolean contactWithSeriousRegionPatients;
|
||||
|
||||
/**
|
||||
* 是否曾有确诊病例或无症状感染者的接触史
|
||||
*/
|
||||
private boolean contactWithConfirmedCase;
|
||||
|
||||
/**
|
||||
* 患者同一家庭、办公室、学校或托幼机构班级、车间等集体单位是否有聚集性发病
|
||||
*/
|
||||
private boolean aggregationDisease;
|
||||
|
||||
|
||||
//==================================实验室检测==================================
|
||||
|
||||
/**
|
||||
* 实验室检测结果,未采集则value为null
|
||||
*/
|
||||
private List<Detection> detectionList;
|
||||
|
||||
/**
|
||||
* 调查单位
|
||||
*/
|
||||
private String investigationCompany;
|
||||
|
||||
/**
|
||||
* 调查者(电话号码)
|
||||
* 外键
|
||||
*/
|
||||
@Indexed
|
||||
private String userPhone;
|
||||
|
||||
/**
|
||||
* 调查日期
|
||||
* 年月日
|
||||
*/
|
||||
private Date investigationDate;
|
||||
|
||||
/**
|
||||
* 体温历史
|
||||
*/
|
||||
private List<TempHistory> tempHistoryList;
|
||||
|
||||
/**
|
||||
* 居住史
|
||||
*/
|
||||
private List<LiveHistory> liveHistoryList;
|
||||
|
||||
/**
|
||||
* 旅行史
|
||||
*/
|
||||
private List<TravelHistory> travelHistoryList;
|
||||
|
||||
/**
|
||||
* 状态信息
|
||||
*/
|
||||
private String state;
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 操作列表
|
||||
*/
|
||||
private List<OperationInformation> operationInformationList;
|
||||
|
||||
//========================================保留字段============================================
|
||||
|
||||
/**
|
||||
* 密切接触者(身份证)
|
||||
* 外键
|
||||
*/
|
||||
@DBRef
|
||||
private List<InvestigationRecord> closeContactList;
|
||||
|
||||
/**
|
||||
* 上级感染者
|
||||
*/
|
||||
private List<SuperiorInfectedIndividual> superiorInfectedIndividualList;
|
||||
|
||||
/**
|
||||
* 存放一些url
|
||||
*/
|
||||
private Map<String, String> urlMap;
|
||||
|
||||
|
||||
public InvestigationRecord(InvestigationRecordVo vo) {
|
||||
questionnaireNumber = vo.getQuestionnaireNumber();
|
||||
idNumber = vo.getIdNumber();
|
||||
name = vo.getName();
|
||||
gender = vo.getGender();
|
||||
overseasCase = vo.isOverseasCase();
|
||||
diseased = vo.isDiseased();
|
||||
entryExperience = vo.getEntryExperience();
|
||||
wayOfBeingDiscovered = vo.getWayOfBeingDiscovered();
|
||||
dateOfAdmission = vo.getDateOfAdmission();
|
||||
symptomAndSign = vo.getSymptomAndSign();
|
||||
existComplication = vo.isExistComplication();
|
||||
complication = vo.getComplication();
|
||||
maxTemp = vo.getMaxTemp();
|
||||
existImagingFeatureOfPneumonia = vo.isExistImagingFeatureOfPneumonia();
|
||||
testDate = vo.getTestDate();
|
||||
dateOfDischarge = vo.getDateOfDischarge();
|
||||
specificOccupation = vo.getSpecificOccupation();
|
||||
otherSpecificOccupation = vo.getOtherSpecificOccupation();
|
||||
workInformation = vo.getWorkInformation();
|
||||
otherWorkInformation = vo.getOtherWorkInformation();
|
||||
pregnant = vo.isPregnant();
|
||||
pregnantWeek = vo.getPregnantWeek();
|
||||
medicalHistory = vo.getMedicalHistory();
|
||||
medicalHistoryDetail = vo.getMedicalHistoryDetail();
|
||||
nearSeriousRegion = vo.isNearSeriousRegion();
|
||||
contactWithSeriousRegionPatients = vo.isContactWithSeriousRegionPatients();
|
||||
contactWithConfirmedCase = vo.isContactWithConfirmedCase();
|
||||
aggregationDisease = vo.isAggregationDisease();
|
||||
detectionList = vo.getDetectionList();
|
||||
investigationCompany = vo.getInvestigationCompany();
|
||||
userPhone = vo.getUserPhone();
|
||||
investigationDate = vo.getInvestigationDate();
|
||||
tempHistoryList = vo.getTempHistoryList();
|
||||
liveHistoryList = vo.getLiveHistoryList();
|
||||
travelHistoryList = vo.getTravelHistoryList();
|
||||
closeContactList = new ArrayList<>();
|
||||
superiorInfectedIndividualList = new ArrayList<>();
|
||||
urlMap = vo.getUrlMap();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
23
src/main/java/com/example/survey/entity/MetaData.java
Normal file
23
src/main/java/com/example/survey/entity/MetaData.java
Normal file
@ -0,0 +1,23 @@
|
||||
package com.example.survey.entity;
|
||||
|
||||
import com.example.survey.entity.inner.FieldToName;
|
||||
import lombok.*;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Data
|
||||
@Document(collection = "metaData")
|
||||
public class MetaData {
|
||||
private ObjectId id;
|
||||
private String name;
|
||||
private Map<String,Object> form;
|
||||
private List<FieldToName> fieldToNameList;
|
||||
private String wordTemplate;
|
||||
private Map<String, Object> config;
|
||||
}
|
73
src/main/java/com/example/survey/entity/Project.java
Normal file
73
src/main/java/com/example/survey/entity/Project.java
Normal file
@ -0,0 +1,73 @@
|
||||
package com.example.survey.entity;
|
||||
|
||||
import lombok.*;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.index.Indexed;
|
||||
import org.springframework.data.mongodb.core.mapping.DBRef;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Data
|
||||
@Document(collection = "project")
|
||||
public class Project {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@Id
|
||||
private ObjectId id;
|
||||
|
||||
/**
|
||||
* 项目名
|
||||
*/
|
||||
@Indexed(unique = true)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述信息
|
||||
*/
|
||||
private String detail;
|
||||
|
||||
/**
|
||||
* 元数据
|
||||
*/
|
||||
@DBRef
|
||||
private MetaData metaData;
|
||||
|
||||
/**
|
||||
* 调查对象数量
|
||||
*/
|
||||
private long respondentCount;
|
||||
|
||||
/**
|
||||
* 未调查调查对象数量
|
||||
*/
|
||||
private long notInvestigatedRespondentCount;
|
||||
|
||||
/**
|
||||
* 负责人
|
||||
*/
|
||||
@DBRef
|
||||
private User user;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String state;
|
||||
}
|
63
src/main/java/com/example/survey/entity/Record.java
Normal file
63
src/main/java/com/example/survey/entity/Record.java
Normal file
@ -0,0 +1,63 @@
|
||||
package com.example.survey.entity;
|
||||
|
||||
import com.example.survey.entity.inner.Operation;
|
||||
import lombok.*;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.DBRef;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
* 调查记录表
|
||||
*/
|
||||
@Data
|
||||
@Document(collection = "record")
|
||||
public class Record {
|
||||
|
||||
@Id
|
||||
private ObjectId id;
|
||||
|
||||
/**
|
||||
* 调查对象
|
||||
*/
|
||||
@DBRef
|
||||
private Respondent respondent;
|
||||
|
||||
/**
|
||||
* 用于存放前端传的字段
|
||||
*/
|
||||
private Map<String, Object> values;
|
||||
|
||||
/**
|
||||
* 分配的用户
|
||||
*/
|
||||
@DBRef
|
||||
private User user;
|
||||
|
||||
/**
|
||||
* 操作列表
|
||||
*/
|
||||
private List<Operation> operationList;
|
||||
|
||||
/**
|
||||
* 记录版本
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 记录状态
|
||||
*/
|
||||
private String state;
|
||||
|
||||
/**
|
||||
* 项目集合
|
||||
*/
|
||||
@DBRef
|
||||
private Project project;
|
||||
|
||||
}
|
||||
|
@ -1,23 +1,21 @@
|
||||
package com.example.survey.entity;
|
||||
|
||||
import com.example.survey.entity.inner.AdministrativeArea;
|
||||
import com.example.survey.enumeration.RespondentStateEnum;
|
||||
import com.example.survey.vo.CreateRespondentVo;
|
||||
import com.example.survey.entity.inner.ProjectPart;
|
||||
import lombok.*;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.index.Indexed;
|
||||
import org.springframework.data.mongodb.core.mapping.DBRef;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
* 调查对象表
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@Document(collection = "respondent")
|
||||
public class Respondent {
|
||||
|
||||
@ -36,7 +34,7 @@ public class Respondent {
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
private String phoneNumber;
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
@ -48,17 +46,6 @@ public class Respondent {
|
||||
*/
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 分配的调查人员
|
||||
*/
|
||||
@Indexed
|
||||
private String userPhone;
|
||||
|
||||
/**
|
||||
* 是否发病
|
||||
*/
|
||||
private boolean diseased;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
@ -70,19 +57,17 @@ public class Respondent {
|
||||
private AdministrativeArea administrativeArea;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
* 分配的人员
|
||||
*/
|
||||
private User user;
|
||||
|
||||
/**
|
||||
* 项目
|
||||
*/
|
||||
private Project project;
|
||||
|
||||
/**
|
||||
* 调查对象状态
|
||||
*/
|
||||
private String state;
|
||||
|
||||
public Respondent(CreateRespondentVo createRespondentVo) {
|
||||
this.idNumber = createRespondentVo.getIdNumber();
|
||||
this.phoneNumber = createRespondentVo.getPhoneNumber();
|
||||
this.name = createRespondentVo.getName();
|
||||
this.msg = createRespondentVo.getMsg();
|
||||
this.userPhone = createRespondentVo.getUserPhone();
|
||||
this.diseased = createRespondentVo.isDiseased();
|
||||
this.gender = createRespondentVo.getGender();
|
||||
this.administrativeArea = createRespondentVo.getAdministrativeArea();
|
||||
this.state = RespondentStateEnum.NOT_INVESTIGATED.getValue();
|
||||
}
|
||||
}
|
||||
|
@ -7,16 +7,13 @@ import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.index.Indexed;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@Document(collection = "role")
|
||||
public class Role {
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.example.survey.entity;
|
||||
|
||||
import com.example.survey.entity.inner.AdministrativeArea;
|
||||
import com.example.survey.vo.CreateUserVo;
|
||||
import com.example.survey.dto.user.CreateUserDTO;
|
||||
import lombok.*;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.springframework.data.annotation.Id;
|
||||
@ -14,11 +14,7 @@ import java.util.*;
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@Document(collection = "user")
|
||||
public class User {
|
||||
|
||||
@ -52,13 +48,13 @@ public class User {
|
||||
* 手机号
|
||||
*/
|
||||
@Indexed(unique = true)
|
||||
private String phoneNumber;
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 一个人可以拥有多个角色
|
||||
*/
|
||||
@DBRef
|
||||
private List<Role> roleList;
|
||||
private Set<Role> roleSet;
|
||||
|
||||
/**
|
||||
* 一个人所属的部门
|
||||
@ -66,14 +62,4 @@ public class User {
|
||||
@DBRef
|
||||
private List<Department> departmentList;
|
||||
|
||||
|
||||
public User(CreateUserVo vo) {
|
||||
username = vo.getUsername();
|
||||
password = vo.getPassword();
|
||||
idNumber = vo.getIdNumber();
|
||||
phoneNumber = vo.getPhoneNumber();
|
||||
roleList = new LinkedList<>();
|
||||
departmentList = new LinkedList<>();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,10 +5,7 @@ import lombok.*;
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class AdministrativeArea {
|
||||
/**
|
||||
|
@ -1,36 +0,0 @@
|
||||
package com.example.survey.entity.inner;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
* 检测项目
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Detection {
|
||||
|
||||
/**
|
||||
* 检测项目名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 检测时间
|
||||
* 年月日
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date date;
|
||||
|
||||
/**
|
||||
* 检测结果
|
||||
*/
|
||||
private String result;
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
package com.example.survey.entity.inner;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Pope\
|
||||
* 入境经历
|
||||
*/
|
||||
public class EntryExperience {
|
||||
/**
|
||||
* 入境前居住或旅行的国家或地区
|
||||
*/
|
||||
private String areaOfResidence;
|
||||
|
||||
/**
|
||||
* 入境前途径的国家或地区
|
||||
*/
|
||||
private String areaOfAccess;
|
||||
|
||||
/**
|
||||
* 国籍
|
||||
*/
|
||||
private String nationality;
|
||||
|
||||
/**
|
||||
* 护照号码
|
||||
*/
|
||||
private String passportNumber;
|
||||
|
||||
/**
|
||||
* 入境口岸
|
||||
*/
|
||||
private EntryPort entryPort;
|
||||
|
||||
/**
|
||||
* 入境日期
|
||||
* 年月日
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date entryDate;
|
||||
|
||||
/**
|
||||
* 入境交通方式
|
||||
* 航班号、车次、船号等
|
||||
*/
|
||||
private String transportation;
|
||||
|
||||
|
||||
public EntryExperience() {
|
||||
}
|
||||
|
||||
public EntryExperience(String areaOfResidence, String areaOfAccess, String nationality, String passportNumber, EntryPort entryPort, Date entryDate, String transportation) {
|
||||
this.areaOfResidence = areaOfResidence;
|
||||
this.areaOfAccess = areaOfAccess;
|
||||
this.nationality = nationality;
|
||||
this.passportNumber = passportNumber;
|
||||
this.entryPort = entryPort;
|
||||
this.entryDate = entryDate;
|
||||
this.transportation = transportation;
|
||||
}
|
||||
|
||||
public String getAreaOfResidence() {
|
||||
return areaOfResidence;
|
||||
}
|
||||
|
||||
public void setAreaOfResidence(String areaOfResidence) {
|
||||
this.areaOfResidence = areaOfResidence;
|
||||
}
|
||||
|
||||
public String getAreaOfAccess() {
|
||||
return areaOfAccess;
|
||||
}
|
||||
|
||||
public void setAreaOfAccess(String areaOfAccess) {
|
||||
this.areaOfAccess = areaOfAccess;
|
||||
}
|
||||
|
||||
public String getNationality() {
|
||||
return nationality;
|
||||
}
|
||||
|
||||
public void setNationality(String nationality) {
|
||||
this.nationality = nationality;
|
||||
}
|
||||
|
||||
public String getPassportNumber() {
|
||||
return passportNumber;
|
||||
}
|
||||
|
||||
public void setPassportNumber(String passportNumber) {
|
||||
this.passportNumber = passportNumber;
|
||||
}
|
||||
|
||||
public EntryPort getEntryPort() {
|
||||
return entryPort;
|
||||
}
|
||||
|
||||
public void setEntryPort(EntryPort entryPort) {
|
||||
this.entryPort = entryPort;
|
||||
}
|
||||
|
||||
public Date getEntryDate() {
|
||||
return entryDate;
|
||||
}
|
||||
|
||||
public void setEntryDate(Date entryDate) {
|
||||
this.entryDate = entryDate;
|
||||
}
|
||||
|
||||
public String getTransportation() {
|
||||
return transportation;
|
||||
}
|
||||
|
||||
public void setTransportation(String transportation) {
|
||||
this.transportation = transportation;
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package com.example.survey.entity.inner;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
* 入境口岸
|
||||
*/
|
||||
public class EntryPort {
|
||||
/**
|
||||
* 入境省份
|
||||
*/
|
||||
private String province;
|
||||
|
||||
/**
|
||||
* 入境机场、码头、车站等
|
||||
*/
|
||||
private String port;
|
||||
|
||||
public EntryPort() {
|
||||
}
|
||||
|
||||
public EntryPort(String province, String port) {
|
||||
this.province = province;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getProvince() {
|
||||
return province;
|
||||
}
|
||||
|
||||
public void setProvince(String province) {
|
||||
this.province = province;
|
||||
}
|
||||
|
||||
public String getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(String port) {
|
||||
this.port = port;
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.example.survey.entity.inner;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Data
|
||||
public class FieldToName {
|
||||
private String field;
|
||||
private String name;
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package com.example.survey.entity.inner;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
* 居旅史
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class LiveHistory {
|
||||
|
||||
/**
|
||||
* 起始时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date beginTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
* 地点
|
||||
*/
|
||||
private Location location;
|
||||
|
||||
/**
|
||||
* 事件
|
||||
*/
|
||||
private String detail;
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package com.example.survey.entity.inner;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Location {
|
||||
|
||||
/**
|
||||
* 地点信息
|
||||
*/
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
private double longitude;
|
||||
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
private double latitude;
|
||||
|
||||
}
|
107
src/main/java/com/example/survey/entity/inner/Operation.java
Normal file
107
src/main/java/com/example/survey/entity/inner/Operation.java
Normal file
@ -0,0 +1,107 @@
|
||||
package com.example.survey.entity.inner;
|
||||
|
||||
import com.example.survey.entity.User;
|
||||
import com.example.survey.enumeration.OpTypeEnum;
|
||||
import lombok.*;
|
||||
import org.springframework.data.mongodb.core.mapping.DBRef;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
* 操作信息
|
||||
*/
|
||||
@Data
|
||||
public class Operation {
|
||||
|
||||
/**
|
||||
* 操作
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 时间
|
||||
*/
|
||||
private Date time;
|
||||
|
||||
/**
|
||||
* 操作者
|
||||
*/
|
||||
@DBRef
|
||||
private User user;
|
||||
|
||||
/**
|
||||
* 版本信息
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 操作结果
|
||||
*/
|
||||
private String result;
|
||||
|
||||
|
||||
public static Operation submitOp(User user, String msg, String version) {
|
||||
Operation submit = new Operation();
|
||||
submit.setType(OpTypeEnum.SUBMIT.getValue());
|
||||
submit.setTime(new Date());
|
||||
submit.setUser(user);
|
||||
submit.setVersion(version);
|
||||
submit.setMsg(msg);
|
||||
submit.setResult("提交成功");
|
||||
return submit;
|
||||
}
|
||||
|
||||
public static Operation modifyOp(User user, String msg, String version) {
|
||||
Operation modify = new Operation();
|
||||
modify.setType(OpTypeEnum.MODIFY.getValue());
|
||||
modify.setTime(new Date());
|
||||
modify.setUser(user);
|
||||
modify.setVersion(version);
|
||||
modify.setMsg(msg);
|
||||
modify.setResult("提交修改");
|
||||
return modify;
|
||||
}
|
||||
|
||||
public static Operation deleteOp(User user, String msg, String version) {
|
||||
Operation delete = new Operation();
|
||||
delete.setType(OpTypeEnum.DELETE.getValue());
|
||||
delete.setTime(new Date());
|
||||
delete.setUser(user);
|
||||
delete.setVersion(version);
|
||||
delete.setMsg(msg);
|
||||
delete.setResult("删除成功");
|
||||
return delete;
|
||||
}
|
||||
|
||||
public static Operation reviewOp(User user, String msg, String version, boolean result) {
|
||||
Operation review = new Operation();
|
||||
review.setType(OpTypeEnum.REVIEW.getValue());
|
||||
review.setTime(new Date());
|
||||
review.setUser(user);
|
||||
review.setVersion(version);
|
||||
review.setMsg(msg);
|
||||
if (result) {
|
||||
review.setResult("审核通过");
|
||||
} else {
|
||||
review.setResult("审核不通过");
|
||||
}
|
||||
return review;
|
||||
}
|
||||
|
||||
public static Operation coverOp(User user, String version) {
|
||||
Operation cover = new Operation();
|
||||
cover.setType(OpTypeEnum.COVER.getValue());
|
||||
cover.setTime(new Date());
|
||||
cover.setUser(user);
|
||||
cover.setVersion(version);
|
||||
cover.setMsg("因重复提交覆盖");
|
||||
cover.setResult("被覆盖");
|
||||
return cover;
|
||||
}
|
||||
}
|
@ -1,113 +0,0 @@
|
||||
package com.example.survey.entity.inner;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
* 操作信息
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class OperationInformation {
|
||||
|
||||
public static final String SUBMIT = "提交";
|
||||
|
||||
/**
|
||||
* 修改操作
|
||||
*/
|
||||
public static final String MODIFY = "修改";
|
||||
|
||||
/**
|
||||
* 删除操作
|
||||
*/
|
||||
public static final String DELETE = "删除";
|
||||
|
||||
/**
|
||||
* 恢复记录
|
||||
*/
|
||||
public static final String RECOVERY = "恢复";
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final String REVIEW = "审核";
|
||||
|
||||
/**
|
||||
* 操作
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 时间
|
||||
*/
|
||||
private Date time;
|
||||
|
||||
/**
|
||||
* 操作者id
|
||||
*/
|
||||
private String userPhone;
|
||||
|
||||
/**
|
||||
* 版本信息
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 操作结果
|
||||
*/
|
||||
private String result;
|
||||
|
||||
public static OperationInformation submitOp(String userPhone, String msg) {
|
||||
OperationInformation submit = new OperationInformation();
|
||||
submit.setType(SUBMIT);
|
||||
submit.setTime(new Date());
|
||||
submit.setUserPhone(userPhone);
|
||||
submit.setVersion(userPhone + new Date().toString());
|
||||
submit.setMsg(msg);
|
||||
submit.setResult("提交成功");
|
||||
return submit;
|
||||
}
|
||||
|
||||
public static OperationInformation modifyOp(String investigatorPhone, String msg) {
|
||||
OperationInformation modify = new OperationInformation();
|
||||
modify.setType(MODIFY);
|
||||
modify.setTime(new Date());
|
||||
modify.setUserPhone(investigatorPhone);
|
||||
modify.setVersion(investigatorPhone + new Date().toString());
|
||||
modify.setMsg(msg);
|
||||
modify.setResult("提交修改");
|
||||
return modify;
|
||||
}
|
||||
|
||||
public static OperationInformation deleteOp(String investigatorPhone, String msg) {
|
||||
OperationInformation delete = new OperationInformation();
|
||||
delete.setType(MODIFY);
|
||||
delete.setTime(new Date());
|
||||
delete.setUserPhone(investigatorPhone);
|
||||
delete.setVersion(investigatorPhone + new Date().toString());
|
||||
delete.setMsg(msg);
|
||||
delete.setResult("删除成功");
|
||||
return delete;
|
||||
}
|
||||
|
||||
public static OperationInformation reviewOp(String investigatorPhone, String msg, String result) {
|
||||
OperationInformation review = new OperationInformation();
|
||||
review.setType(REVIEW);
|
||||
review.setTime(new Date());
|
||||
review.setUserPhone(investigatorPhone);
|
||||
review.setVersion(investigatorPhone + new Date().toString());
|
||||
review.setMsg(msg);
|
||||
review.setResult(result);
|
||||
return review;
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.example.survey.entity.inner;
|
||||
|
||||
import com.example.survey.entity.Project;
|
||||
import com.example.survey.entity.User;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.mongodb.core.index.Indexed;
|
||||
import org.springframework.data.mongodb.core.mapping.DBRef;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Data
|
||||
public class ProjectPart {
|
||||
/**
|
||||
* 项目
|
||||
*/
|
||||
@Indexed
|
||||
@DBRef
|
||||
Project project;
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*/
|
||||
@Indexed
|
||||
@DBRef
|
||||
User user;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
String state;
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
package com.example.survey.entity.inner;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
* 上级感染者
|
||||
*/
|
||||
public class SuperiorInfectedIndividual {
|
||||
|
||||
/**
|
||||
* 身份证
|
||||
*/
|
||||
private String idNumber;
|
||||
|
||||
/**
|
||||
* 地点
|
||||
*/
|
||||
private String place;
|
||||
|
||||
/**
|
||||
* 时间
|
||||
*/
|
||||
private Date date;
|
||||
|
||||
/**
|
||||
* 事件
|
||||
*/
|
||||
private String event;
|
||||
|
||||
public SuperiorInfectedIndividual() {
|
||||
}
|
||||
|
||||
public SuperiorInfectedIndividual(String idNumber, String place, Date date, String event) {
|
||||
this.idNumber = idNumber;
|
||||
this.place = place;
|
||||
this.date = date;
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
public String getIdNumber() {
|
||||
return idNumber;
|
||||
}
|
||||
|
||||
public void setIdNumber(String idNumber) {
|
||||
this.idNumber = idNumber;
|
||||
}
|
||||
|
||||
public String getPlace() {
|
||||
return place;
|
||||
}
|
||||
|
||||
public void setPlace(String place) {
|
||||
this.place = place;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public String getEvent() {
|
||||
return event;
|
||||
}
|
||||
|
||||
public void setEvent(String event) {
|
||||
this.event = event;
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package com.example.survey.entity.inner;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
* 体温历史
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TempHistory {
|
||||
|
||||
/**
|
||||
* 检测时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd:HH:mm:ss")
|
||||
private Date time;
|
||||
|
||||
/**
|
||||
* 体温
|
||||
*/
|
||||
private String data;
|
||||
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
package com.example.survey.entity.inner;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TravelHistory {
|
||||
/**
|
||||
* 起始时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date beginTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
* 开始地点
|
||||
*/
|
||||
private Location startLocation;
|
||||
|
||||
/**
|
||||
* 结束地点
|
||||
*/
|
||||
private Location endLocation;
|
||||
|
||||
/**
|
||||
* 事件
|
||||
*/
|
||||
private String detail;
|
||||
}
|
42
src/main/java/com/example/survey/enumeration/OpTypeEnum.java
Normal file
42
src/main/java/com/example/survey/enumeration/OpTypeEnum.java
Normal file
@ -0,0 +1,42 @@
|
||||
package com.example.survey.enumeration;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
public enum OpTypeEnum {
|
||||
/**
|
||||
* 提交操作
|
||||
*/
|
||||
SUBMIT("提交"),
|
||||
/**
|
||||
* 修改操作
|
||||
*/
|
||||
MODIFY("修改"),
|
||||
/**
|
||||
* 删除操作
|
||||
*/
|
||||
DELETE("删除"),
|
||||
/**
|
||||
* 恢复操作
|
||||
*/
|
||||
RECOVERY("恢复"),
|
||||
/**
|
||||
* 审核操作
|
||||
*/
|
||||
REVIEW("审核"),
|
||||
/**
|
||||
* 覆盖
|
||||
*/
|
||||
COVER("覆盖"),
|
||||
;
|
||||
|
||||
private final String value;
|
||||
|
||||
OpTypeEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.example.survey.enumeration;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
public enum ProjectStateEnum {
|
||||
/**
|
||||
* 进行中状态
|
||||
*/
|
||||
IN_PROGRESS("进行中"),
|
||||
/**
|
||||
* 已完成状态
|
||||
*/
|
||||
FINISHED("已完成"),
|
||||
/**
|
||||
* 已作废状态
|
||||
*/
|
||||
INVALID("已作废"),
|
||||
;
|
||||
|
||||
|
||||
private final String value;
|
||||
|
||||
ProjectStateEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.example.survey.enumeration;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
* 调查记录状态枚举
|
||||
*/
|
||||
|
||||
public enum RecordStateEnum {
|
||||
/**
|
||||
* 已审核状态
|
||||
*/
|
||||
REVIEWED("已审核"),
|
||||
/**
|
||||
* 待审核状态
|
||||
*/
|
||||
UNDER_REVIEW("待审核"),
|
||||
/**
|
||||
* 未通过状态
|
||||
*/
|
||||
NOT_PASS("未通过"),
|
||||
/**
|
||||
* 已删除状态
|
||||
*/
|
||||
DELETED("已删除"),
|
||||
/**
|
||||
* 已归档状态
|
||||
*/
|
||||
FILED("已归档")
|
||||
;
|
||||
|
||||
|
||||
private final String value;
|
||||
|
||||
RecordStateEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
@ -11,7 +11,13 @@ public enum RespondentStateEnum {
|
||||
/**
|
||||
* 未调查状态
|
||||
*/
|
||||
NOT_INVESTIGATED("未调查");
|
||||
NOT_INVESTIGATED("未调查"),
|
||||
/**
|
||||
* 已归档
|
||||
*/
|
||||
FILED("已归档"),
|
||||
|
||||
;
|
||||
|
||||
|
||||
private final String value;
|
||||
|
74
src/main/java/com/example/survey/enumeration/ResultEnum.java
Normal file
74
src/main/java/com/example/survey/enumeration/ResultEnum.java
Normal file
@ -0,0 +1,74 @@
|
||||
package com.example.survey.enumeration;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
public enum ResultEnum {
|
||||
/**
|
||||
* 请求成功
|
||||
*/
|
||||
SUCCESS(0, "请求成功!"),
|
||||
|
||||
|
||||
NO_TOKEN(100, "请先登录!"),
|
||||
INSUFFICIENT_PRIVILEGE(101, "非法token或权限不够!"),
|
||||
NOT_EXIST_AUTHORITY(102, "权限不存在!"),
|
||||
|
||||
/**
|
||||
* 用户模块
|
||||
*/
|
||||
WRONG_PASSWORD(200, "密码错误!"),
|
||||
NOT_EXIST_USER(201, "用户不存在!"),
|
||||
ALREADY_EXIST_USER(202, "用户已存在!"),
|
||||
|
||||
/**
|
||||
* 角色模块
|
||||
*/
|
||||
NOT_EXIST_ROLE(300, "角色不存在!"),
|
||||
ALREADY_EXIST_ROLE(301, "角色已存在!"),
|
||||
|
||||
|
||||
/**
|
||||
* 调查对象模块
|
||||
*/
|
||||
NOT_EXIST_RESPONDENT(400, "调查对象不存在!"),
|
||||
ALREADY_EXIST_RESPONDENT(401, "调查对象已存在!"),
|
||||
|
||||
|
||||
/**
|
||||
* 调查记录模块
|
||||
*/
|
||||
NOT_EXIST_RECORD(500, "调查记录不存在!"),
|
||||
|
||||
|
||||
/**
|
||||
* 调查记录模块
|
||||
*/
|
||||
NOT_EXIST_PROJECT(600, "项目不存在!"),
|
||||
ALREADY_EXIST_PROJECT(601, "项目已存在!"),
|
||||
NOT_EXIST_PROJECT_STATE(602, "项目状态不存在!"),
|
||||
|
||||
/**
|
||||
* 元数据模块
|
||||
*/
|
||||
NOT_EXIST_METADATA(700,"元数据不存在!"),
|
||||
ALREADY_EXIST_METADATA(601,"元数据已存在!"),
|
||||
;
|
||||
|
||||
|
||||
private final int code;
|
||||
private final String msg;
|
||||
|
||||
ResultEnum(int code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
}
|
@ -1,10 +1,17 @@
|
||||
package com.example.survey.exception;
|
||||
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Getter
|
||||
public class AuthException extends RuntimeException{
|
||||
public AuthException(String message) {
|
||||
super(message);
|
||||
private final ResultEnum resultEnum;
|
||||
|
||||
public AuthException(ResultEnum resultEnum) {
|
||||
super(resultEnum.getMsg());
|
||||
this.resultEnum = resultEnum;
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,17 @@
|
||||
package com.example.survey.exception;
|
||||
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
public class DepartmentException extends RuntimeException{
|
||||
public DepartmentException(String message) {
|
||||
super(message);
|
||||
@Getter
|
||||
public class DepartmentException extends RuntimeException {
|
||||
private final ResultEnum resultEnum;
|
||||
|
||||
public DepartmentException(ResultEnum resultEnum) {
|
||||
super(resultEnum.getMsg());
|
||||
this.resultEnum = resultEnum;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
package com.example.survey.exception;
|
||||
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Getter
|
||||
public class MetaDataException extends RuntimeException {
|
||||
private final ResultEnum resultEnum;
|
||||
|
||||
public MetaDataException(ResultEnum resultEnum) {
|
||||
super(resultEnum.getMsg());
|
||||
this.resultEnum = resultEnum;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.example.survey.exception;
|
||||
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Getter
|
||||
public class ProjectException extends RuntimeException{
|
||||
private final ResultEnum resultEnum;
|
||||
|
||||
public ProjectException(ResultEnum resultEnum) {
|
||||
super(resultEnum.getMsg());
|
||||
this.resultEnum = resultEnum;
|
||||
}
|
||||
}
|
@ -1,11 +1,17 @@
|
||||
package com.example.survey.exception;
|
||||
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Getter
|
||||
public class RecordException extends RuntimeException{
|
||||
private final ResultEnum resultEnum;
|
||||
|
||||
public RecordException(String message) {
|
||||
super(message);
|
||||
public RecordException(ResultEnum resultEnum) {
|
||||
super(resultEnum.getMsg());
|
||||
this.resultEnum = resultEnum;
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,17 @@
|
||||
package com.example.survey.exception;
|
||||
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Getter
|
||||
public class RespondentException extends RuntimeException{
|
||||
public RespondentException(String message) {
|
||||
super(message);
|
||||
private final ResultEnum resultEnum;
|
||||
|
||||
public RespondentException(ResultEnum resultEnum) {
|
||||
super(resultEnum.getMsg());
|
||||
this.resultEnum = resultEnum;
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,17 @@
|
||||
package com.example.survey.exception;
|
||||
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
public class RoleException extends RuntimeException{
|
||||
public RoleException(String msg){
|
||||
super(msg);
|
||||
@Getter
|
||||
public class RoleException extends RuntimeException {
|
||||
private final ResultEnum resultEnum;
|
||||
|
||||
public RoleException(ResultEnum resultEnum) {
|
||||
super(resultEnum.getMsg());
|
||||
this.resultEnum = resultEnum;
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,17 @@
|
||||
package com.example.survey.exception;
|
||||
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
public class UserException extends RuntimeException{
|
||||
public UserException(String msg){
|
||||
super(msg);
|
||||
@Getter
|
||||
public class UserException extends RuntimeException {
|
||||
private final ResultEnum resultEnum;
|
||||
|
||||
public UserException(ResultEnum resultEnum) {
|
||||
super(resultEnum.getMsg());
|
||||
this.resultEnum = resultEnum;
|
||||
}
|
||||
}
|
||||
|
@ -1,69 +0,0 @@
|
||||
package com.example.survey.service;
|
||||
|
||||
import com.example.survey.entity.InvestigationRecord;
|
||||
import com.example.survey.vo.InvestigationRecordVo;
|
||||
import com.example.survey.vo.ReviewVo;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
public interface InvestigationRecordService {
|
||||
|
||||
/**
|
||||
* 创建新的调查记录
|
||||
*
|
||||
* @param vo 调查记录信息
|
||||
* @return 是否创建成功
|
||||
*/
|
||||
boolean addInvestigationRecord(InvestigationRecordVo vo);
|
||||
|
||||
/**
|
||||
* 根据筛选条件查询调查记录
|
||||
*
|
||||
* @param userPhone 用户电话号码
|
||||
* @param currentPage 当前页数
|
||||
* @param pageSize 页大小
|
||||
* @param state 状态
|
||||
* @param idNumber 调查对象身份证号
|
||||
* @param version 版本
|
||||
* @param questionnaireNumber 问卷编号
|
||||
* @param diseased 是否患病
|
||||
* @return 调查记录列表
|
||||
*/
|
||||
List<InvestigationRecord> listUnderReviewRecordLimit(String userPhone, int currentPage, int pageSize, String state, String idNumber, String version, String questionnaireNumber, Boolean diseased);
|
||||
|
||||
/**
|
||||
* 根据流调人员电话号码查询待审核记录数量
|
||||
*
|
||||
* @param userPhone 用户电话号码
|
||||
* @return 记录数量
|
||||
*/
|
||||
long countUnderReviewRecord(String userPhone);
|
||||
|
||||
/**
|
||||
* 提交修改后的调查记录,等待审核
|
||||
*
|
||||
* @param vo 调查记录Vo
|
||||
* @return 修改是否提交成功
|
||||
*/
|
||||
void changeInvestigationRecord(InvestigationRecordVo vo);
|
||||
|
||||
/**
|
||||
* 审核待调查记录
|
||||
*
|
||||
* @param reviewVo 审核信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean reviewRecord(ReviewVo reviewVo);
|
||||
|
||||
/**
|
||||
* 导出为word
|
||||
*
|
||||
* @param idNumber 调查对象身份证号
|
||||
* @param response 响应
|
||||
*/
|
||||
void export2Word(String idNumber, HttpServletResponse response);
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.example.survey.service;
|
||||
|
||||
import com.example.survey.dto.metaData.CreateMetaDataDTO;
|
||||
import com.example.survey.dto.metaData.DeleteMetaDataDTO;
|
||||
import com.example.survey.dto.metaData.ModifyMetaDataDTO;
|
||||
import com.example.survey.entity.MetaData;
|
||||
import com.example.survey.vo.MetaDataVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
public interface MetaDataService {
|
||||
/**
|
||||
* 创建元数据
|
||||
*
|
||||
* @param createMetaDataDTO 元数据信息
|
||||
*/
|
||||
void addMetaData(CreateMetaDataDTO createMetaDataDTO);
|
||||
|
||||
/**
|
||||
* 根据筛选条件模糊查询元数据
|
||||
* @param name 元数据名
|
||||
* @param currentPage 当前页数
|
||||
* @param pageSize 页大小
|
||||
* @return 元数据
|
||||
*/
|
||||
List<MetaDataVO> listMetaDataLimit(String name, int currentPage, int pageSize);
|
||||
|
||||
/**
|
||||
* 根据元数据名查询数量
|
||||
*
|
||||
* @param name 元数据名
|
||||
* @return 数量
|
||||
*/
|
||||
long countMetaData(String name);
|
||||
|
||||
/**
|
||||
* 获取所有元数据名字的列表
|
||||
* @return 名字的列表
|
||||
*/
|
||||
List<String> getNameList();
|
||||
|
||||
/**
|
||||
* 修改元数据信息
|
||||
*
|
||||
* @param modifyMetaDataDTO 修改信息
|
||||
*/
|
||||
void modifyMetaData(ModifyMetaDataDTO modifyMetaDataDTO);
|
||||
|
||||
/**
|
||||
* @param name 名字
|
||||
* @return 元数据
|
||||
*/
|
||||
MetaData getMetaData(String name);
|
||||
|
||||
/**
|
||||
* 删除元数据
|
||||
*
|
||||
* @param deleteMetaDataDTO 删除信息
|
||||
*/
|
||||
void deleteMetaData(DeleteMetaDataDTO deleteMetaDataDTO);
|
||||
}
|
72
src/main/java/com/example/survey/service/ProjectService.java
Normal file
72
src/main/java/com/example/survey/service/ProjectService.java
Normal file
@ -0,0 +1,72 @@
|
||||
package com.example.survey.service;
|
||||
|
||||
import com.example.survey.dto.project.CreateProjectDTO;
|
||||
import com.example.survey.dto.project.ModifyProjectDTO;
|
||||
import com.example.survey.dto.project.ModifyStateDTO;
|
||||
import com.example.survey.vo.ProjectVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
public interface ProjectService {
|
||||
|
||||
|
||||
/**
|
||||
* 创建新项目
|
||||
*
|
||||
* @param createProjectDTO 创建项目信息
|
||||
*/
|
||||
void createProject(CreateProjectDTO createProjectDTO);
|
||||
|
||||
|
||||
/**
|
||||
* 根据筛选条件分页查询项目
|
||||
*
|
||||
* @param name 项目名
|
||||
* @param currentPage 当前页数
|
||||
* @param pageSize 页大小
|
||||
* @return 项目vo
|
||||
*/
|
||||
List<ProjectVO> listProjectLimit(String name, int currentPage, int pageSize);
|
||||
|
||||
/**
|
||||
* 根据项目名查询调查对象数量
|
||||
*
|
||||
* @param name 项目名
|
||||
* @return 调查对象数量
|
||||
*/
|
||||
long countRespondent(String name);
|
||||
|
||||
/**
|
||||
* 根据项目名与调查对象状态查询调查对象数量
|
||||
*
|
||||
* @param name 项目名
|
||||
* @param respondentState 调查对象状态
|
||||
* @return 调查对象数量
|
||||
*/
|
||||
long countRespondent(String name, String respondentState);
|
||||
|
||||
/**
|
||||
* 修改项目状态
|
||||
*
|
||||
* @param modifyStateDTO 修改信息
|
||||
*/
|
||||
void modifyProjectState(ModifyStateDTO modifyStateDTO);
|
||||
|
||||
/**
|
||||
* 修改项目数据
|
||||
*
|
||||
* @param modifyProjectDTO 修改信息
|
||||
*/
|
||||
void modifyProject(ModifyProjectDTO modifyProjectDTO);
|
||||
|
||||
/**
|
||||
* 根据项目吗查询数量
|
||||
*
|
||||
* @param name 项目名
|
||||
* @return 数量
|
||||
*/
|
||||
long countProject(String name);
|
||||
}
|
84
src/main/java/com/example/survey/service/RecordService.java
Normal file
84
src/main/java/com/example/survey/service/RecordService.java
Normal file
@ -0,0 +1,84 @@
|
||||
package com.example.survey.service;
|
||||
|
||||
import com.example.survey.dto.record.ModifyRecordDTO;
|
||||
import com.example.survey.dto.record.ReviewRecordDTO;
|
||||
import com.example.survey.dto.record.SubmitRecordDTO;
|
||||
import com.example.survey.vo.RecordVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
public interface RecordService {
|
||||
|
||||
/**
|
||||
* 根据筛选条件查询流调记录数量
|
||||
*
|
||||
* @param userPhone 用户电话号码
|
||||
* @param projectName 项目名
|
||||
* @return 符合筛选条件的调查记录数量
|
||||
*/
|
||||
long countRecord(String userPhone, String projectName);
|
||||
|
||||
|
||||
/**
|
||||
* 审核流调记录
|
||||
*
|
||||
* @param reviewRecordDTO 审核信息
|
||||
*/
|
||||
void reviewRecord(ReviewRecordDTO reviewRecordDTO);
|
||||
|
||||
/**
|
||||
* 修改已审核的流调记录
|
||||
*
|
||||
* @param modifyRecordDTO 修改信息
|
||||
*/
|
||||
void modifyRecord(ModifyRecordDTO modifyRecordDTO);
|
||||
|
||||
/**
|
||||
* 创建流调记录
|
||||
*
|
||||
* @param submitRecordDTO 流调记录信息
|
||||
*/
|
||||
void createRecord(SubmitRecordDTO submitRecordDTO);
|
||||
|
||||
/**
|
||||
* 根据筛选条件查询流调记录数量
|
||||
*
|
||||
* @param idNumber 调查对象身份证号
|
||||
* @param userPhone 分配的人员电话号码
|
||||
* @param projectName 项目名
|
||||
* @param state 流调记录状态
|
||||
* @param version 流调记录版本
|
||||
* @param questionnaireNumber 问卷编号
|
||||
* @return 流调记录数量
|
||||
*/
|
||||
long countRecord(String idNumber, String userPhone, String projectName, String state, String version, String questionnaireNumber);
|
||||
|
||||
/**
|
||||
* 根据筛选条件查询流调记录
|
||||
*
|
||||
* @param idNumber 调查对象身份证号
|
||||
* @param userPhone 分配的人员电话号码
|
||||
* @param projectName 项目名
|
||||
* @param state 流调记录状态
|
||||
* @param version 流调记录版本
|
||||
* @param questionnaireNumber 问卷编号
|
||||
* @param currentPage 当前页数,从0开始
|
||||
* @param pageSize 页大小
|
||||
* @return 流调记录VO
|
||||
*/
|
||||
List<RecordVO> listRecordLimit(String idNumber, String userPhone, String projectName, String state, String version, String questionnaireNumber, int currentPage, int pageSize);
|
||||
|
||||
/**
|
||||
* 根据筛选条件查询流调记录的values
|
||||
*
|
||||
* @param projectName 项目名
|
||||
* @param idNumber 调查对象身份证号
|
||||
* @param version 版本号
|
||||
* @return 流调记录的values
|
||||
*/
|
||||
Map<String,Object> getRecordValues(String projectName, String idNumber, String version);
|
||||
}
|
@ -1,9 +1,7 @@
|
||||
package com.example.survey.service;
|
||||
|
||||
import com.example.survey.entity.Respondent;
|
||||
import com.example.survey.dto.RespondentDto;
|
||||
import com.example.survey.entity.inner.AdministrativeArea;
|
||||
import com.example.survey.vo.CreateRespondentVo;
|
||||
import com.example.survey.dto.respondent.*;
|
||||
import com.example.survey.vo.RespondentVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -14,30 +12,63 @@ public interface RespondentService {
|
||||
/**
|
||||
* 创建待调查对象
|
||||
*
|
||||
* @param createRespondentVo 待调查对象信息
|
||||
* @param createRespondentDTO 待调查对象信息
|
||||
* @return 是否创建成功
|
||||
*/
|
||||
boolean addRespondent(CreateRespondentVo createRespondentVo);
|
||||
void createRespondent(CreateRespondentDTO createRespondentDTO);
|
||||
|
||||
/**
|
||||
* 根据流调人员电话号码分页查询待调查对象数据
|
||||
*
|
||||
* @param userPhone 分配的人员电话号码
|
||||
* @param state 状态
|
||||
* @param administrativeArea 行政区划
|
||||
* @param currentPage 当前页数
|
||||
* @param pageSize 页大小
|
||||
* @param userPhone 分配的人员电话号码
|
||||
* @param state 状态
|
||||
* @param idNumber 身份证号
|
||||
* @param name 调查对象姓名
|
||||
* @param phone 调查对象电话
|
||||
* @param province 省份
|
||||
* @param city 城市
|
||||
* @param county 区县
|
||||
* @param projectName 项目名
|
||||
* @param currentPage 当前页数
|
||||
* @param pageSize 页大小
|
||||
* @return 页数据
|
||||
*/
|
||||
List<RespondentDto> listRespondentLimit(String userPhone, String state, AdministrativeArea administrativeArea, int currentPage, int pageSize);
|
||||
List<RespondentVO> listRespondentLimit(String userPhone, String state, String idNumber, String name, String phone, String province, String city, String county, String projectName, int currentPage, int pageSize);
|
||||
|
||||
/**
|
||||
* 根据筛选条件查询调查对象数量
|
||||
*
|
||||
* @param userPhone 分配的人员电话号码
|
||||
* @param state 状态
|
||||
* @param administrativeArea 行政区划
|
||||
* @param userPhone 分配的人员电话号码
|
||||
* @param state 状态
|
||||
* @param idNumber 身份证号
|
||||
* @param name 调查对象姓名
|
||||
* @param phone 调查对象电话
|
||||
* @param province 省份
|
||||
* @param city 城市
|
||||
* @param county 区县
|
||||
* @param projectName 项目名
|
||||
* @return 数量
|
||||
*/
|
||||
long countRespondent(String userPhone, String state, AdministrativeArea administrativeArea);
|
||||
long countRespondent(String userPhone, String state, String idNumber, String name, String phone, String province, String city, String county, String projectName);
|
||||
|
||||
/**
|
||||
* 修改调查对象信息
|
||||
*
|
||||
* @param modifyRespondentDTO 修改信息
|
||||
*/
|
||||
void modifyRespondent(ModifyRespondentDTO modifyRespondentDTO);
|
||||
|
||||
/**
|
||||
* 分配人员
|
||||
*
|
||||
* @param modifyRespondentUserDTO 绑定用户信息
|
||||
*/
|
||||
void modifyUser(ModifyRespondentUserDTO modifyRespondentUserDTO);
|
||||
|
||||
/**
|
||||
* 删除调查对象
|
||||
*
|
||||
* @param deleteRespondentDTO 删除信息
|
||||
*/
|
||||
void deleteRespondent(DeleteRespondentDTO deleteRespondentDTO);
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
package com.example.survey.service;
|
||||
|
||||
import com.example.survey.vo.CreateRoleVo;
|
||||
import com.example.survey.vo.ModifyRoleVo;
|
||||
import com.example.survey.dto.role.CreateRoleDTO;
|
||||
import com.example.survey.dto.role.DeleteRoleDTO;
|
||||
import com.example.survey.dto.role.ModifyRoleDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -13,33 +14,40 @@ public interface RoleService {
|
||||
/**
|
||||
* 创建角色
|
||||
*
|
||||
* @param createRoleVo 角色信息
|
||||
* @param createRoleDTO 角色信息
|
||||
* @return 是否创建成功
|
||||
*/
|
||||
boolean addRole(CreateRoleVo createRoleVo);
|
||||
void addRole(CreateRoleDTO createRoleDTO);
|
||||
|
||||
/**
|
||||
* 根据权限名分页查询权限
|
||||
*
|
||||
* @param roleName 角色名 模糊匹配
|
||||
* @param name 角色名 模糊匹配
|
||||
* @param currentPage 当前页数
|
||||
* @param pageSize 页大小
|
||||
* @return 查询结果
|
||||
*/
|
||||
List<CreateRoleVo> getRole(String roleName, int currentPage, int pageSize);
|
||||
List<CreateRoleDTO> listRoleLimit(String name, int currentPage, int pageSize);
|
||||
|
||||
/**
|
||||
* 删除角色
|
||||
*
|
||||
* @param roleName 角色名
|
||||
* @return 是否删除成功
|
||||
* @param deleteRoleDTO 删除信息
|
||||
*/
|
||||
void deleteRole(String roleName);
|
||||
void deleteRole(DeleteRoleDTO deleteRoleDTO);
|
||||
|
||||
/**
|
||||
* 修改角色权限
|
||||
*
|
||||
* @param modifyRoleVo 修改后角色信息
|
||||
* @param modifyRoleDTO 修改信息
|
||||
*/
|
||||
void modifyRole(ModifyRoleVo modifyRoleVo);
|
||||
void modifyRole(ModifyRoleDTO modifyRoleDTO);
|
||||
|
||||
/**
|
||||
* 根绝角色名模糊查询角色数量
|
||||
*
|
||||
* @param name 角色名 模糊匹配
|
||||
* @return 角色数量
|
||||
*/
|
||||
long countRole(String name);
|
||||
}
|
||||
|
@ -1,11 +1,8 @@
|
||||
package com.example.survey.service;
|
||||
|
||||
import com.example.survey.dto.LoginDto;
|
||||
import com.example.survey.dto.UserDto;
|
||||
import com.example.survey.vo.LoginVo;
|
||||
import com.example.survey.vo.CreateUserVo;
|
||||
import com.example.survey.vo.UserInfoVo;
|
||||
import com.example.survey.vo.UserRoleVo;
|
||||
import com.example.survey.dto.user.*;
|
||||
import com.example.survey.vo.LoginVO;
|
||||
import com.example.survey.vo.UserVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -16,25 +13,25 @@ public interface UserService {
|
||||
/**
|
||||
* 根据登录信息判断是否登录
|
||||
*
|
||||
* @param loginVo 登录信息
|
||||
* @param loginDTO 登录信息
|
||||
* @return 用户信息 若登录失败则返回null
|
||||
*/
|
||||
LoginDto matchAuth(LoginVo loginVo);
|
||||
LoginVO matchAuth(LoginDTO loginDTO);
|
||||
|
||||
/**
|
||||
* 注册用户
|
||||
*
|
||||
* @param createUserVo 注册信息
|
||||
* @param createUserDTO 注册信息
|
||||
* @return 是否注册成功
|
||||
*/
|
||||
boolean addUser(CreateUserVo createUserVo);
|
||||
void addUser(CreateUserDTO createUserDTO);
|
||||
|
||||
/**
|
||||
* 修改用户权限
|
||||
*
|
||||
* @param userRoleVo 新权限信息
|
||||
* @param modifyUserRoleDTO 新权限信息
|
||||
*/
|
||||
void modifyRole(UserRoleVo userRoleVo);
|
||||
void modifyRole(ModifyUserRoleDTO modifyUserRoleDTO);
|
||||
|
||||
/**
|
||||
* 根据筛选条件分页查询用户
|
||||
@ -45,27 +42,35 @@ public interface UserService {
|
||||
* @param pageSize 页大小
|
||||
* @return 用户信息dto
|
||||
*/
|
||||
List<UserDto> listUserLimit(String username, String phoneNumber, int currentPage, int pageSize);
|
||||
List<UserVO> listUserLimit(String username, String phoneNumber, int currentPage, int pageSize);
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*
|
||||
* @param phoneNumber 电话号码
|
||||
* @return 是否删除成功
|
||||
* @param deleteUserDTO 删除信息
|
||||
*/
|
||||
boolean deleteUser(String phoneNumber);
|
||||
void deleteUser(DeleteUserDTO deleteUserDTO);
|
||||
|
||||
/**
|
||||
* 修改用户信息
|
||||
*
|
||||
* @param userInfoVo 用户信息
|
||||
* @param modifyUserInfoDTO 用户信息
|
||||
*/
|
||||
void modifyUserInfo(UserInfoVo userInfoVo);
|
||||
void modifyUserInfo(ModifyUserInfoDTO modifyUserInfoDTO);
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
*
|
||||
* @param phoneNumber 电话号码
|
||||
* @param resetPwdDTO 用户信息
|
||||
*/
|
||||
void resetPwd(String phoneNumber);
|
||||
void resetPwd(ResetPwdDTO resetPwdDTO);
|
||||
|
||||
/**
|
||||
* 根据用户名与电话号码查询用户数量
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param phone 电话号码
|
||||
* @return 用户数量
|
||||
*/
|
||||
long countUser(String username, String phone);
|
||||
}
|
||||
|
@ -1,163 +0,0 @@
|
||||
package com.example.survey.service.impl;
|
||||
|
||||
import com.example.survey.dao.InvestigationRecordDao;
|
||||
import com.example.survey.dao.RespondentDao;
|
||||
import com.example.survey.dao.UserDao;
|
||||
import com.example.survey.entity.InvestigationRecord;
|
||||
import com.example.survey.entity.inner.OperationInformation;
|
||||
import com.example.survey.exception.RecordException;
|
||||
import com.example.survey.exception.RespondentException;
|
||||
import com.example.survey.exception.UserException;
|
||||
import com.example.survey.service.InvestigationRecordService;
|
||||
import com.example.survey.util.WordUtil;
|
||||
import com.example.survey.vo.InvestigationRecordVo;
|
||||
import com.example.survey.vo.ReviewVo;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Log4j2
|
||||
@Service
|
||||
public class InvestigationRecordServiceImpl implements InvestigationRecordService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private InvestigationRecordDao investigationRecordDao;
|
||||
|
||||
@Autowired
|
||||
private RespondentDao respondentDao;
|
||||
|
||||
@Autowired
|
||||
private UserDao userDao;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean addInvestigationRecord(InvestigationRecordVo vo) {
|
||||
//如果不存在对应电话号码的调查对象
|
||||
if (!respondentDao.existRespondent(vo.getIdNumber())) {
|
||||
log.error("调查对象不存在");
|
||||
throw new RespondentException("调查对象不存在");
|
||||
}
|
||||
//如果已经存在待审核或已审核记录则失败
|
||||
if (investigationRecordDao.existInvestigationRecord(vo.getIdNumber(), InvestigationRecord.UNDER_REVIEW, InvestigationRecord.REVIEWED)) {
|
||||
|
||||
log.error("数据库已存在对应调查对象的待审核或已审核记录");
|
||||
throw new RecordException("数据库已存在对应调查对象的待审核或已审核记录");
|
||||
}
|
||||
//如果不存在对应电话号码的流调人员
|
||||
if(!userDao.existUser(vo.getUserPhone())){
|
||||
log.error("用户不存在");
|
||||
throw new UserException("用户不存在");
|
||||
}
|
||||
|
||||
InvestigationRecord record = new InvestigationRecord(vo);
|
||||
//生成版本信息
|
||||
record.setState(InvestigationRecord.UNDER_REVIEW);
|
||||
record.setVersion(vo.getUserPhone() + new Date().toString());
|
||||
List<OperationInformation> opList = new ArrayList<>();
|
||||
opList.add(OperationInformation.submitOp(vo.getUserPhone(), vo.getMsg()));
|
||||
record.setOperationInformationList(opList);
|
||||
|
||||
|
||||
//TODO 插入消息队列
|
||||
|
||||
return investigationRecordDao.insertInvestigationRecord(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InvestigationRecord> listUnderReviewRecordLimit(String userPhone, int currentPage, int pageSize, String state, String idNumber, String version, String questionnaireNumber, Boolean diseased) {
|
||||
//TODO 从消息队列进行筛选
|
||||
|
||||
return investigationRecordDao.listInvestigationRecordLimit(userPhone, pageSize * currentPage, pageSize, state, idNumber, version, questionnaireNumber, diseased);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long countUnderReviewRecord(String userPhone) {
|
||||
//TODO 从消息队列获取调查记录数量
|
||||
|
||||
return investigationRecordDao.countInvestigationRecordByUserPhone(userPhone, InvestigationRecord.UNDER_REVIEW);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void changeInvestigationRecord(InvestigationRecordVo vo) {
|
||||
//创建新记录
|
||||
InvestigationRecord oldRecord = investigationRecordDao.selectInvestigationRecord(vo.getIdNumber(), InvestigationRecord.REVIEWED);
|
||||
if (oldRecord == null) {
|
||||
oldRecord = investigationRecordDao.selectInvestigationRecord(vo.getIdNumber(), InvestigationRecord.NOT_PASS);
|
||||
}
|
||||
|
||||
if(oldRecord == null){
|
||||
log.error("调查记录不存在");
|
||||
throw new RecordException("调查记录不存在");
|
||||
}
|
||||
InvestigationRecord newRecord = new InvestigationRecord(vo);
|
||||
|
||||
//生成版本信息
|
||||
newRecord.setState(InvestigationRecord.UNDER_REVIEW);
|
||||
newRecord.setVersion(vo.getUserPhone() + new Date().toString());
|
||||
//生成操作记录
|
||||
List<OperationInformation> opList = oldRecord.getOperationInformationList();
|
||||
opList.add(OperationInformation.submitOp(vo.getUserPhone(), vo.getMsg()));
|
||||
newRecord.setOperationInformationList(opList);
|
||||
|
||||
//存入新纪录
|
||||
//原纪录标记为已归档
|
||||
investigationRecordDao.updateRecordState(oldRecord.getIdNumber(), InvestigationRecord.REVIEWED, InvestigationRecord.OUT_OF_DATE);
|
||||
investigationRecordDao.insertInvestigationRecord(newRecord);
|
||||
|
||||
//TODO 将修改请求加入消息队列
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean reviewRecord(ReviewVo reviewVo) {
|
||||
|
||||
//如果待审核调查记录表不存在
|
||||
if (!investigationRecordDao.existInvestigationRecord(reviewVo.getIdNumber(), InvestigationRecord.UNDER_REVIEW)) {
|
||||
log.error("未审核记录不存在");
|
||||
throw new RecordException("未审核记录不存在");
|
||||
}
|
||||
//如果审核人不存在
|
||||
if(!userDao.existUser(reviewVo.getReviewerPhone())){
|
||||
log.error("审核人不存在");
|
||||
throw new UserException("审核人不存在");
|
||||
}
|
||||
|
||||
InvestigationRecord record = investigationRecordDao.selectInvestigationRecord(reviewVo.getIdNumber(), InvestigationRecord.UNDER_REVIEW);
|
||||
|
||||
//审核结果与版本信息
|
||||
record.setState(reviewVo.isPass() ? InvestigationRecord.REVIEWED : InvestigationRecord.NOT_PASS);
|
||||
record.setVersion(reviewVo.getReviewerPhone() + new Date().toString());
|
||||
|
||||
//生成操作记录
|
||||
List<OperationInformation> opList = record.getOperationInformationList();
|
||||
opList.add(OperationInformation.reviewOp(reviewVo.getReviewerPhone(), reviewVo.getMsg(), reviewVo.isPass() ? "审核通过" : "审核不通过"));
|
||||
record.setOperationInformationList(opList);
|
||||
|
||||
//更新数据库记录
|
||||
investigationRecordDao.reviewRecord(record);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void export2Word(String idNumber, HttpServletResponse response) {
|
||||
InvestigationRecord record = investigationRecordDao.selectInvestigationRecord(idNumber, InvestigationRecord.REVIEWED);
|
||||
try {
|
||||
WordUtil.writeDocx(record, response);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package com.example.survey.service.impl;
|
||||
|
||||
import com.example.survey.dao.MetaDataDao;
|
||||
import com.example.survey.dto.metaData.CreateMetaDataDTO;
|
||||
import com.example.survey.dto.metaData.DeleteMetaDataDTO;
|
||||
import com.example.survey.dto.metaData.ModifyMetaDataDTO;
|
||||
import com.example.survey.entity.MetaData;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.exception.MetaDataException;
|
||||
import com.example.survey.service.MetaDataService;
|
||||
import com.example.survey.vo.MetaDataVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Service
|
||||
public class MetaDataServiceImpl implements MetaDataService {
|
||||
|
||||
@Autowired
|
||||
MetaDataDao metaDataDao;
|
||||
|
||||
@Override
|
||||
public void addMetaData(CreateMetaDataDTO createMetaDataDTO) {
|
||||
if (metaDataDao.existMetaData(createMetaDataDTO.getName())) {
|
||||
throw new MetaDataException(ResultEnum.ALREADY_EXIST_METADATA);
|
||||
}
|
||||
MetaData metaData = new MetaData();
|
||||
metaData.setName(createMetaDataDTO.getName());
|
||||
metaData.setForm(createMetaDataDTO.getForm());
|
||||
metaData.setFieldToNameList(createMetaDataDTO.getFieldToNameList());
|
||||
metaData.setConfig(createMetaDataDTO.getConfig());
|
||||
metaDataDao.saveMetaData(metaData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MetaDataVO> listMetaDataLimit(String name, int currentPage, int pageSize) {
|
||||
List<MetaData> metaDataList = metaDataDao.listMetaDataLimit(name, currentPage * pageSize, pageSize);
|
||||
if (metaDataList == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return metaDataList.stream()
|
||||
.map(metaData -> {
|
||||
MetaDataVO metaDataVO = new MetaDataVO();
|
||||
metaDataVO.setName(metaData.getName());
|
||||
metaDataVO.setForm(metaData.getForm());
|
||||
metaDataVO.setFieldToNameList(metaData.getFieldToNameList());
|
||||
metaDataVO.setConfig(metaData.getConfig());
|
||||
return metaDataVO;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countMetaData(String name) {
|
||||
return metaDataDao.countMetaData(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getNameList() {
|
||||
return metaDataDao.selectAllMetaData().stream().map(MetaData::getName).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyMetaData(ModifyMetaDataDTO modifyMetaDataDTO) {
|
||||
if (!metaDataDao.existMetaData(modifyMetaDataDTO.getName())) {
|
||||
throw new MetaDataException(ResultEnum.NOT_EXIST_METADATA);
|
||||
}
|
||||
MetaData metaData = metaDataDao.selectMetaData(modifyMetaDataDTO.getName());
|
||||
metaData.setForm(modifyMetaDataDTO.getForm());
|
||||
metaData.setFieldToNameList(modifyMetaDataDTO.getFieldToNameList());
|
||||
metaData.setConfig(modifyMetaDataDTO.getConfig());
|
||||
metaDataDao.saveMetaData(metaData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaData getMetaData(String name) {
|
||||
if (!metaDataDao.existMetaData(name)) {
|
||||
throw new MetaDataException(ResultEnum.ALREADY_EXIST_METADATA);
|
||||
}
|
||||
return metaDataDao.selectMetaData(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteMetaData(DeleteMetaDataDTO deleteMetaDataDTO) {
|
||||
if (!metaDataDao.existMetaData(deleteMetaDataDTO.getName())) {
|
||||
throw new MetaDataException(ResultEnum.ALREADY_EXIST_METADATA);
|
||||
}
|
||||
metaDataDao.deleteMetaData(deleteMetaDataDTO.getName());
|
||||
}
|
||||
}
|
@ -0,0 +1,139 @@
|
||||
package com.example.survey.service.impl;
|
||||
|
||||
import com.example.survey.dao.MetaDataDao;
|
||||
import com.example.survey.dao.ProjectDao;
|
||||
import com.example.survey.dao.RespondentDao;
|
||||
import com.example.survey.dao.UserDao;
|
||||
import com.example.survey.dto.project.CreateProjectDTO;
|
||||
import com.example.survey.dto.project.ModifyProjectDTO;
|
||||
import com.example.survey.dto.project.ModifyStateDTO;
|
||||
import com.example.survey.entity.MetaData;
|
||||
import com.example.survey.entity.Project;
|
||||
import com.example.survey.entity.User;
|
||||
import com.example.survey.enumeration.ProjectStateEnum;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.exception.MetaDataException;
|
||||
import com.example.survey.exception.ProjectException;
|
||||
import com.example.survey.exception.UserException;
|
||||
import com.example.survey.service.ProjectService;
|
||||
import com.example.survey.vo.ProjectVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Service
|
||||
public class ProjectServiceImpl implements ProjectService {
|
||||
|
||||
@Autowired
|
||||
ProjectDao projectDao;
|
||||
|
||||
@Autowired
|
||||
RespondentDao respondentDao;
|
||||
|
||||
@Autowired
|
||||
MetaDataDao metaDataDao;
|
||||
|
||||
@Autowired
|
||||
UserDao userDao;
|
||||
|
||||
@Override
|
||||
public void createProject(CreateProjectDTO createProjectDTO) {
|
||||
if (!userDao.existUser(createProjectDTO.getUserPhone())) {
|
||||
throw new UserException(ResultEnum.NOT_EXIST_USER);
|
||||
}
|
||||
if (!metaDataDao.existMetaData(createProjectDTO.getMetaDataName())) {
|
||||
throw new MetaDataException(ResultEnum.NOT_EXIST_METADATA);
|
||||
}
|
||||
User user = userDao.selectUser(createProjectDTO.getUserPhone());
|
||||
MetaData metaData = metaDataDao.selectMetaData(createProjectDTO.getMetaDataName());
|
||||
Project project = new Project();
|
||||
project.setName(createProjectDTO.getName());
|
||||
project.setMetaData(metaData);
|
||||
project.setStartTime(createProjectDTO.getStartTime());
|
||||
project.setEndTime(createProjectDTO.getEndTime());
|
||||
project.setDetail(createProjectDTO.getDetail());
|
||||
project.setState(ProjectStateEnum.IN_PROGRESS.getValue());
|
||||
project.setUser(user);
|
||||
projectDao.saveProject(project);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProjectVO> listProjectLimit(String name, int currentPage, int pageSize) {
|
||||
return projectDao.listProjectLimit(name, currentPage * pageSize, pageSize).stream()
|
||||
.map(project -> {
|
||||
ProjectVO projectVO = new ProjectVO();
|
||||
projectVO.setName(project.getName());
|
||||
projectVO.setDetail(project.getDetail());
|
||||
projectVO.setStartTime(project.getStartTime());
|
||||
projectVO.setEndTime(project.getEndTime());
|
||||
if (project.getMetaData() != null) {
|
||||
projectVO.setMetaDataName(project.getMetaData().getName());
|
||||
}
|
||||
projectVO.setState(project.getState());
|
||||
return projectVO;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countRespondent(String name) {
|
||||
if (!projectDao.existProject(name)) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
return projectDao.selectProject(name).getRespondentCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countRespondent(String name, String respondentState) {
|
||||
if (!projectDao.existProject(name)) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
Project project = projectDao.selectProject(name);
|
||||
return project.getNotInvestigatedRespondentCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyProjectState(ModifyStateDTO modifyStateDTO) {
|
||||
if (!projectDao.existProject(modifyStateDTO.getName())) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
Project project = projectDao.selectProject(modifyStateDTO.getName());
|
||||
for (ProjectStateEnum value : ProjectStateEnum.values()) {
|
||||
if (value.getValue().equals(modifyStateDTO.getState())) {
|
||||
project.setState(modifyStateDTO.getState());
|
||||
projectDao.saveProject(project);
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT_STATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyProject(ModifyProjectDTO modifyProjectDTO) {
|
||||
if (!userDao.existUser(modifyProjectDTO.getUserPhone())) {
|
||||
throw new UserException(ResultEnum.NOT_EXIST_USER);
|
||||
}
|
||||
if (!projectDao.existProject(modifyProjectDTO.getName())) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
User user = userDao.selectUser(modifyProjectDTO.getUserPhone());
|
||||
Project project = projectDao.selectProject(modifyProjectDTO.getName());
|
||||
project.setDetail(modifyProjectDTO.getDetail());
|
||||
project.setStartTime(modifyProjectDTO.getStartTime());
|
||||
project.setEndTime(modifyProjectDTO.getEndTime());
|
||||
project.setUser(user);
|
||||
projectDao.saveProject(project);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countProject(String name) {
|
||||
return projectDao.countProject(name);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,274 @@
|
||||
package com.example.survey.service.impl;
|
||||
|
||||
import com.example.survey.dao.ProjectDao;
|
||||
import com.example.survey.dao.RecordDao;
|
||||
import com.example.survey.dao.RespondentDao;
|
||||
import com.example.survey.dao.UserDao;
|
||||
import com.example.survey.dto.record.ModifyRecordDTO;
|
||||
import com.example.survey.dto.record.ReviewRecordDTO;
|
||||
import com.example.survey.dto.record.SubmitRecordDTO;
|
||||
import com.example.survey.entity.Project;
|
||||
import com.example.survey.entity.Record;
|
||||
import com.example.survey.entity.Respondent;
|
||||
import com.example.survey.entity.User;
|
||||
import com.example.survey.entity.inner.Operation;
|
||||
import com.example.survey.enumeration.RecordStateEnum;
|
||||
import com.example.survey.enumeration.RespondentStateEnum;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.exception.ProjectException;
|
||||
import com.example.survey.exception.RecordException;
|
||||
import com.example.survey.exception.RespondentException;
|
||||
import com.example.survey.exception.UserException;
|
||||
import com.example.survey.service.RecordService;
|
||||
import com.example.survey.vo.RecordVO;
|
||||
import com.example.survey.vo.inner.OperationInfo;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Log4j2
|
||||
@Service
|
||||
public class RecordServiceImpl implements RecordService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private RecordDao recordDao;
|
||||
|
||||
@Autowired
|
||||
private RespondentDao respondentDao;
|
||||
|
||||
@Autowired
|
||||
private UserDao userDao;
|
||||
|
||||
@Autowired
|
||||
private ProjectDao projectDao;
|
||||
|
||||
@Override
|
||||
public long countRecord(String userPhone, String projectName) {
|
||||
if (userPhone != null && !userDao.existUser(userPhone)) {
|
||||
throw new UserException(ResultEnum.NOT_EXIST_USER);
|
||||
}
|
||||
if (projectName != null && !projectDao.existProject(projectName)) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
User user = userDao.selectUser(userPhone);
|
||||
Project project = projectDao.selectProject(projectName);
|
||||
return recordDao.countRecord(null, user, project, RecordStateEnum.UNDER_REVIEW.getValue(), null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reviewRecord(ReviewRecordDTO reviewRecordDTO) {
|
||||
if (!respondentDao.existRespondent(reviewRecordDTO.getIdNumber(), RespondentStateEnum.NOT_INVESTIGATED.getValue())) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
if (!userDao.existUser(reviewRecordDTO.getReviewerPhone())) {
|
||||
throw new UserException(ResultEnum.NOT_EXIST_USER);
|
||||
}
|
||||
if (!projectDao.existProject(reviewRecordDTO.getProjectName())) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
Project project = projectDao.selectProject(reviewRecordDTO.getProjectName());
|
||||
Respondent respondent = respondentDao.selectRespondent(reviewRecordDTO.getIdNumber(), project);
|
||||
User user = userDao.selectUser(reviewRecordDTO.getReviewerPhone());
|
||||
|
||||
|
||||
if (!recordDao.existRecord(respondent, project, RecordStateEnum.UNDER_REVIEW.getValue())) {
|
||||
throw new RecordException(ResultEnum.NOT_EXIST_RECORD);
|
||||
}
|
||||
Record record = recordDao.getRecord(respondent, project, RecordStateEnum.UNDER_REVIEW.getValue());
|
||||
|
||||
record.setState(reviewRecordDTO.getPass() ? RecordStateEnum.REVIEWED.getValue() : RecordStateEnum.NOT_PASS.getValue());
|
||||
record.setVersion(UUID.randomUUID().toString());
|
||||
Operation reviewOp = Operation.reviewOp(user, reviewRecordDTO.getMsg(), record.getVersion(), reviewRecordDTO.getPass());
|
||||
List<Operation> opList = record.getOperationList();
|
||||
opList.add(reviewOp);
|
||||
record.setOperationList(opList);
|
||||
|
||||
recordDao.saveRecord(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyRecord(ModifyRecordDTO modifyRecordDTO) {
|
||||
if (!respondentDao.existRespondent(modifyRecordDTO.getIdNumber(), RespondentStateEnum.NOT_INVESTIGATED.getValue())) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
if (!userDao.existUser(modifyRecordDTO.getUserPhone())) {
|
||||
throw new UserException(ResultEnum.NOT_EXIST_USER);
|
||||
}
|
||||
if (!projectDao.existProject(modifyRecordDTO.getProjectName())) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
Project project = projectDao.selectProject(modifyRecordDTO.getProjectName());
|
||||
Respondent respondent = respondentDao.selectRespondent(modifyRecordDTO.getIdNumber(), project);
|
||||
User user = userDao.selectUser(modifyRecordDTO.getUserPhone());
|
||||
|
||||
|
||||
if (!recordDao.existRecord(respondent, project, RecordStateEnum.UNDER_REVIEW.getValue())) {
|
||||
throw new RecordException(ResultEnum.NOT_EXIST_RECORD);
|
||||
}
|
||||
Record record = recordDao.getRecord(respondent, project, RecordStateEnum.REVIEWED.getValue());
|
||||
|
||||
//将原来的设为已归档 添加覆盖操作
|
||||
record.setState(RecordStateEnum.FILED.getValue());
|
||||
Operation coverOp = Operation.coverOp(user, record.getVersion());
|
||||
List<Operation> oldOpList = record.getOperationList();
|
||||
List<Operation> newOpList = record.getOperationList();
|
||||
oldOpList.add(coverOp);
|
||||
record.setOperationList(oldOpList);
|
||||
record.setVersion(UUID.randomUUID().toString());
|
||||
recordDao.saveRecord(record);
|
||||
|
||||
//生成新的流调记录
|
||||
record.setId(null);
|
||||
record.setValues(modifyRecordDTO.getValues());
|
||||
record.setState(RecordStateEnum.UNDER_REVIEW.getValue());
|
||||
Operation modifyOp = Operation.modifyOp(user, modifyRecordDTO.getMsg(), record.getVersion());
|
||||
newOpList.add(modifyOp);
|
||||
record.setOperationList(newOpList);
|
||||
record.setVersion(UUID.randomUUID().toString());
|
||||
recordDao.saveRecord(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createRecord(SubmitRecordDTO submitRecordDTO) {
|
||||
if (!respondentDao.existRespondent(submitRecordDTO.getIdNumber())) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
if (!userDao.existUser(submitRecordDTO.getUserPhone())) {
|
||||
throw new UserException(ResultEnum.NOT_EXIST_USER);
|
||||
}
|
||||
if (!projectDao.existProject(submitRecordDTO.getProjectName())) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
Project project = projectDao.selectProject(submitRecordDTO.getProjectName());
|
||||
Respondent respondent = respondentDao.selectRespondent(submitRecordDTO.getIdNumber(), project);
|
||||
User user = userDao.selectUser(submitRecordDTO.getUserPhone());
|
||||
|
||||
//设置调查对象为已调查
|
||||
respondent.setState(RespondentStateEnum.INVESTIGATED.getValue());
|
||||
respondentDao.saveRespondent(respondent);
|
||||
|
||||
Record record = recordDao.getRecord(respondent, project, RecordStateEnum.UNDER_REVIEW.getValue());
|
||||
if (record == null) {
|
||||
record = recordDao.getRecord(respondent, project, RecordStateEnum.REVIEWED.getValue());
|
||||
}
|
||||
if (record != null) {
|
||||
//存在旧纪录,覆盖
|
||||
List<Operation> oldOpList = record.getOperationList();
|
||||
List<Operation> newOpList = record.getOperationList();
|
||||
record.setState(RecordStateEnum.FILED.getValue());
|
||||
Operation coverOp = Operation.coverOp(user, record.getVersion());
|
||||
oldOpList.add(coverOp);
|
||||
record.setOperationList(oldOpList);
|
||||
record.setVersion(UUID.randomUUID().toString());
|
||||
recordDao.saveRecord(record);
|
||||
|
||||
//插入新记录
|
||||
record.setId(null);
|
||||
record.setValues(submitRecordDTO.getValues());
|
||||
record.setState(RecordStateEnum.UNDER_REVIEW.getValue());
|
||||
Operation submitOp = Operation.submitOp(user, submitRecordDTO.getMsg(), record.getVersion());
|
||||
newOpList.add(submitOp);
|
||||
record.setOperationList(newOpList);
|
||||
record.setVersion(UUID.randomUUID().toString());
|
||||
} else {
|
||||
record = new Record();
|
||||
record.setRespondent(respondent);
|
||||
record.setUser(user);
|
||||
record.setValues(submitRecordDTO.getValues());
|
||||
record.setState(RecordStateEnum.UNDER_REVIEW.getValue());
|
||||
record.setVersion(UUID.randomUUID().toString());
|
||||
List<Operation> opList = new ArrayList<>();
|
||||
Operation submitOp = Operation.submitOp(user, submitRecordDTO.getMsg(), record.getVersion());
|
||||
opList.add(submitOp);
|
||||
record.setOperationList(opList);
|
||||
record.setProject(project);
|
||||
}
|
||||
recordDao.saveRecord(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countRecord(String idNumber, String userPhone, String projectName, String state, String version, String questionnaireNumber) {
|
||||
if (idNumber != null && !respondentDao.existRespondent(idNumber)) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
if (userPhone != null && !userDao.existUser(userPhone)) {
|
||||
throw new UserException(ResultEnum.NOT_EXIST_USER);
|
||||
}
|
||||
if (projectName != null && !projectDao.existProject(projectName)) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
Project project = projectDao.selectProject(projectName);
|
||||
Respondent respondent = respondentDao.selectRespondent(idNumber, project);
|
||||
User user = userDao.selectUser(userPhone);
|
||||
|
||||
|
||||
return recordDao.countRecord(respondent, user, project, state, version, questionnaireNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RecordVO> listRecordLimit(String idNumber, String userPhone, String projectName, String state, String version, String questionnaireNumber, int currentPage, int pageSize) {
|
||||
if (idNumber != null && !respondentDao.existRespondent(idNumber)) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
if (userPhone != null && !userDao.existUser(userPhone)) {
|
||||
throw new UserException(ResultEnum.NOT_EXIST_USER);
|
||||
}
|
||||
if (projectName != null && !projectDao.existProject(projectName)) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
Project project = projectDao.selectProject(projectName);
|
||||
Respondent respondent = respondentDao.selectRespondent(idNumber, project);
|
||||
User user = userDao.selectUser(userPhone);
|
||||
|
||||
|
||||
List<Record> recordList = recordDao.listRecordLimit(respondent, user, project, state, version, questionnaireNumber, currentPage * pageSize, pageSize);
|
||||
return recordList.stream().map(record -> {
|
||||
RecordVO recordVO = new RecordVO();
|
||||
recordVO.setIdNumber(record.getRespondent().getIdNumber());
|
||||
recordVO.setUserPhone(record.getUser().getPhone());
|
||||
recordVO.setProjectName(record.getProject().getName());
|
||||
recordVO.setOperationInfoList(record.getOperationList().stream().map(op -> {
|
||||
OperationInfo operationInfo = new OperationInfo();
|
||||
operationInfo.setType(op.getType());
|
||||
operationInfo.setTime(op.getTime());
|
||||
operationInfo.setUserPhone(op.getUser().getPhone());
|
||||
operationInfo.setMsg(op.getMsg());
|
||||
operationInfo.setResult(op.getResult());
|
||||
operationInfo.setVersion(op.getVersion());
|
||||
return operationInfo;
|
||||
}).collect(Collectors.toList()));
|
||||
recordVO.setVersion(record.getVersion());
|
||||
recordVO.setState(record.getState());
|
||||
return recordVO;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getRecordValues(String projectName, String idNumber, String version) {
|
||||
if (!projectDao.existProject(projectName)) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
if (!respondentDao.existRespondent(idNumber)) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
Project project = projectDao.selectProject(projectName);
|
||||
Respondent respondent = respondentDao.selectRespondent(idNumber, project);
|
||||
Record record = recordDao.selectRecord(respondent, project, version);
|
||||
if (record == null) {
|
||||
throw new RecordException(ResultEnum.NOT_EXIST_RECORD);
|
||||
}
|
||||
return record.getValues();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,19 +1,32 @@
|
||||
package com.example.survey.service.impl;
|
||||
|
||||
import com.example.survey.dao.ProjectDao;
|
||||
import com.example.survey.dao.RespondentDao;
|
||||
import com.example.survey.dao.UserDao;
|
||||
import com.example.survey.dto.respondent.CreateRespondentDTO;
|
||||
import com.example.survey.dto.respondent.DeleteRespondentDTO;
|
||||
import com.example.survey.dto.respondent.ModifyRespondentDTO;
|
||||
import com.example.survey.dto.respondent.ModifyRespondentUserDTO;
|
||||
import com.example.survey.entity.Project;
|
||||
import com.example.survey.entity.Respondent;
|
||||
import com.example.survey.entity.User;
|
||||
import com.example.survey.entity.inner.AdministrativeArea;
|
||||
import com.example.survey.enumeration.RespondentStateEnum;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.exception.ProjectException;
|
||||
import com.example.survey.exception.RespondentException;
|
||||
import com.example.survey.exception.UserException;
|
||||
import com.example.survey.service.RespondentService;
|
||||
import com.example.survey.dto.RespondentDto;
|
||||
import com.example.survey.vo.CreateRespondentVo;
|
||||
import com.example.survey.vo.RespondentVO;
|
||||
import com.example.survey.vo.inner.UserInfo;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
@ -25,33 +38,139 @@ public class RespondentServiceImpl implements RespondentService {
|
||||
@Autowired
|
||||
private RespondentDao respondentDao;
|
||||
|
||||
@Autowired
|
||||
private ProjectDao projectDao;
|
||||
|
||||
@Autowired
|
||||
private UserDao userDao;
|
||||
|
||||
@Override
|
||||
public boolean addRespondent(CreateRespondentVo createRespondentVo) {
|
||||
if (!userDao.existUser(createRespondentVo.getUserPhone())) {
|
||||
log.error("不存在对应id的用户");
|
||||
public void createRespondent(CreateRespondentDTO createRespondentDTO) {
|
||||
if (!projectDao.existProject(createRespondentDTO.getProjectName())) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
Respondent respondent = new Respondent(createRespondentVo);
|
||||
if (!userDao.existUser(createRespondentDTO.getUserPhone())) {
|
||||
throw new UserException(ResultEnum.NOT_EXIST_USER);
|
||||
}
|
||||
Project project = projectDao.selectProject(createRespondentDTO.getProjectName());
|
||||
User user = userDao.selectUser(createRespondentDTO.getPhone());
|
||||
|
||||
return respondentDao.insertRespondent(respondent);
|
||||
Respondent respondent = new Respondent();
|
||||
respondent.setIdNumber(createRespondentDTO.getIdNumber());
|
||||
respondent.setPhone(createRespondentDTO.getPhone());
|
||||
respondent.setName(createRespondentDTO.getName());
|
||||
respondent.setGender(createRespondentDTO.getGender());
|
||||
respondent.setMsg(createRespondentDTO.getMsg());
|
||||
respondent.setAdministrativeArea(createRespondentDTO.getAdministrativeArea());
|
||||
respondent.setProject(project);
|
||||
respondent.setUser(user);
|
||||
respondent.setState(RespondentStateEnum.NOT_INVESTIGATED.getValue());
|
||||
respondentDao.saveRespondent(respondent);
|
||||
|
||||
project.setRespondentCount(project.getRespondentCount() + 1);
|
||||
project.setNotInvestigatedRespondentCount(project.getNotInvestigatedRespondentCount() + 1);
|
||||
projectDao.saveProject(project);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RespondentDto> listRespondentLimit(String userPhone, String state, AdministrativeArea administrativeArea, int currentPage, int pageSize) {
|
||||
List<RespondentDto> dtoList = new ArrayList<>();
|
||||
List<Respondent> respondentList = respondentDao.listRespondentLimit(userPhone, state, administrativeArea, currentPage * pageSize, pageSize);
|
||||
for (Respondent respondent : respondentList) {
|
||||
User user = userDao.selectUser(respondent.getUserPhone());
|
||||
dtoList.add(new RespondentDto(respondent, user));
|
||||
public List<RespondentVO> listRespondentLimit(String userPhone, String state, String idNumber, String name, String phone, String province, String city, String county, String projectName, int currentPage, int pageSize) {
|
||||
if (userPhone != null && !userDao.existUser(userPhone)) {
|
||||
throw new UserException(ResultEnum.NOT_EXIST_USER);
|
||||
}
|
||||
return dtoList;
|
||||
if (projectName != null && !projectDao.existProject(projectName)) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
User tmpUser = userDao.selectUser(userPhone);
|
||||
Project tmpProject = projectDao.selectProject(projectName);
|
||||
|
||||
List<Respondent> respondentList = respondentDao.listRespondentLimit(tmpUser, state, idNumber, name, phone, province, city, county, tmpProject, currentPage * pageSize, pageSize);
|
||||
if (respondentList == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return respondentList.stream().map(respondent -> {
|
||||
RespondentVO respondentVO = new RespondentVO();
|
||||
respondentVO.setIdNumber(respondent.getIdNumber());
|
||||
respondentVO.setPhone(respondent.getPhone());
|
||||
respondentVO.setName(respondent.getName());
|
||||
respondentVO.setMsg(respondent.getMsg());
|
||||
respondentVO.setGender(respondent.getGender());
|
||||
respondentVO.setAdministrativeArea(respondent.getAdministrativeArea());
|
||||
respondentVO.setProjectName(respondent.getProject().getName());
|
||||
respondentVO.setState(respondent.getState());
|
||||
User user = respondent.getUser();
|
||||
if (user != null) {
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setIdNumber(user.getIdNumber());
|
||||
userInfo.setUsername(user.getUsername());
|
||||
userInfo.setPhone(user.getPhone());
|
||||
respondentVO.setUserInfo(userInfo);
|
||||
}
|
||||
return respondentVO;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countRespondent(String userPhone, String state, AdministrativeArea administrativeArea) {
|
||||
return respondentDao.countRespondent(userPhone, state, administrativeArea);
|
||||
public long countRespondent(String userPhone, String state, String idNumber, String name, String phone, String province, String city, String county, String projectName) {
|
||||
if (userPhone != null && !userDao.existUser(userPhone)) {
|
||||
throw new UserException(ResultEnum.NOT_EXIST_USER);
|
||||
}
|
||||
if (projectName != null && !projectDao.existProject(projectName)) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
User user = userDao.selectUser(userPhone);
|
||||
Project project = projectDao.selectProject(projectName);
|
||||
return respondentDao.countRespondent(user, state, idNumber, name, phone, province, city, county, project);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyRespondent(ModifyRespondentDTO modifyRespondentDTO) {
|
||||
if (!projectDao.existProject(modifyRespondentDTO.getProjectName())) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
if (!respondentDao.existRespondent(modifyRespondentDTO.getIdNumber())) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
Project project = projectDao.selectProject(modifyRespondentDTO.getProjectName());
|
||||
Respondent respondent = respondentDao.selectRespondent(modifyRespondentDTO.getIdNumber(), project);
|
||||
respondent.setPhone(modifyRespondentDTO.getPhone());
|
||||
respondent.setName(modifyRespondentDTO.getName());
|
||||
respondent.setMsg(modifyRespondentDTO.getMsg());
|
||||
respondent.setGender(modifyRespondentDTO.getGender());
|
||||
respondent.setAdministrativeArea(modifyRespondentDTO.getAdministrativeArea());
|
||||
respondentDao.saveRespondent(respondent);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void modifyUser(ModifyRespondentUserDTO modifyRespondentUserDTO) {
|
||||
if (!respondentDao.existRespondent(modifyRespondentUserDTO.getIdNumber())) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
if (!userDao.existUser(modifyRespondentUserDTO.getUserPhone())) {
|
||||
throw new UserException(ResultEnum.NOT_EXIST_USER);
|
||||
}
|
||||
if (!projectDao.existProject(modifyRespondentUserDTO.getProjectName())) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
Project project = projectDao.selectProject(modifyRespondentUserDTO.getProjectName());
|
||||
Respondent respondent = respondentDao.selectRespondent(modifyRespondentUserDTO.getIdNumber(), project);
|
||||
User user = userDao.selectUser(modifyRespondentUserDTO.getUserPhone());
|
||||
respondent.setUser(user);
|
||||
respondentDao.saveRespondent(respondent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRespondent(DeleteRespondentDTO deleteRespondentDTO) {
|
||||
if (!respondentDao.existRespondent(deleteRespondentDTO.getIdNumber())) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
if (!projectDao.existProject(deleteRespondentDTO.getProjectName())) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
Project project = projectDao.selectProject(deleteRespondentDTO.getProjectName());
|
||||
Respondent respondent = respondentDao.selectRespondent(deleteRespondentDTO.getIdNumber(), project);
|
||||
respondent.setState(RespondentStateEnum.FILED.getValue());
|
||||
respondentDao.saveRespondent(respondent);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2,13 +2,17 @@ package com.example.survey.service.impl;
|
||||
|
||||
import com.example.survey.dao.RoleDao;
|
||||
import com.example.survey.dao.UserDao;
|
||||
import com.example.survey.dto.role.CreateRoleDTO;
|
||||
import com.example.survey.dto.role.DeleteRoleDTO;
|
||||
import com.example.survey.dto.role.ModifyRoleDTO;
|
||||
import com.example.survey.entity.Role;
|
||||
import com.example.survey.enumeration.AuthEnum;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.exception.AuthException;
|
||||
import com.example.survey.exception.RoleException;
|
||||
import com.example.survey.service.RoleService;
|
||||
import com.example.survey.util.TokenUtil;
|
||||
import com.example.survey.vo.CreateRoleVo;
|
||||
import com.example.survey.vo.ModifyRoleVo;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -21,6 +25,7 @@ import java.util.Set;
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Log4j2
|
||||
@Service
|
||||
public class RoleServiceImpl implements RoleService {
|
||||
|
||||
@ -31,54 +36,72 @@ public class RoleServiceImpl implements RoleService {
|
||||
private UserDao userDao;
|
||||
|
||||
@Override
|
||||
public boolean addRole(CreateRoleVo createRoleVo) {
|
||||
public void addRole(CreateRoleDTO createRoleDTO) {
|
||||
Role role = new Role();
|
||||
role.setName(createRoleVo.getRoleName());
|
||||
role.setName(createRoleDTO.getName());
|
||||
Set<AuthEnum> authoritySet = new HashSet<>();
|
||||
for (String name : createRoleVo.getAuthList()) {
|
||||
authoritySet.add(AuthEnum.getRoleEnum(name));
|
||||
for (String name : createRoleDTO.getAuthoritySet()) {
|
||||
AuthEnum authEnum = AuthEnum.getRoleEnum(name);
|
||||
if (authEnum == null) {
|
||||
throw new AuthException(ResultEnum.NOT_EXIST_AUTHORITY);
|
||||
}
|
||||
authoritySet.add(authEnum);
|
||||
}
|
||||
role.setAuthoritySet(authoritySet);
|
||||
|
||||
return roleDao.insertRole(role);
|
||||
roleDao.saveRole(role);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CreateRoleVo> getRole(String roleName, int currentPage, int pageSize) {
|
||||
List<Role> roleList = roleDao.listLimitRole(roleName, currentPage * pageSize, pageSize);
|
||||
List<CreateRoleVo> roleVoList = new LinkedList<>();
|
||||
public List<CreateRoleDTO> listRoleLimit(String name, int currentPage, int pageSize) {
|
||||
List<CreateRoleDTO> createRoleDTOList = new LinkedList<>();
|
||||
List<Role> roleList = roleDao.listRoleLimit(name, currentPage * pageSize, pageSize);
|
||||
if (roleList == null) {
|
||||
return createRoleDTOList;
|
||||
}
|
||||
for (Role role : roleList) {
|
||||
roleVoList.add(new CreateRoleVo(role));
|
||||
createRoleDTOList.add(new CreateRoleDTO(role));
|
||||
}
|
||||
|
||||
return roleVoList;
|
||||
return createRoleDTOList;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteRole(String roleName) {
|
||||
public void deleteRole(DeleteRoleDTO deleteRoleDTO) {
|
||||
if (!roleDao.existRole(deleteRoleDTO.getName())) {
|
||||
throw new RoleException(ResultEnum.NOT_EXIST_ROLE);
|
||||
}
|
||||
//将用户数据库中含有该角色的用户更新
|
||||
userDao.clearRole(roleDao.selectRole(roleName));
|
||||
userDao.clearRole(roleDao.selectRole(deleteRoleDTO.getName()));
|
||||
//从角色数据库删除角色
|
||||
roleDao.deleteRole(roleName);
|
||||
|
||||
roleDao.deleteRole(deleteRoleDTO.getName());
|
||||
//删除redis中的角色
|
||||
TokenUtil.expireKey(roleName);
|
||||
TokenUtil.expireKey(deleteRoleDTO.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyRole(ModifyRoleVo modifyRoleVo) {
|
||||
Set<AuthEnum> authEnumList = new HashSet<>();
|
||||
public void modifyRole(ModifyRoleDTO modifyRoleDTO) {
|
||||
if (!roleDao.existRole(modifyRoleDTO.getName())) {
|
||||
throw new RoleException(ResultEnum.NOT_EXIST_ROLE);
|
||||
}
|
||||
Role role = roleDao.selectRole(modifyRoleDTO.getName());
|
||||
Set<AuthEnum> authoritySet = new HashSet<>();
|
||||
Set<String> routeSet = new HashSet<>();
|
||||
for (String authName : modifyRoleVo.getAuthList()) {
|
||||
for (String authName : modifyRoleDTO.getAuthoritySet()) {
|
||||
AuthEnum authEnum = AuthEnum.getRoleEnum(authName);
|
||||
if(authEnum == null){
|
||||
throw new AuthException("权限不存在");
|
||||
if (authEnum == null) {
|
||||
throw new AuthException(ResultEnum.NOT_EXIST_AUTHORITY);
|
||||
}
|
||||
authEnumList.add(authEnum);
|
||||
authoritySet.add(authEnum);
|
||||
routeSet.addAll(authEnum.getRoutes());
|
||||
}
|
||||
roleDao.updateRole(modifyRoleVo.getRoleName(), authEnumList);
|
||||
TokenUtil.setWithoutExpireTime(modifyRoleVo.getRoleName(), routeSet);
|
||||
role.setAuthoritySet(authoritySet);
|
||||
roleDao.saveRole(role);
|
||||
TokenUtil.setWithoutExpireTime(modifyRoleDTO.getName(), routeSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countRole(String name) {
|
||||
return roleDao.countRole(name);
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user