diff --git a/pom.xml b/pom.xml
index b2737e7..2161c95 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,25 +22,23 @@
org.springframework.boot
- spring-boot-starter-data-mongodb
+ spring-boot-starter-web
+
+
+ org.springframework.boot
+ spring-boot-starter-logging
+
+
org.springframework.boot
- spring-boot-starter-web
+ spring-boot-starter-data-mongodb
-
org.springframework.boot
spring-boot-starter-test
test
-
-
- org.springframework.kafka
- spring-kafka
- 2.6.5
-
-
org.projectlombok
@@ -58,10 +56,33 @@
fastjson
1.2.75
+
+
+ org.apache.poi
+ poi
+ 3.17
+
+
+ org.apache.poi
+ poi-ooxml
+ 3.17
+
+
+
+ org.apache.poi
+ ooxml-schemas
+ 1.1
+
+
+ org.springframework.boot
+ spring-boot-starter-log4j2
+
-
-
+
+ org.springframework.boot
+ spring-boot-starter-aop
+
diff --git a/src/main/java/com/example/survey/config/AuthFilterConfig.java b/src/main/java/com/example/survey/config/AuthFilterConfig.java
index f7d4a0e..eb7dcb4 100644
--- a/src/main/java/com/example/survey/config/AuthFilterConfig.java
+++ b/src/main/java/com/example/survey/config/AuthFilterConfig.java
@@ -3,6 +3,7 @@ package com.example.survey.config;
import com.alibaba.fastjson.JSON;
import com.example.survey.util.TokenUtil;
import com.example.survey.vo.ResultVo;
+import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
@@ -18,6 +19,7 @@ import java.util.Set;
* @author Pope
* 权限过滤器
*/
+@Log4j2
@Configuration
public class AuthFilterConfig implements Filter {
@@ -32,10 +34,6 @@ public class AuthFilterConfig implements Filter {
}};
- @Autowired
- TokenUtil tokenUtil;
-
-
@Override
public void init(FilterConfig filterConfig) throws ServletException {
@@ -52,24 +50,32 @@ public class AuthFilterConfig implements Filter {
HttpServletResponse response = (HttpServletResponse) servletResponse;
String method = request.getMethod();
String uri = request.getRequestURI();
-
- System.out.println(method + " : " + uri);
+ log.info(method + uri);
//判断是否需要token
+
if (URIS.contains(uri)) {
filterChain.doFilter(servletRequest, servletResponse);
return;
}
+
String token = request.getHeader("Authorization");
+ if(uri.startsWith("/investigationRecord/record2word")){
+ token = request.getParameter("token");
+ }
if (token == null) {
+ log.error("请求无token");
returnJson(response, new ResultVo(ResultVo.FAILED, "请先登录!", null));
return;
}
- if (!tokenUtil.isPass(token,uri,method)) {
+ if (!TokenUtil.isPass(token, uri, method)) {
+ log.error("token错误");
returnJson(response, new ResultVo(ResultVo.FAILED, "权限不够!", null));
return;
}
+
+
filterChain.doFilter(servletRequest, servletResponse);
}
diff --git a/src/main/java/com/example/survey/config/LogConfig.java b/src/main/java/com/example/survey/config/LogConfig.java
new file mode 100644
index 0000000..f6bb335
--- /dev/null
+++ b/src/main/java/com/example/survey/config/LogConfig.java
@@ -0,0 +1,45 @@
+package com.example.survey.config;
+
+import lombok.extern.log4j.Log4j2;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.annotation.Pointcut;
+import org.springframework.aop.MethodBeforeAdvice;
+import org.springframework.context.annotation.Configuration;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Objects;
+
+/**
+ * @author Pope
+ */
+@Log4j2
+@Aspect
+@Configuration
+public class LogConfig {
+
+ @Pointcut(value = "execution(* com.example.survey.controller.*.*(..))")
+ public void controllerLog() {
+
+ }
+
+ @Pointcut(value = "execution(* com.example.survey.service.impl.*.*(..))")
+ public void serviceLog() {
+
+ }
+
+ @Pointcut(value = "execution(* com.example.survey.dao.impl.*.*(..))")
+ public void daoLog() {
+
+ }
+
+
+ @Around(value = "controllerLog()||serviceLog()||daoLog()")
+ public Object before(ProceedingJoinPoint joinPoint) throws Throwable {
+ log.info("class:{}, method:{}, params:{}", joinPoint.getTarget().getClass().getName(), joinPoint.getSignature().getName(), Arrays.toString(joinPoint.getArgs()));
+ return joinPoint.proceed();
+ }
+}
diff --git a/src/main/java/com/example/survey/controller/InvestigationRecordController.java b/src/main/java/com/example/survey/controller/InvestigationRecordController.java
index 8ea3fea..cca2b5f 100644
--- a/src/main/java/com/example/survey/controller/InvestigationRecordController.java
+++ b/src/main/java/com/example/survey/controller/InvestigationRecordController.java
@@ -5,9 +5,11 @@ 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;
@@ -15,6 +17,7 @@ import java.util.Map;
/**
* @author Pope
*/
+@Log4j2
@RestController
@RequestMapping("/investigationRecord")
public class InvestigationRecordController {
@@ -22,38 +25,21 @@ public class InvestigationRecordController {
@Autowired
private InvestigationRecordService investigationRecordService;
- @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.setData(result);
-
- return resultVo;
- }
-
-
@GetMapping("/underReviewRecord")
public ResultVo getUnderReviewRecord(@RequestParam(value = "currentPage") Integer currentPage,
@RequestParam(value = "pageSize", defaultValue = "30") Integer pageSize,
- @RequestParam(value = "investigatorPhone", required = false) String investigatorPhone,
+ @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 resultMap = new HashMap<>(16, 0.75F);
- List records = investigationRecordService.listUnderReviewRecordPageByInvestigationPhone(investigatorPhone, currentPage, pageSize, state, idNumber, version, questionnaireNumber, diseased);
+ List records = investigationRecordService.listUnderReviewRecordLimit(userPhone, currentPage, pageSize, state, idNumber, version, questionnaireNumber, diseased);
resultMap.put("totalCount", records.size());
resultMap.put("currentPage", currentPage);
resultMap.put("pageSize", pageSize);
@@ -64,12 +50,12 @@ public class InvestigationRecordController {
}
@GetMapping("/underReviewRecordCount")
- public ResultVo countUnderReviewRecord(@RequestParam(value = "investigatorPhone") String investigatorPhone) {
+ public ResultVo countUnderReviewRecord(@RequestParam(value = "userPhone") String userPhone) {
ResultVo resultVo = new ResultVo();
resultVo.setCode(ResultVo.SUCCESS);
resultVo.setMsg("查询成功");
- resultVo.setData(investigationRecordService.countUnderReviewRecordByInvestigatorPhone(investigatorPhone));
+ resultVo.setData(investigationRecordService.countUnderReviewRecord(userPhone));
return resultVo;
}
@@ -79,9 +65,7 @@ public class InvestigationRecordController {
public ResultVo reviewRecord(@RequestBody ReviewVo reviewVo) {
ResultVo resultVo = new ResultVo();
- resultVo.setCode(ResultVo.SUCCESS);
boolean result = investigationRecordService.reviewRecord(reviewVo);
-
if (result) {
resultVo.setCode(ResultVo.SUCCESS);
resultVo.setMsg("审核成功");
@@ -90,6 +74,7 @@ public class InvestigationRecordController {
resultVo.setMsg("审核失败");
}
+ resultVo.setCode(ResultVo.SUCCESS);
resultVo.setData(result);
return resultVo;
@@ -99,12 +84,37 @@ public class InvestigationRecordController {
public ResultVo updateInvestigationRecord(@RequestBody InvestigationRecordVo investigationRecordVo) {
ResultVo resultVo = new ResultVo();
- resultVo.setCode(0);
- resultVo.setMsg("修改提交成功,等待审核");
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);
+ }
+
}
diff --git a/src/main/java/com/example/survey/controller/InvestigatorController.java b/src/main/java/com/example/survey/controller/InvestigatorController.java
deleted file mode 100644
index 2b12189..0000000
--- a/src/main/java/com/example/survey/controller/InvestigatorController.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.example.survey.controller;
-
-import com.example.survey.entity.Investigator;
-import com.example.survey.service.InvestigatorService;
-import com.example.survey.vo.ResultVo;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-
-/**
- * @author Pope
- */
-@RestController
-@RequestMapping("/investigator")
-public class InvestigatorController {
-
- @Autowired
- private InvestigatorService investigatorService;
-
- @PostMapping("/investigator")
- public ResultVo addInvestigator(@RequestBody Investigator investigator){
- ResultVo resultVo = new ResultVo();
-
- boolean result = investigatorService.addInvestigator(investigator);
- if(result){
- resultVo.setCode(ResultVo.SUCCESS);
- resultVo.setMsg("创建成功");
- }else {
- resultVo.setCode(ResultVo.FAILED);
- resultVo.setMsg("创建失败");
- }
- resultVo.setData(result);
-
- return resultVo;
- }
-
-}
diff --git a/src/main/java/com/example/survey/controller/RespondentController.java b/src/main/java/com/example/survey/controller/RespondentController.java
index fe4e6cf..9b8c5f3 100644
--- a/src/main/java/com/example/survey/controller/RespondentController.java
+++ b/src/main/java/com/example/survey/controller/RespondentController.java
@@ -1,8 +1,9 @@
package com.example.survey.controller;
-import com.example.survey.entity.Respondent;
+import com.example.survey.entity.inner.AdministrativeArea;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -22,10 +23,10 @@ public class RespondentController {
private RespondentService respondentService;
@PostMapping("/respondent")
- public ResultVo addRespondent(@RequestBody Respondent respondent) {
+ public ResultVo addRespondent(@RequestBody CreateRespondentVo createRespondentVo) {
ResultVo resultVo = new ResultVo();
- boolean result = respondentService.addRespondent(respondent);
+ boolean result = respondentService.addRespondent(createRespondentVo);
if (result) {
resultVo.setCode(ResultVo.SUCCESS);
resultVo.setMsg("创建成功");
@@ -39,19 +40,24 @@ public class RespondentController {
}
@GetMapping("/respondent")
- public ResultVo countRespondent(@RequestParam(value = "investigatorPhone") String investigatorPhone,
+ 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();
-
- resultVo.setCode(ResultVo.SUCCESS);
- resultVo.setMsg("查询成功");
Map resultMap = new HashMap<>(16, 0.75F);
- List voList = respondentService.listRespondentPageByInvestigatorPhone(investigatorPhone, currentPage, pageSize);
- resultMap.put("totalCount", voList.size());
+ AdministrativeArea administrativeArea = new AdministrativeArea(province, city, county);
+ List voList = respondentService.listRespondentLimit(userPhone, state, administrativeArea, currentPage, pageSize);
+ resultMap.put("totalCount", respondentService.countRespondent(userPhone, state, administrativeArea));
resultMap.put("currentPage", currentPage);
resultMap.put("pageSize", pageSize);
resultMap.put("data", voList);
+
+ resultVo.setCode(ResultVo.SUCCESS);
+ resultVo.setMsg("查询成功");
resultVo.setData(resultMap);
return resultVo;
diff --git a/src/main/java/com/example/survey/controller/RoleController.java b/src/main/java/com/example/survey/controller/RoleController.java
index 9284f42..d7e3ebb 100644
--- a/src/main/java/com/example/survey/controller/RoleController.java
+++ b/src/main/java/com/example/survey/controller/RoleController.java
@@ -1,13 +1,17 @@
package com.example.survey.controller;
+import com.example.survey.enumeration.AuthEnum;
import com.example.survey.service.RoleService;
-import com.example.survey.vo.RoleVo;
+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 org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
/**
* @author Pope
@@ -19,11 +23,32 @@ public class RoleController {
@Autowired
private RoleService roleService;
- @PostMapping("/role")
- public ResultVo addAuth(@RequestBody RoleVo roleVo){
+ @GetMapping("/role")
+ 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();
- boolean result = roleService.addRole(roleVo);
+
+ List roleVoList = roleService.getRole(roleName, currentPage, pageSize);
+ Map resultMap = new HashMap<>(16, 0.75F);
+ resultMap.put("totalCount",roleVoList.size());
+ resultMap.put("pageSize", pageSize);
+ resultMap.put("currentPage", currentPage);
+ resultMap.put("data",roleVoList);
+
+ resultVo.setCode(ResultVo.SUCCESS);
+ resultVo.setMsg("查询成功");
+ 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("创建成功");
@@ -36,4 +61,42 @@ public class RoleController {
}
+
+ @DeleteMapping("/role")
+ public ResultVo deleteRole(@RequestBody DeleteRoleVo deleteRoleVo) {
+ ResultVo resultVo = new ResultVo();
+
+ roleService.deleteRole(deleteRoleVo.getRoleName());
+
+ resultVo.setCode(ResultVo.SUCCESS);
+ resultVo.setMsg("删除成功");
+ return resultVo;
+ }
+
+ @PutMapping("/role")
+ public ResultVo modifyRole(@RequestBody ModifyRoleVo modifyRoleVo) {
+ ResultVo resultVo = new ResultVo();
+
+ roleService.modifyRole(modifyRoleVo);
+
+ resultVo.setCode(ResultVo.SUCCESS);
+ resultVo.setMsg("修改成功");
+
+ return resultVo;
+ }
+
+ @GetMapping("/authList")
+ public ResultVo getAuthList() {
+ ResultVo resultVo = new ResultVo();
+
+ Map resultMap = new HashMap<>();
+ resultMap.put("authList", AuthEnum.getNameList());
+ resultVo.setCode(ResultVo.SUCCESS);
+ resultVo.setMsg("查询成功");
+ resultVo.setData(resultMap);
+
+ return resultVo;
+ }
+
+
}
diff --git a/src/main/java/com/example/survey/controller/UserController.java b/src/main/java/com/example/survey/controller/UserController.java
index ed4768a..544ce76 100644
--- a/src/main/java/com/example/survey/controller/UserController.java
+++ b/src/main/java/com/example/survey/controller/UserController.java
@@ -1,14 +1,17 @@
package com.example.survey.controller;
import com.example.survey.dto.LoginDto;
+import com.example.survey.dto.UserDto;
import com.example.survey.service.UserService;
-import com.example.survey.vo.LoginVo;
-import com.example.survey.vo.ResultVo;
-import com.example.survey.vo.SignupVo;
-import com.example.survey.vo.UserRoleVo;
+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;
+
+
/**
* @author Pope
*/
@@ -19,6 +22,42 @@ public class UserController {
@Autowired
UserService userService;
+ @GetMapping("/user")
+ 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();
+
+
+ List userDtoList = userService.listUserLimit(username, phoneNumber, currentPage, pageSize);
+ Map resultMap = new HashMap<>(16, 0.75F);
+ resultMap.put("totalCount", userDtoList.size());
+ resultMap.put("pageSize", pageSize);
+ resultMap.put("currentPage", currentPage);
+ resultMap.put("data", userDtoList);
+
+ resultVo.setCode(ResultVo.SUCCESS);
+ resultVo.setMsg("查询成功");
+ 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;
+ }
+
@PostMapping("/login")
public ResultVo login(@RequestBody LoginVo loginVo) {
ResultVo resultVo = new ResultVo();
@@ -36,31 +75,69 @@ public class UserController {
return resultVo;
}
- @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;
- }
@PutMapping("/userRole")
public ResultVo modifyUserRoles(@RequestBody UserRoleVo userRoleVo) {
ResultVo resultVo = new ResultVo();
- userService.modifyRoles(userRoleVo);
+ userService.modifyRole(userRoleVo);
resultVo.setCode(0);
resultVo.setMsg("修改成功");
return resultVo;
}
+ @PutMapping("/userInfo")
+ public ResultVo changeUserInfo(@RequestBody UserInfoVo userInfoVo) {
+ ResultVo resultVo = new ResultVo();
+
+ userService.modifyUserInfo(userInfoVo);
+
+ resultVo.setCode(ResultVo.SUCCESS);
+ resultVo.setMsg("修改成功");
+
+ return resultVo;
+ }
+
+ @PutMapping("/pwd")
+ public ResultVo resetPwd(@RequestBody ResetPwdVo resetPwdVo) {
+ ResultVo resultVo = new ResultVo();
+
+ userService.resetPwd(resetPwdVo.getPhoneNumber());
+
+ resultVo.setCode(ResultVo.SUCCESS);
+ resultVo.setMsg("重置成功");
+
+ return resultVo;
+ }
+
+ @PostMapping("/user")
+ public ResultVo createUser(@RequestBody CreateUserVo createUserVo) {
+ ResultVo resultVo = new ResultVo();
+
+ userService.addUser(createUserVo);
+
+ resultVo.setCode(ResultVo.SUCCESS);
+ resultVo.setMsg("创建成功");
+
+ return resultVo;
+ }
+
+
+// @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;
+// }
+
}
diff --git a/src/main/java/com/example/survey/controller/advice/GlobalExceptionHandler.java b/src/main/java/com/example/survey/controller/advice/GlobalExceptionHandler.java
new file mode 100644
index 0000000..dfd3383
--- /dev/null
+++ b/src/main/java/com/example/survey/controller/advice/GlobalExceptionHandler.java
@@ -0,0 +1,76 @@
+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 org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+
+/**
+ * @author Pope
+ */
+@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;
+ }
+
+
+ @ExceptionHandler(RecordException.class)
+ public ResultVo handleRecordException(RecordException e) {
+ ResultVo resultVo = new ResultVo();
+
+ resultVo.setCode(ResultVo.FAILED);
+ resultVo.setMsg(e.getMessage());
+
+ return resultVo;
+ }
+
+ @ExceptionHandler(RespondentException.class)
+ public ResultVo handleRespondentException(RespondentException e) {
+ ResultVo resultVo = new ResultVo();
+
+ resultVo.setCode(ResultVo.FAILED);
+ resultVo.setMsg(e.getMessage());
+
+ return resultVo;
+ }
+
+ @ExceptionHandler(RoleException.class)
+ public ResultVo handleRoleException(RoleException e) {
+ ResultVo resultVo = new ResultVo();
+
+ resultVo.setCode(ResultVo.FAILED);
+ resultVo.setMsg(e.getMessage());
+
+ return resultVo;
+ }
+
+ @ExceptionHandler(DepartmentException.class)
+ public ResultVo handleDepartmentException(DepartmentException e) {
+ ResultVo resultVo = new ResultVo();
+
+ resultVo.setCode(ResultVo.FAILED);
+ resultVo.setMsg(e.getMessage());
+
+ return resultVo;
+ }
+
+ @ExceptionHandler(AuthException.class)
+ public ResultVo handleAuthException(AuthException e) {
+ ResultVo resultVo = new ResultVo();
+
+ resultVo.setCode(ResultVo.FAILED);
+ resultVo.setMsg(e.getMessage());
+
+ return resultVo;
+ }
+
+}
diff --git a/src/main/java/com/example/survey/dao/InvestigationRecordDao.java b/src/main/java/com/example/survey/dao/InvestigationRecordDao.java
index ecca6de..03d4bae 100644
--- a/src/main/java/com/example/survey/dao/InvestigationRecordDao.java
+++ b/src/main/java/com/example/survey/dao/InvestigationRecordDao.java
@@ -1,6 +1,7 @@
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;
@@ -21,7 +22,7 @@ public interface InvestigationRecordDao {
/**
* 根据筛选条件分页查询记录
*
- * @param investigatorPhone 调查人员电话号码
+ * @param userPhone 用户电话号码
* @param offset 偏移量
* @param number 数量
* @param state 调查记录状态
@@ -31,16 +32,16 @@ public interface InvestigationRecordDao {
* @param diseased 调查对象是否患病
* @return 筛选结果
*/
- List listLimitInvestigationRecord(String investigatorPhone, int offset, int number, String state, String idNumber, String version, String questionnaireNumber, Boolean diseased);
+ List listInvestigationRecordLimit(String userPhone, int offset, int number, String state, String idNumber, String version, String questionnaireNumber, Boolean diseased);
/**
* 根据流调人员电话号码查询对应状态的记录数量
*
- * @param investigatorPhone 流调人员电话号码
- * @param state 记录状态
+ * @param userPhone 流调人员电话号码
+ * @param state 记录状态
* @return 记录数量
*/
- long countInvestigationRecordByInvestigatorPhone(String investigatorPhone, String state);
+ long countInvestigationRecordByUserPhone(String userPhone, String state);
/**
* 更新记录状态
@@ -71,8 +72,17 @@ public interface InvestigationRecordDao {
* 是否存在当前状态调查记录
*
* @param idNumber 调查对象身份证号
- * @param states 调查记录状态
+ * @param states 调查记录状态
* @return 是否存在
*/
boolean existInvestigationRecord(String idNumber, String... states);
+
+
+ /**
+ * 更新所有匹配的调查记录的userPhone字段
+ *
+ * @param oldUserPhone 旧的userPhone字段
+ * @param newUserPhone 新的userPhone字段
+ */
+ void updateManyRecordUserPhone(String oldUserPhone, String newUserPhone);
}
diff --git a/src/main/java/com/example/survey/dao/InvestigatorDao.java b/src/main/java/com/example/survey/dao/InvestigatorDao.java
deleted file mode 100644
index 5942599..0000000
--- a/src/main/java/com/example/survey/dao/InvestigatorDao.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.example.survey.dao;
-
-import com.example.survey.entity.Investigator;
-
-/**
- * @author Pope
- */
-public interface InvestigatorDao {
-
- /**
- * 根据流调人员电话判断是否存在
- * @param phoneNumber 流调人员电话
- * @return 是否存在该电话
- */
- boolean existInvestigator(String phoneNumber);
-
- /**
- * 插入调查人员
- * @param investigator 调查人员
- * @return 是否插入成功
- */
- boolean insertInvestigator(Investigator investigator);
-
- /**
- * 根据流调人员电话号码查询流调人员
- * @param phoneNumber 流调人员电话号码
- * @return 对应的流调人员
- */
- Investigator selectInvestigator(String phoneNumber);
-
-}
diff --git a/src/main/java/com/example/survey/dao/RespondentDao.java b/src/main/java/com/example/survey/dao/RespondentDao.java
index 62372ff..d358459 100644
--- a/src/main/java/com/example/survey/dao/RespondentDao.java
+++ b/src/main/java/com/example/survey/dao/RespondentDao.java
@@ -1,7 +1,7 @@
package com.example.survey.dao;
-import com.example.survey.entity.Investigator;
import com.example.survey.entity.Respondent;
+import com.example.survey.entity.inner.AdministrativeArea;
import java.util.List;
@@ -19,12 +19,14 @@ public interface RespondentDao {
/**
* 根据流调人员电话号码分页查询待调查对象列表
- * @param investigatorPhone 流调人员电话号码
+ * @param userPhone 分配的人员电话号码
+ * @param state 状态
+ * @param administrativeArea 行政区划
* @param offset 偏移量
* @param number 大小
* @return 待调查对象列表
*/
- List listLimitRespondentByInvestigator(String investigatorPhone, int offset, int number);
+ List listRespondentLimit(String userPhone, String state, AdministrativeArea administrativeArea, int offset, int number);
/**
* 判断是否存在对应id的调查对象
@@ -34,9 +36,12 @@ public interface RespondentDao {
boolean existRespondent(String idNumber);
/**
- * 根据流调人员电话号码查询调查对象数量
- * @param investigatorPhone 流调人员电话号码
- * @return 对应流调人员id的调查对象数量
+ * 根绝筛选条件获取调查对象数量
+ *
+ * @param userPhone 分配的人员电话号码
+ * @param state 状态
+ * @param administrativeArea 行政区划
+ * @return 数量
*/
- long countRespondentBuInvestigatorPhone(String investigatorPhone);
+ long countRespondent(String userPhone, String state, AdministrativeArea administrativeArea);
}
diff --git a/src/main/java/com/example/survey/dao/RoleDao.java b/src/main/java/com/example/survey/dao/RoleDao.java
index 4e197a6..8e79575 100644
--- a/src/main/java/com/example/survey/dao/RoleDao.java
+++ b/src/main/java/com/example/survey/dao/RoleDao.java
@@ -1,8 +1,10 @@
package com.example.survey.dao;
import com.example.survey.entity.Role;
+import com.example.survey.enumeration.AuthEnum;
import java.util.List;
+import java.util.Set;
/**
* @author Pope
@@ -33,10 +35,20 @@ public interface RoleDao {
void deleteRole(String name);
/**
- * 更改用户角色
+ * 根据角色名模糊匹配角色
*
- * @param phoneNumber 电话号码
- * @param roleList 角色列表
+ * @param name 角色名 模糊匹配
+ * @param offset 偏移量
+ * @param limit 大小
+ * @return
*/
- void updateUserRoles(String phoneNumber, List roleList);
+ List listLimitRole(String name, int offset, int limit);
+
+ /**
+ * 更改角色的权限列表
+ *
+ * @param roleName 角色名
+ * @param authEnumSet 权限集合
+ */
+ void updateRole(String roleName, Set authEnumSet);
}
diff --git a/src/main/java/com/example/survey/dao/UserDao.java b/src/main/java/com/example/survey/dao/UserDao.java
index 5fc4737..e994a37 100644
--- a/src/main/java/com/example/survey/dao/UserDao.java
+++ b/src/main/java/com/example/survey/dao/UserDao.java
@@ -1,6 +1,11 @@
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;
/**
* @author Pope
@@ -11,11 +16,11 @@ public interface UserDao {
/**
* 根据用户名密码查询用户
*
- * @param username 用户名
- * @param password 密码
+ * @param phoneNumber 用户电话号码
+ * @param password 密码
* @return 对应用户
*/
- User selectUser(String username, String password);
+ User selectUser(String phoneNumber, String password);
/**
* 插入用户
@@ -24,4 +29,77 @@ public interface UserDao {
* @return 是否插入成功
*/
boolean insertUser(User user);
+
+ /**
+ * 根据筛选条件分页查询用户
+ *
+ * @param username 用户名 模糊匹配
+ * @param phoneNumber 电话号码 精确匹配
+ * @param offset 偏移量
+ * @param limit 数据量
+ * @return 用户信息dto
+ */
+ List listUserLimit(String username, String phoneNumber, int offset, int limit);
+
+ /**
+ * 根据电话号码判断是否存在用户
+ *
+ * @param phoneNumber 电话号码
+ * @return 是否存在用户
+ */
+ boolean existUser(String phoneNumber);
+
+ /**
+ * 删除用户
+ *
+ * @param phoneNumber 电话号码
+ */
+ void deleteUser(String phoneNumber);
+
+
+ /**
+ * 从含有该角色的用户的角色列表中删除该用户
+ *
+ * @param role 角色
+ */
+ void clearRole(Role role);
+
+ /**
+ * 更改用户角色
+ *
+ * @param phoneNumber 电话号码
+ * @param roleList 角色列表
+ */
+ void updateUserRole(String phoneNumber, List roleList);
+
+ /**
+ * 根据调查人员电话查询用户名
+ *
+ * @param investigatorPhone 调查人员电话号码
+ * @return 用户名
+ */
+ String selectUsername(String investigatorPhone);
+
+ /**
+ * 根据电话号码查询用户
+ *
+ * @param phoneNumber 电话
+ * @return 用户
+ */
+ User selectUser(String phoneNumber);
+
+
+ /**
+ * 重置密码
+ *
+ * @param phoneNumber 电话号码
+ */
+ void resetPwd(String phoneNumber);
+
+ /**
+ * 更新用户信息
+ *
+ * @param userInfoVo 用户信息
+ */
+ void modifyUser(UserInfoVo userInfoVo);
}
diff --git a/src/main/java/com/example/survey/dao/impl/DepartmentDaoImpl.java b/src/main/java/com/example/survey/dao/impl/DepartmentDaoImpl.java
index 6ee0cc6..c8a6397 100644
--- a/src/main/java/com/example/survey/dao/impl/DepartmentDaoImpl.java
+++ b/src/main/java/com/example/survey/dao/impl/DepartmentDaoImpl.java
@@ -2,16 +2,19 @@ package com.example.survey.dao.impl;
import com.example.survey.dao.DepartmentDao;
import com.example.survey.entity.Department;
+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 org.springframework.stereotype.Service;
/**
* @author Pope
*/
-@Service
+@Log4j2
+@Repository
public class DepartmentDaoImpl implements DepartmentDao {
@Autowired
@@ -22,6 +25,10 @@ public class DepartmentDaoImpl implements DepartmentDao {
try {
mongoTemplate.save(department);
}catch (Exception e){
+
+ log.error("部门插入失败");
+ log.error(e.getMessage());
+
return false;
}
return true;
diff --git a/src/main/java/com/example/survey/dao/impl/InvestigationRecordDaoImpl.java b/src/main/java/com/example/survey/dao/impl/InvestigationRecordDaoImpl.java
index c44ec89..bc4493b 100644
--- a/src/main/java/com/example/survey/dao/impl/InvestigationRecordDaoImpl.java
+++ b/src/main/java/com/example/survey/dao/impl/InvestigationRecordDaoImpl.java
@@ -3,6 +3,9 @@ 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;
@@ -16,6 +19,7 @@ import java.util.*;
/**
* @author Pope
*/
+@Log4j2
@Repository
public class InvestigationRecordDaoImpl implements InvestigationRecordDao {
@@ -27,17 +31,19 @@ public class InvestigationRecordDaoImpl implements InvestigationRecordDao {
try {
mongoTemplate.save(record);
} catch (Exception e) {
- //TODO 抛出相应异常
- return false;
+ log.error("调查记录插入失败");
+ log.error(e.getMessage());
+ throw new RecordException("已存在对应调查对象的调查记录");
}
return true;
}
@Override
- public List listLimitInvestigationRecord(String investigatorPhone, int offset, int number, String state, String idNumber, String version, String questionnaireNumber, Boolean diseased) {
- Criteria criteria = new Criteria();
+ public List listInvestigationRecordLimit(String investigatorPhone, int offset, int number, String state, String idNumber, String version, String questionnaireNumber, Boolean diseased) {
+ ;
- //流调人员id
+ Criteria criteria = new Criteria();
+ //流调人员电话号码
if (investigatorPhone != null) {
criteria.and("investigatorPhone").is(investigatorPhone);
}
@@ -46,7 +52,7 @@ public class InvestigationRecordDaoImpl implements InvestigationRecordDao {
if (state != null) {
criteria.and("state").is(state);
} else {
- criteria.and("state").in(InvestigationRecord.UNDER_REVIEW,InvestigationRecord.REVIEWED);
+ criteria.and("state").in(InvestigationRecord.UNDER_REVIEW, InvestigationRecord.REVIEWED);
}
//调查对象身份证号
@@ -75,8 +81,8 @@ public class InvestigationRecordDaoImpl implements InvestigationRecordDao {
}
@Override
- public long countInvestigationRecordByInvestigatorPhone(String investigatorPhone, String state) {
- Query query = new Query(Criteria.where("investigatorPhone").is(investigatorPhone).and("state").is(state));
+ 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);
}
@@ -108,5 +114,12 @@ public class InvestigationRecordDaoImpl implements InvestigationRecordDao {
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);
+ }
+
}
diff --git a/src/main/java/com/example/survey/dao/impl/InvestigatorDaoImpl.java b/src/main/java/com/example/survey/dao/impl/InvestigatorDaoImpl.java
deleted file mode 100644
index 7ee454a..0000000
--- a/src/main/java/com/example/survey/dao/impl/InvestigatorDaoImpl.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.example.survey.dao.impl;
-
-import com.example.survey.dao.InvestigatorDao;
-import com.example.survey.entity.Investigator;
-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;
-
-/**
- * @author Pope
- */
-@Repository
-public class InvestigatorDaoImpl implements InvestigatorDao {
-
- @Autowired
- MongoTemplate mongoTemplate;
-
- @Override
- public boolean existInvestigator(String phoneNumber) {
- Query query = new Query(Criteria.where("phoneNumber").is(phoneNumber));
- return mongoTemplate.exists(query, Investigator.class);
- }
-
- @Override
- public boolean insertInvestigator(Investigator investigator) {
- try {
- mongoTemplate.save(investigator);
- } catch (Exception e) {
- //TODO 抛出相应异常
- return false;
- }
- return true;
- }
-
- @Override
- public Investigator selectInvestigator(String phoneNumber) {
- Query query = new Query(Criteria.where("phoneNumber").is(phoneNumber));
- return mongoTemplate.findOne(query, Investigator.class);
- }
-}
diff --git a/src/main/java/com/example/survey/dao/impl/RespondentDaoImpl.java b/src/main/java/com/example/survey/dao/impl/RespondentDaoImpl.java
index 5c50ee9..89b3e8c 100644
--- a/src/main/java/com/example/survey/dao/impl/RespondentDaoImpl.java
+++ b/src/main/java/com/example/survey/dao/impl/RespondentDaoImpl.java
@@ -2,6 +2,9 @@ package com.example.survey.dao.impl;
import com.example.survey.dao.RespondentDao;
import com.example.survey.entity.Respondent;
+import com.example.survey.entity.inner.AdministrativeArea;
+import com.example.survey.exception.RespondentException;
+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;
@@ -13,6 +16,7 @@ import java.util.List;
/**
* @author Pope
*/
+@Log4j2
@Repository
public class RespondentDaoImpl implements RespondentDao {
@@ -24,14 +28,37 @@ public class RespondentDaoImpl implements RespondentDao {
try {
mongoTemplate.save(respondent);
} catch (Exception e) {
- return false;
+ log.error("调查对象插入失败");
+ log.error(e.getMessage());
+ throw new RespondentException("调查对象已存在");
}
return true;
}
@Override
- public List listLimitRespondentByInvestigator(String investigatorPhone, int offset, int number) {
- Query query = new Query(Criteria.where("investigatorPhone").is(investigatorPhone)).skip(offset).limit(number);
+ public List listRespondentLimit(String userPhone, String state, AdministrativeArea administrativeArea, int offset, int number) {
+ Criteria criteria = new Criteria();
+
+ if (userPhone != null) {
+ criteria.and("userPhone").is(userPhone);
+ }
+
+ if (state != null) {
+ criteria.and("state").is(state);
+ }
+
+ 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).skip(offset).limit(number);
return mongoTemplate.find(query, Respondent.class);
}
@@ -42,8 +69,31 @@ public class RespondentDaoImpl implements RespondentDao {
}
@Override
- public long countRespondentBuInvestigatorPhone(String investigatorPhone) {
- Query query = new Query(Criteria.where("investigatorPhone").is(investigatorPhone));
+ public long countRespondent(String userPhone, String state, AdministrativeArea administrativeArea) {
+ Criteria criteria = new Criteria();
+
+ if (userPhone != null) {
+ criteria.and("userPhone").is(userPhone);
+ }
+
+ if (state != null) {
+ criteria.and("state").is(state);
+ }
+
+ 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);
return mongoTemplate.count(query, Respondent.class);
}
+
+
}
diff --git a/src/main/java/com/example/survey/dao/impl/RoleDaoImpl.java b/src/main/java/com/example/survey/dao/impl/RoleDaoImpl.java
index 770f491..559c660 100644
--- a/src/main/java/com/example/survey/dao/impl/RoleDaoImpl.java
+++ b/src/main/java/com/example/survey/dao/impl/RoleDaoImpl.java
@@ -3,19 +3,25 @@ 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.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;
/**
* @author Pope
*/
-@Service
+@Log4j2
+@Repository
public class RoleDaoImpl implements RoleDao {
@Autowired
private MongoTemplate mongoTemplate;
@@ -25,7 +31,9 @@ public class RoleDaoImpl implements RoleDao {
try {
mongoTemplate.save(role);
} catch (Exception e) {
- return false;
+ log.error("权限插入失败");
+ log.error(e.getMessage());
+ throw new RoleException("已存在权限");
}
return true;
}
@@ -39,14 +47,28 @@ public class RoleDaoImpl implements RoleDao {
@Override
public void deleteRole(String name) {
Query query = new Query(Criteria.where("name").is(name));
- mongoTemplate.remove(query);
+ mongoTemplate.remove(query, Role.class);
+ }
+
+
+ @Override
+ public List listLimitRole(String name, int offset, int limit) {
+ Criteria criteria = new Criteria();
+ if (name != null) {
+ criteria.and("name").regex(name);
+ }
+ Query query = new Query(criteria).skip(offset).limit(limit);
+ return mongoTemplate.find(query, Role.class);
}
@Override
- public void updateUserRoles(String phoneNumber, List roleList) {
- Query query = new Query(Criteria.where("phoneNumber").is(phoneNumber));
- Update update = new Update()
- .set("roleList", roleList);
- mongoTemplate.updateFirst(query, update, User.class);
+ public void updateRole(String roleName, Set authEnumSet) {
+ Query query = new Query(Criteria.where("name").is(roleName));
+ Role role = mongoTemplate.findOne(query, Role.class);
+ if(role == null){
+ throw new RoleException("角色不存在");
+ }
+ role.setAuthoritySet(authEnumSet);
+ mongoTemplate.save(role);
}
}
diff --git a/src/main/java/com/example/survey/dao/impl/UserDaoImpl.java b/src/main/java/com/example/survey/dao/impl/UserDaoImpl.java
index 2e86ed9..0b2cd8c 100644
--- a/src/main/java/com/example/survey/dao/impl/UserDaoImpl.java
+++ b/src/main/java/com/example/survey/dao/impl/UserDaoImpl.java
@@ -1,35 +1,148 @@
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.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;
+
/**
* @author Pope
*/
-@Service
+@Log4j2
+@Repository
public class UserDaoImpl implements UserDao {
@Autowired
private MongoTemplate mongoTemplate;
@Override
- public User selectUser(String username, String password) {
- Query query = new Query(Criteria.where("phoneNumber").is(username).and("password").is(password));
- return mongoTemplate.findOne(query,User.class);
+ 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){
- return false;
+ } catch (Exception e) {
+ log.error("用户插入失败");
+ log.error(e.getMessage());
+ throw new UserException("已存在用户");
}
return true;
}
+
+ @Override
+ public List listUserLimit(String username, String phoneNumber, int offset, int limit) {
+ Criteria criteria = new Criteria();
+
+ //用户名模糊查询
+ if (username != null) {
+ criteria.and("username").regex(username);
+ }
+
+ //电话号码精确查询
+ if (phoneNumber != null) {
+ criteria.and("phoneNumber").is(phoneNumber);
+ }
+
+ Query query = new Query(criteria).skip(offset).limit(limit);
+ return mongoTemplate.find(query, User.class);
+ }
+
+ @Override
+ public boolean existUser(String phoneNumber) {
+ Query query = new Query(Criteria.where("phoneNumber").is(phoneNumber));
+
+ return mongoTemplate.exists(query, User.class);
+ }
+
+ @Override
+ public void deleteUser(String phoneNumber) {
+ Query query = new Query(Criteria.where("phoneNumber").is(phoneNumber));
+ 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())));
+ List users = mongoTemplate.find(query, User.class);
+ for (User user : users) {
+ List roleList = user.getRoleList();
+ Iterator it = roleList.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);
+ mongoTemplate.updateFirst(userQuery, update, User.class);
+ }
+ }
+
+ @Override
+ public void updateUserRole(String phoneNumber, List 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));
+ 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);
+
+ }
+
+ @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);
+ }
+
+
}
diff --git a/src/main/java/com/example/survey/dto/LoginDto.java b/src/main/java/com/example/survey/dto/LoginDto.java
index 7cd65cb..f9c407a 100644
--- a/src/main/java/com/example/survey/dto/LoginDto.java
+++ b/src/main/java/com/example/survey/dto/LoginDto.java
@@ -2,6 +2,8 @@ package com.example.survey.dto;
import com.example.survey.entity.Department;
import com.example.survey.entity.Role;
+import com.example.survey.entity.inner.AdministrativeArea;
+import com.example.survey.vo.RoleVo;
import lombok.*;
import java.util.List;
@@ -16,6 +18,10 @@ import java.util.List;
@AllArgsConstructor
public class LoginDto {
private String token;
- private List roleList;
+ private String username;
+ private String idNumber;
+ private String phoneNumber;
+ private List roleList;
private List departmentList;
+ private AdministrativeArea administrativeArea;
}
diff --git a/src/main/java/com/example/survey/dto/RespondentDto.java b/src/main/java/com/example/survey/dto/RespondentDto.java
index 555c996..98f620a 100644
--- a/src/main/java/com/example/survey/dto/RespondentDto.java
+++ b/src/main/java/com/example/survey/dto/RespondentDto.java
@@ -1,7 +1,8 @@
package com.example.survey.dto;
-import com.example.survey.entity.Investigator;
+import com.example.survey.dto.inner.RelevantUserInfo;
import com.example.survey.entity.Respondent;
+import com.example.survey.entity.User;
import lombok.*;
/**
@@ -35,9 +36,9 @@ public class RespondentDto {
private String msg;
/**
- * 分配的调查人员
+ * 分配的人员
*/
- private Investigator investigator;
+ private RelevantUserInfo relevantUserInfo;
/**
* 是否发病
@@ -49,11 +50,11 @@ public class RespondentDto {
*/
private String gender;
- public RespondentDto(Respondent respondent, Investigator investigator){
+ public RespondentDto(Respondent respondent, User user){
this.idNumber = respondent.getIdNumber();
this.name = respondent.getName();
this.phoneNumber = respondent.getPhoneNumber();
- this.investigator = investigator;
+ this.relevantUserInfo = new RelevantUserInfo(user);
this.diseased = respondent.isDiseased();
this.gender = respondent.getGender();
this.msg = respondent.getMsg();
diff --git a/src/main/java/com/example/survey/dto/UserDto.java b/src/main/java/com/example/survey/dto/UserDto.java
new file mode 100644
index 0000000..d31933f
--- /dev/null
+++ b/src/main/java/com/example/survey/dto/UserDto.java
@@ -0,0 +1,35 @@
+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 roleList;
+ private List 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();
+ }
+}
diff --git a/src/main/java/com/example/survey/dto/inner/RelevantUserInfo.java b/src/main/java/com/example/survey/dto/inner/RelevantUserInfo.java
new file mode 100644
index 0000000..54cfdc3
--- /dev/null
+++ b/src/main/java/com/example/survey/dto/inner/RelevantUserInfo.java
@@ -0,0 +1,35 @@
+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();
+ }
+}
diff --git a/src/main/java/com/example/survey/entity/Department.java b/src/main/java/com/example/survey/entity/Department.java
index 77356f2..d8d5e98 100644
--- a/src/main/java/com/example/survey/entity/Department.java
+++ b/src/main/java/com/example/survey/entity/Department.java
@@ -1,6 +1,7 @@
package com.example.survey.entity;
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;
@@ -19,9 +20,9 @@ import java.util.List;
public class Department {
/**
- * 唯一索引
+ * id
*/
- private String uniqueIndex;
+ private ObjectId id;
/**
* 部门名
@@ -31,6 +32,7 @@ public class Department {
/**
* 子部门
*/
+ @DBRef
private List children;
/**
diff --git a/src/main/java/com/example/survey/entity/InvestigationRecord.java b/src/main/java/com/example/survey/entity/InvestigationRecord.java
index b626ab0..0a29e45 100644
--- a/src/main/java/com/example/survey/entity/InvestigationRecord.java
+++ b/src/main/java/com/example/survey/entity/InvestigationRecord.java
@@ -3,12 +3,12 @@ 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.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
/**
* @author Pope
@@ -58,6 +58,11 @@ public class InvestigationRecord {
public static final String WOMAN = "女";
+ /**
+ * id
+ */
+ private ObjectId id;
+
/**
* 问卷编号
*/
@@ -230,7 +235,7 @@ public class InvestigationRecord {
* 外键
*/
@Indexed
- private String investigatorPhone;
+ private String userPhone;
/**
* 调查日期
@@ -244,9 +249,14 @@ public class InvestigationRecord {
private List tempHistoryList;
/**
- * 居旅史
+ * 居住史
*/
- private List liveAndTravelHistoryList;
+ private List liveHistoryList;
+
+ /**
+ * 旅行史
+ */
+ private List travelHistoryList;
/**
* 状态信息
@@ -269,62 +279,61 @@ public class InvestigationRecord {
* 密切接触者(身份证)
* 外键
*/
- private List closeContactList;
+ @DBRef
+ private List closeContactList;
/**
* 上级感染者
*/
private List superiorInfectedIndividualList;
-
/**
- * 生成提交待审核的记录
- * @param vo 调查记录vo
+ * 存放一些url
*/
- public static InvestigationRecord getInvestigationRecord(InvestigationRecordVo vo) {
- InvestigationRecord record = new InvestigationRecord();
- record.questionnaireNumber = vo.getQuestionnaireNumber();
- record.idNumber = vo.getIdNumber();
- record.name = vo.getName();
- record.gender = vo.getGender();
- record.overseasCase = vo.isOverseasCase();
- record.diseased = vo.isDiseased();
- record.entryExperience = vo.getEntryExperience();
- record.wayOfBeingDiscovered = vo.getWayOfBeingDiscovered();
- record.dateOfAdmission = vo.getDateOfAdmission();
- record.symptomAndSign = vo.getSymptomAndSign();
- record.existComplication = vo.isExistComplication();
- record.complication = vo.getComplication();
- record.maxTemp = vo.getMaxTemp();
- record.existImagingFeatureOfPneumonia = vo.isExistImagingFeatureOfPneumonia();
- record.testDate = vo.getTestDate();
- record.dateOfDischarge = vo.getDateOfDischarge();
- record.specificOccupation = vo.getSpecificOccupation();
- record.otherSpecificOccupation = vo.getOtherSpecificOccupation();
- record.workInformation = vo.getWorkInformation();
- record.otherWorkInformation = vo.getOtherWorkInformation();
- record.pregnant = vo.isPregnant();
- record.pregnantWeek = vo.getPregnantWeek();
- record.medicalHistory = vo.getMedicalHistory();
- record.medicalHistoryDetail = vo.getMedicalHistoryDetail();
- record.nearSeriousRegion = vo.isNearSeriousRegion();
- record.contactWithSeriousRegionPatients = vo.isContactWithSeriousRegionPatients();
- record.contactWithConfirmedCase = vo.isContactWithConfirmedCase();
- record.aggregationDisease = vo.isAggregationDisease();
- record.detectionList = vo.getDetectionList();
- record.investigationCompany = vo.getInvestigationCompany();
- record.investigatorPhone = vo.getInvestigatorPhone();
- record.investigationDate = vo.getInvestigationDate();
- record.tempHistoryList = vo.getTempHistoryList();
- record.liveAndTravelHistoryList = vo.getLiveAndTravelHistoryList();
+ private Map urlMap;
- record.closeContactList = new ArrayList<>();
- record.superiorInfectedIndividualList = new ArrayList<>();
- return record;
+ 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();
}
-
}
diff --git a/src/main/java/com/example/survey/entity/Investigator.java b/src/main/java/com/example/survey/entity/Investigator.java
deleted file mode 100644
index 77b16af..0000000
--- a/src/main/java/com/example/survey/entity/Investigator.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.example.survey.entity;
-
-import lombok.*;
-import org.springframework.data.mongodb.core.index.Indexed;
-import org.springframework.data.mongodb.core.mapping.Document;
-
-/**
- * @author Pope
- * 调查人员表
- */
-@Getter
-@Setter
-@ToString
-@NoArgsConstructor
-@AllArgsConstructor
-@Document(collection = "investigator")
-public class Investigator {
-
- /**
- * 身份证号
- */
-
- private String idNumber;
-
- /**
- * 姓名
- */
- private String name;
-
- /**
- * 电话号码
- */
- @Indexed(unique = true)
- private String phoneNumber;
-
-}
diff --git a/src/main/java/com/example/survey/entity/Respondent.java b/src/main/java/com/example/survey/entity/Respondent.java
index bdb6c4c..f128323 100644
--- a/src/main/java/com/example/survey/entity/Respondent.java
+++ b/src/main/java/com/example/survey/entity/Respondent.java
@@ -1,6 +1,11 @@
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 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.Document;
@@ -17,13 +22,10 @@ import org.springframework.data.mongodb.core.mapping.Document;
public class Respondent {
/**
- * 性别为男
+ * id
*/
- public static final String MAN = "男";
- /**
- * 性别为女
- */
- public static final String WOMAN = "女";
+ @Id
+ private ObjectId id;
/**
* 身份证号
@@ -50,7 +52,7 @@ public class Respondent {
* 分配的调查人员
*/
@Indexed
- private String investigatorPhone;
+ private String userPhone;
/**
* 是否发病
@@ -62,7 +64,25 @@ public class Respondent {
*/
private String gender;
+ /**
+ * 行政区划
+ */
+ private AdministrativeArea administrativeArea;
+ /**
+ * 状态
+ */
+ 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();
+ }
}
diff --git a/src/main/java/com/example/survey/entity/Role.java b/src/main/java/com/example/survey/entity/Role.java
index 3b5f681..645edf7 100644
--- a/src/main/java/com/example/survey/entity/Role.java
+++ b/src/main/java/com/example/survey/entity/Role.java
@@ -2,6 +2,8 @@ package com.example.survey.entity;
import com.example.survey.enumeration.AuthEnum;
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.Document;
@@ -18,6 +20,12 @@ import java.util.Set;
@Document(collection = "role")
public class Role {
+ /**
+ * id
+ */
+ @Id
+ private ObjectId id;
+
/**
* 角色名
*/
diff --git a/src/main/java/com/example/survey/entity/User.java b/src/main/java/com/example/survey/entity/User.java
index 0ef8a81..acd769e 100644
--- a/src/main/java/com/example/survey/entity/User.java
+++ b/src/main/java/com/example/survey/entity/User.java
@@ -1,14 +1,15 @@
package com.example.survey.entity;
-import com.example.survey.vo.SignupVo;
+import com.example.survey.entity.inner.AdministrativeArea;
+import com.example.survey.vo.CreateUserVo;
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.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
/**
* @author Pope
@@ -21,6 +22,12 @@ import java.util.Set;
@Document(collection = "user")
public class User {
+ /**
+ * id
+ */
+ @Id
+ private ObjectId id;
+
/**
* 用户名
*/
@@ -36,6 +43,11 @@ public class User {
*/
private String idNumber;
+ /**
+ * 行政区划
+ */
+ private AdministrativeArea administrativeArea;
+
/**
* 手机号
*/
@@ -45,20 +57,23 @@ public class User {
/**
* 一个人可以拥有多个角色
*/
+ @DBRef
private List roleList;
/**
* 一个人所属的部门
*/
+ @DBRef
private List departmentList;
- public User(SignupVo vo){
- this.username = vo.getUsername();
- this.password = vo.getPassword();
- this.phoneNumber = vo.getPhoneNumber();
- this.roleList = new ArrayList<>();
- this.departmentList = new ArrayList<>();
+ public User(CreateUserVo vo) {
+ username = vo.getUsername();
+ password = vo.getPassword();
+ idNumber = vo.getIdNumber();
+ phoneNumber = vo.getPhoneNumber();
+ roleList = new LinkedList<>();
+ departmentList = new LinkedList<>();
}
}
diff --git a/src/main/java/com/example/survey/entity/inner/AdministrativeArea.java b/src/main/java/com/example/survey/entity/inner/AdministrativeArea.java
new file mode 100644
index 0000000..e8b1063
--- /dev/null
+++ b/src/main/java/com/example/survey/entity/inner/AdministrativeArea.java
@@ -0,0 +1,26 @@
+package com.example.survey.entity.inner;
+
+import lombok.*;
+
+/**
+ * @author Pope
+ */
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+public class AdministrativeArea {
+ /**
+ * 省
+ */
+ private String province;
+ /**
+ * 市
+ */
+ private String city;
+ /**
+ * 县
+ */
+ private String county;
+}
diff --git a/src/main/java/com/example/survey/entity/inner/LiveAndTravelHistory.java b/src/main/java/com/example/survey/entity/inner/LiveHistory.java
similarity index 77%
rename from src/main/java/com/example/survey/entity/inner/LiveAndTravelHistory.java
rename to src/main/java/com/example/survey/entity/inner/LiveHistory.java
index 68f2203..3849dd6 100644
--- a/src/main/java/com/example/survey/entity/inner/LiveAndTravelHistory.java
+++ b/src/main/java/com/example/survey/entity/inner/LiveHistory.java
@@ -9,19 +9,13 @@ import java.util.List;
/**
* @author Pope
* 居旅史
- * TODO 完善类
*/
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
-public class LiveAndTravelHistory {
-
- /**
- * 居住史或者旅行史
- */
- private List type;
+public class LiveHistory {
/**
* 起始时间
@@ -38,7 +32,7 @@ public class LiveAndTravelHistory {
/**
* 地点
*/
- private String location;
+ private Location location;
/**
* 事件
diff --git a/src/main/java/com/example/survey/entity/inner/Location.java b/src/main/java/com/example/survey/entity/inner/Location.java
new file mode 100644
index 0000000..cc3170f
--- /dev/null
+++ b/src/main/java/com/example/survey/entity/inner/Location.java
@@ -0,0 +1,30 @@
+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;
+
+}
diff --git a/src/main/java/com/example/survey/entity/inner/OperationInformation.java b/src/main/java/com/example/survey/entity/inner/OperationInformation.java
index aaaadd1..9830156 100644
--- a/src/main/java/com/example/survey/entity/inner/OperationInformation.java
+++ b/src/main/java/com/example/survey/entity/inner/OperationInformation.java
@@ -20,7 +20,7 @@ public class OperationInformation {
/**
* 修改操作
*/
- public static final String CHANGE = "修改";
+ public static final String MODIFY = "修改";
/**
* 删除操作
@@ -50,7 +50,7 @@ public class OperationInformation {
/**
* 操作者id
*/
- private String investigatorPhone;
+ private String userPhone;
/**
* 版本信息
@@ -66,4 +66,48 @@ public class OperationInformation {
* 操作结果
*/
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;
+ }
}
diff --git a/src/main/java/com/example/survey/entity/inner/TravelHistory.java b/src/main/java/com/example/survey/entity/inner/TravelHistory.java
new file mode 100644
index 0000000..b18f21c
--- /dev/null
+++ b/src/main/java/com/example/survey/entity/inner/TravelHistory.java
@@ -0,0 +1,43 @@
+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;
+}
diff --git a/src/main/java/com/example/survey/enumeration/AuthEnum.java b/src/main/java/com/example/survey/enumeration/AuthEnum.java
index 9698c15..b236145 100644
--- a/src/main/java/com/example/survey/enumeration/AuthEnum.java
+++ b/src/main/java/com/example/survey/enumeration/AuthEnum.java
@@ -1,6 +1,8 @@
package com.example.survey.enumeration;
import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Set;
/**
@@ -12,24 +14,33 @@ public enum AuthEnum {
/**
* 管理员权限,可以访问所有接口
*/
- ADMIN(0, "管理员", new HashSet() {{
+ ADMIN("管理员", new HashSet() {{
add("/investigator/investigator : POST");
add("/investigationRecord/underReviewRecord : GET");
add("/investigationRecord/underReviewRecordCount : GET");
add("/investigationRecord/investigationRecord : POST");
add("/investigationRecord/investigationRecord : PUT");
add("/investigationRecord/underReviewRecord : PUT");
+ add("/investigationRecord/record2word : GET");
add("/respondent/respondent : POST");
add("/respondent/respondent : GET");
add("/user/userRole : PUT");
+ add("/user/user : GET");
+ add("/user/user : DELETE");
+ add("/user/user : POST");
add("/role/role : POST");
-
+ add("/role/role : GET");
+ add("/role/role : DELETE");
+ add("/role/role : PUT");
+ add("/role/authList : GET");
+ add("/user/userInfo : PUT");
+ add("/user/pwd : PUT");
}}),
/**
* 查询调查记录的权限
*/
- RETRIEVE_RECORD(1, "查询调查记录的权限", new HashSet() {{
+ RETRIEVE_RECORD("查询调查记录的权限", new HashSet() {{
add("/investigationRecord/underReviewRecord : GET");
add("/investigationRecord/underReviewRecordCount : GET");
}}),
@@ -37,92 +48,132 @@ public enum AuthEnum {
/**
* 提交记录的权限
*/
- CREATE_RECORD(2, "提交调查记录权限", new HashSet() {{
+ CREATE_RECORD("提交调查记录权限", new HashSet() {{
add("/investigationRecord/investigationRecord : POST");
}}),
/**
* 修改调查记录信息的权限
*/
- UPDATE_RECORD(3, "修改调查记录权限", new HashSet() {{
+ UPDATE_RECORD("修改调查记录权限", new HashSet() {{
add("/investigationRecord/investigationRecord : PUT");
}}),
/**
* 审核调查记录权限
*/
- REVIEW_RECORD(4, "审核调查记录权限", new HashSet() {{
+ REVIEW_RECORD("审核调查记录权限", new HashSet() {{
add("/investigationRecord/underReviewRecord : PUT");
}}),
/**
* 删除调查记录权限
*/
- DELETE_RECORD(5, "删除调查记录权限", new HashSet() {{
+ DELETE_RECORD("删除调查记录权限", new HashSet() {{
}}),
/**
* 分析调查记录的权限
*/
- ANALYSE_RECORD(6, "分析调查记录权限", new HashSet() {{
+ ANALYSE_RECORD("分析调查记录权限", new HashSet() {{
}}),
/**
* 可以增删改流调人员信息
*/
- CUD_INVESTIGATOR(7, "增删改流调人员信息的权限", new HashSet() {{
+ CUD_INVESTIGATOR("增删改流调人员信息的权限", new HashSet() {{
}}),
/**
* 查询流调人员信息
*/
- RETRIEVE_INVESTIGATOR(8, "查询流调人员信息的权限", new HashSet() {{
+ RETRIEVE_INVESTIGATOR("查询流调人员信息的权限", new HashSet() {{
}}),
/**
* 增删改调查对象信息的权限
*/
- CUD_RESPONDENT(9, "增删改调查对象信息的权限", new HashSet() {{
+ CUD_RESPONDENT("增删改调查对象信息的权限", new HashSet() {{
add("/respondent/respondent : POST");
}}),
/**
* 查询调查对象信息的权限
*/
- RETRIEVE_RESPONDENT(10, "查询调查对象信息的权限", new HashSet() {{
+ RETRIEVE_RESPONDENT("查询调查对象信息的权限", new HashSet() {{
add("/respondent/respondent : GET");
+ }}),
+
+ /**
+ * 查看用户的权限
+ */
+ RETRIEVE_USER("查看用户的权限", new HashSet() {{
+ add("/user/user : GET");
+ }}),
+
+ /**
+ * 删除用户的权限
+ */
+ DELETE_USER("删除用户的权限", new HashSet() {{
+ add("/user/user : DELETE");
+ }}),
+
+ /**
+ * 查看角色的权限
+ */
+ RETRIEVE_ROLE("查看角色的权限", new HashSet() {{
+ add("/role/role : GET");
+ }}),
+
+ /**
+ * 删除角色的权限
+ */
+ DELETE_ROLE("删除角色的权限", new HashSet() {{
+ add("/role/role : DELETE");
+ }}),
+
+ /**
+ * 修改角色的权限
+ */
+ UPDATE_ROLE("修改角色的权限", new HashSet() {{
+ add("/role/role : PUT");
+ }}),
+
+ /**
+ * 查看权限列表
+ */
+ LIST_AUTHORITY("查看权限列表的权限", new HashSet() {{
+ add("/role/authList : GET");
}});
- private int code;
private String name;
private Set routes;
- AuthEnum(int code, String name, Set routes) {
- this.code = code;
+ AuthEnum(String name, Set routes) {
this.name = name;
this.routes = routes;
}
- public static AuthEnum getRoleEnum(int code) {
+ public static AuthEnum getRoleEnum(String name) {
for (AuthEnum value : AuthEnum.values()) {
- if (value.code == code) {
+ if (value.name.equals(name)) {
return value;
}
}
return null;
}
- public int getCode() {
- return code;
- }
-
- public void setCode(int code) {
- this.code = code;
+ public static List getNameList() {
+ List res = new LinkedList<>();
+ for (AuthEnum value : AuthEnum.values()) {
+ res.add(value.name);
+ }
+ return res;
}
public String getName() {
diff --git a/src/main/java/com/example/survey/enumeration/GenderEnum.java b/src/main/java/com/example/survey/enumeration/GenderEnum.java
new file mode 100644
index 0000000..f5ebd44
--- /dev/null
+++ b/src/main/java/com/example/survey/enumeration/GenderEnum.java
@@ -0,0 +1,26 @@
+package com.example.survey.enumeration;
+
+/**
+ * @author Pope
+ */
+public enum GenderEnum {
+ /**
+ * 男性
+ */
+ MAN("男"),
+
+ /**
+ * 女性
+ */
+ WOMAN("女");
+
+ private final String value;
+
+ GenderEnum(String gender) {
+ this.value = gender;
+ }
+
+ public String getValue() {
+ return value;
+ }
+}
diff --git a/src/main/java/com/example/survey/enumeration/RespondentStateEnum.java b/src/main/java/com/example/survey/enumeration/RespondentStateEnum.java
new file mode 100644
index 0000000..9680eef
--- /dev/null
+++ b/src/main/java/com/example/survey/enumeration/RespondentStateEnum.java
@@ -0,0 +1,26 @@
+package com.example.survey.enumeration;
+
+/**
+ * @author Pope
+ */
+public enum RespondentStateEnum {
+ /**
+ * 已调查状态
+ */
+ INVESTIGATED("已调查"),
+ /**
+ * 未调查状态
+ */
+ NOT_INVESTIGATED("未调查");
+
+
+ private final String value;
+
+ RespondentStateEnum(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+}
diff --git a/src/main/java/com/example/survey/exception/AuthException.java b/src/main/java/com/example/survey/exception/AuthException.java
new file mode 100644
index 0000000..6e26740
--- /dev/null
+++ b/src/main/java/com/example/survey/exception/AuthException.java
@@ -0,0 +1,10 @@
+package com.example.survey.exception;
+
+/**
+ * @author Pope
+ */
+public class AuthException extends RuntimeException{
+ public AuthException(String message) {
+ super(message);
+ }
+}
diff --git a/src/main/java/com/example/survey/exception/DepartmentException.java b/src/main/java/com/example/survey/exception/DepartmentException.java
new file mode 100644
index 0000000..bad820e
--- /dev/null
+++ b/src/main/java/com/example/survey/exception/DepartmentException.java
@@ -0,0 +1,10 @@
+package com.example.survey.exception;
+
+/**
+ * @author Pope
+ */
+public class DepartmentException extends RuntimeException{
+ public DepartmentException(String message) {
+ super(message);
+ }
+}
diff --git a/src/main/java/com/example/survey/exception/RecordException.java b/src/main/java/com/example/survey/exception/RecordException.java
new file mode 100644
index 0000000..b68543f
--- /dev/null
+++ b/src/main/java/com/example/survey/exception/RecordException.java
@@ -0,0 +1,11 @@
+package com.example.survey.exception;
+
+/**
+ * @author Pope
+ */
+public class RecordException extends RuntimeException{
+
+ public RecordException(String message) {
+ super(message);
+ }
+}
diff --git a/src/main/java/com/example/survey/exception/RespondentException.java b/src/main/java/com/example/survey/exception/RespondentException.java
new file mode 100644
index 0000000..a7cd292
--- /dev/null
+++ b/src/main/java/com/example/survey/exception/RespondentException.java
@@ -0,0 +1,10 @@
+package com.example.survey.exception;
+
+/**
+ * @author Pope
+ */
+public class RespondentException extends RuntimeException{
+ public RespondentException(String message) {
+ super(message);
+ }
+}
diff --git a/src/main/java/com/example/survey/exception/RoleException.java b/src/main/java/com/example/survey/exception/RoleException.java
new file mode 100644
index 0000000..e88ce80
--- /dev/null
+++ b/src/main/java/com/example/survey/exception/RoleException.java
@@ -0,0 +1,10 @@
+package com.example.survey.exception;
+
+/**
+ * @author Pope
+ */
+public class RoleException extends RuntimeException{
+ public RoleException(String msg){
+ super(msg);
+ }
+}
diff --git a/src/main/java/com/example/survey/exception/UserException.java b/src/main/java/com/example/survey/exception/UserException.java
new file mode 100644
index 0000000..dff6c5b
--- /dev/null
+++ b/src/main/java/com/example/survey/exception/UserException.java
@@ -0,0 +1,10 @@
+package com.example.survey.exception;
+
+/**
+ * @author Pope
+ */
+public class UserException extends RuntimeException{
+ public UserException(String msg){
+ super(msg);
+ }
+}
diff --git a/src/main/java/com/example/survey/service/InvestigationRecordService.java b/src/main/java/com/example/survey/service/InvestigationRecordService.java
index 1a933ea..f84bb17 100644
--- a/src/main/java/com/example/survey/service/InvestigationRecordService.java
+++ b/src/main/java/com/example/survey/service/InvestigationRecordService.java
@@ -4,6 +4,7 @@ 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;
/**
@@ -22,7 +23,7 @@ public interface InvestigationRecordService {
/**
* 根据筛选条件查询调查记录
*
- * @param investigatorPhone 流调人员电话号码
+ * @param userPhone 用户电话号码
* @param currentPage 当前页数
* @param pageSize 页大小
* @param state 状态
@@ -32,15 +33,15 @@ public interface InvestigationRecordService {
* @param diseased 是否患病
* @return 调查记录列表
*/
- List listUnderReviewRecordPageByInvestigationPhone(String investigatorPhone, int currentPage, int pageSize, String state, String idNumber, String version, String questionnaireNumber, Boolean diseased);
+ List listUnderReviewRecordLimit(String userPhone, int currentPage, int pageSize, String state, String idNumber, String version, String questionnaireNumber, Boolean diseased);
/**
* 根据流调人员电话号码查询待审核记录数量
*
- * @param investigatorPhone 流调人员id
+ * @param userPhone 用户电话号码
* @return 记录数量
*/
- long countUnderReviewRecordByInvestigatorPhone(String investigatorPhone);
+ long countUnderReviewRecord(String userPhone);
/**
* 提交修改后的调查记录,等待审核
@@ -53,8 +54,16 @@ public interface InvestigationRecordService {
/**
* 审核待调查记录
*
- * @param vo 审核信息
+ * @param reviewVo 审核信息
* @return 是否成功
*/
- boolean reviewRecord(ReviewVo vo);
+ boolean reviewRecord(ReviewVo reviewVo);
+
+ /**
+ * 导出为word
+ *
+ * @param idNumber 调查对象身份证号
+ * @param response 响应
+ */
+ void export2Word(String idNumber, HttpServletResponse response);
}
diff --git a/src/main/java/com/example/survey/service/InvestigatorService.java b/src/main/java/com/example/survey/service/InvestigatorService.java
deleted file mode 100644
index 80d6bbe..0000000
--- a/src/main/java/com/example/survey/service/InvestigatorService.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.example.survey.service;
-
-import com.example.survey.entity.Investigator;
-
-/**
- * @author Pope
- */
-public interface InvestigatorService {
-
-
- /**
- * 创建调查人员
- * @param investigator 调查人员
- * @return 是否创建成功
- */
- boolean addInvestigator(Investigator investigator);
-}
diff --git a/src/main/java/com/example/survey/service/RespondentService.java b/src/main/java/com/example/survey/service/RespondentService.java
index 4c3085b..25f5c20 100644
--- a/src/main/java/com/example/survey/service/RespondentService.java
+++ b/src/main/java/com/example/survey/service/RespondentService.java
@@ -2,6 +2,8 @@ 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 java.util.List;
@@ -11,24 +13,31 @@ import java.util.List;
public interface RespondentService {
/**
* 创建待调查对象
- * @param respondent 待调查对象
+ *
+ * @param createRespondentVo 待调查对象信息
* @return 是否创建成功
*/
- boolean addRespondent(Respondent respondent);
+ boolean addRespondent(CreateRespondentVo createRespondentVo);
/**
* 根据流调人员电话号码分页查询待调查对象数据
- * @param investigatorPhone 流调人员电话号码
- * @param currentPage 当前页数
- * @param pageSize 页大小
+ *
+ * @param userPhone 分配的人员电话号码
+ * @param state 状态
+ * @param administrativeArea 行政区划
+ * @param currentPage 当前页数
+ * @param pageSize 页大小
* @return 页数据
*/
- List listRespondentPageByInvestigatorPhone(String investigatorPhone, int currentPage, int pageSize);
+ List listRespondentLimit(String userPhone, String state, AdministrativeArea administrativeArea, int currentPage, int pageSize);
/**
- * 根据流调人员phone查询调查对象数量
- * @param investigatorPhone 流调人员电话号码
- * @return 对应流调人员id的调查对象数量
+ * 根据筛选条件查询调查对象数量
+ *
+ * @param userPhone 分配的人员电话号码
+ * @param state 状态
+ * @param administrativeArea 行政区划
+ * @return 数量
*/
- long countRespondentByInvestigatorPhone(String investigatorPhone);
+ long countRespondent(String userPhone, String state, AdministrativeArea administrativeArea);
}
diff --git a/src/main/java/com/example/survey/service/RoleService.java b/src/main/java/com/example/survey/service/RoleService.java
index 0d03bde..d850c1d 100644
--- a/src/main/java/com/example/survey/service/RoleService.java
+++ b/src/main/java/com/example/survey/service/RoleService.java
@@ -1,6 +1,9 @@
package com.example.survey.service;
-import com.example.survey.vo.RoleVo;
+import com.example.survey.vo.CreateRoleVo;
+import com.example.survey.vo.ModifyRoleVo;
+
+import java.util.List;
/**
* @author Pope
@@ -10,8 +13,33 @@ public interface RoleService {
/**
* 创建角色
*
- * @param roleVo 角色信息
+ * @param createRoleVo 角色信息
* @return 是否创建成功
*/
- boolean addRole(RoleVo roleVo);
+ boolean addRole(CreateRoleVo createRoleVo);
+
+ /**
+ * 根据权限名分页查询权限
+ *
+ * @param roleName 角色名 模糊匹配
+ * @param currentPage 当前页数
+ * @param pageSize 页大小
+ * @return 查询结果
+ */
+ List getRole(String roleName, int currentPage, int pageSize);
+
+ /**
+ * 删除角色
+ *
+ * @param roleName 角色名
+ * @return 是否删除成功
+ */
+ void deleteRole(String roleName);
+
+ /**
+ * 修改角色权限
+ *
+ * @param modifyRoleVo 修改后角色信息
+ */
+ void modifyRole(ModifyRoleVo modifyRoleVo);
}
diff --git a/src/main/java/com/example/survey/service/UserService.java b/src/main/java/com/example/survey/service/UserService.java
index 2ee02ba..f1c093a 100644
--- a/src/main/java/com/example/survey/service/UserService.java
+++ b/src/main/java/com/example/survey/service/UserService.java
@@ -1,10 +1,14 @@
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.SignupVo;
+import com.example.survey.vo.CreateUserVo;
+import com.example.survey.vo.UserInfoVo;
import com.example.survey.vo.UserRoleVo;
+import java.util.List;
+
/**
* @author Pope
*/
@@ -20,14 +24,48 @@ public interface UserService {
/**
* 注册用户
*
- * @param signupVo 注册信息
+ * @param createUserVo 注册信息
* @return 是否注册成功
*/
- boolean addUser(SignupVo signupVo);
+ boolean addUser(CreateUserVo createUserVo);
/**
* 修改用户权限
+ *
* @param userRoleVo 新权限信息
*/
- void modifyRoles(UserRoleVo userRoleVo);
+ void modifyRole(UserRoleVo userRoleVo);
+
+ /**
+ * 根据筛选条件分页查询用户
+ *
+ * @param username 用户名 模糊匹配
+ * @param phoneNumber 电话号码 精确匹配
+ * @param currentPage 当前页数
+ * @param pageSize 页大小
+ * @return 用户信息dto
+ */
+ List listUserLimit(String username, String phoneNumber, int currentPage, int pageSize);
+
+ /**
+ * 删除用户
+ *
+ * @param phoneNumber 电话号码
+ * @return 是否删除成功
+ */
+ boolean deleteUser(String phoneNumber);
+
+ /**
+ * 修改用户信息
+ *
+ * @param userInfoVo 用户信息
+ */
+ void modifyUserInfo(UserInfoVo userInfoVo);
+
+ /**
+ * 重置密码
+ *
+ * @param phoneNumber 电话号码
+ */
+ void resetPwd(String phoneNumber);
}
diff --git a/src/main/java/com/example/survey/service/impl/InvestigationRecordServiceImpl.java b/src/main/java/com/example/survey/service/impl/InvestigationRecordServiceImpl.java
index 7d539f4..8d71583 100644
--- a/src/main/java/com/example/survey/service/impl/InvestigationRecordServiceImpl.java
+++ b/src/main/java/com/example/survey/service/impl/InvestigationRecordServiceImpl.java
@@ -1,17 +1,23 @@
package com.example.survey.service.impl;
import com.example.survey.dao.InvestigationRecordDao;
-import com.example.survey.dao.InvestigatorDao;
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;
@@ -19,71 +25,67 @@ import java.util.List;
/**
* @author Pope
*/
+@Log4j2
@Service
public class InvestigationRecordServiceImpl implements InvestigationRecordService {
+
@Autowired
private InvestigationRecordDao investigationRecordDao;
@Autowired
- private InvestigatorDao investigatorDao;
+ private RespondentDao respondentDao;
@Autowired
- private RespondentDao respondentDao;
+ private UserDao userDao;
+
@Override
public boolean addInvestigationRecord(InvestigationRecordVo vo) {
- InvestigationRecord record = InvestigationRecord.getInvestigationRecord(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.getInvestigatorPhone() + new Date().toString());
+ record.setVersion(vo.getUserPhone() + new Date().toString());
List opList = new ArrayList<>();
- OperationInformation op = new OperationInformation();
- op.setType(OperationInformation.SUBMIT);
- op.setTime(new Date());
- op.setInvestigatorPhone(vo.getInvestigatorPhone());
- op.setVersion(vo.getInvestigatorPhone() + new Date().toString());
- op.setMsg(vo.getMsg());
- op.setResult("提交成功");
- opList.add(op);
+ opList.add(OperationInformation.submitOp(vo.getUserPhone(), vo.getMsg()));
record.setOperationInformationList(opList);
- //如果不存在对应id的调查对象
- if (!respondentDao.existRespondent(record.getIdNumber())) {
- //TODO 改为抛出相应异常
- return false;
- }
-
- //如果已经存在则失败
- if (investigationRecordDao.existInvestigationRecord(record.getIdNumber(), InvestigationRecord.UNDER_REVIEW, InvestigationRecord.REVIEWED)) {
- return false;
- }
-
- //如果不存在对应id的流调人员
- if (!investigatorDao.existInvestigator(record.getInvestigatorPhone())) {
- //TODO 改为抛出相应异常
- return false;
- }
//TODO 插入消息队列
-
return investigationRecordDao.insertInvestigationRecord(record);
}
@Override
- public List listUnderReviewRecordPageByInvestigationPhone(String investigatorPhone, int currentPage, int pageSize, String state, String idNumber, String version, String questionnaireNumber, Boolean diseased) {
+ public List listUnderReviewRecordLimit(String userPhone, int currentPage, int pageSize, String state, String idNumber, String version, String questionnaireNumber, Boolean diseased) {
//TODO 从消息队列进行筛选
- return investigationRecordDao.listLimitInvestigationRecord(investigatorPhone, pageSize * currentPage, pageSize, state, idNumber, version, questionnaireNumber, diseased);
+ return investigationRecordDao.listInvestigationRecordLimit(userPhone, pageSize * currentPage, pageSize, state, idNumber, version, questionnaireNumber, diseased);
}
@Override
- public long countUnderReviewRecordByInvestigatorPhone(String investigatorPhone) {
+ public long countUnderReviewRecord(String userPhone) {
//TODO 从消息队列获取调查记录数量
- return investigationRecordDao.countInvestigationRecordByInvestigatorPhone(investigatorPhone, InvestigationRecord.UNDER_REVIEW);
+ return investigationRecordDao.countInvestigationRecordByUserPhone(userPhone, InvestigationRecord.UNDER_REVIEW);
}
@Override
@@ -91,24 +93,22 @@ public class InvestigationRecordServiceImpl implements InvestigationRecordServic
public void changeInvestigationRecord(InvestigationRecordVo vo) {
//创建新记录
InvestigationRecord oldRecord = investigationRecordDao.selectInvestigationRecord(vo.getIdNumber(), InvestigationRecord.REVIEWED);
- if(oldRecord == null){
+ if (oldRecord == null) {
oldRecord = investigationRecordDao.selectInvestigationRecord(vo.getIdNumber(), InvestigationRecord.NOT_PASS);
}
- InvestigationRecord newRecord = InvestigationRecord.getInvestigationRecord(vo);
+
+ if(oldRecord == null){
+ log.error("调查记录不存在");
+ throw new RecordException("调查记录不存在");
+ }
+ InvestigationRecord newRecord = new InvestigationRecord(vo);
//生成版本信息
newRecord.setState(InvestigationRecord.UNDER_REVIEW);
- newRecord.setVersion(vo.getInvestigatorPhone() + new Date().toString());
+ newRecord.setVersion(vo.getUserPhone() + new Date().toString());
//生成操作记录
List opList = oldRecord.getOperationInformationList();
- OperationInformation op = new OperationInformation();
- op.setType(OperationInformation.CHANGE);
- op.setTime(new Date());
- op.setInvestigatorPhone(vo.getInvestigatorPhone());
- op.setVersion(vo.getInvestigatorPhone() + new Date().toString());
- op.setMsg(vo.getMsg());
- op.setResult("提交成功");
- opList.add(op);
+ opList.add(OperationInformation.submitOp(vo.getUserPhone(), vo.getMsg()));
newRecord.setOperationInformationList(opList);
//存入新纪录
@@ -121,35 +121,28 @@ public class InvestigationRecordServiceImpl implements InvestigationRecordServic
}
@Override
- public boolean reviewRecord(ReviewVo vo) {
+ public boolean reviewRecord(ReviewVo reviewVo) {
- //如果调查记录表不存在
- if (!investigationRecordDao.existInvestigationRecord(vo.getIdNumber(), InvestigationRecord.UNDER_REVIEW)) {
- //TODO 抛出相应异常
- return false;
+ //如果待审核调查记录表不存在
+ if (!investigationRecordDao.existInvestigationRecord(reviewVo.getIdNumber(), InvestigationRecord.UNDER_REVIEW)) {
+ log.error("未审核记录不存在");
+ throw new RecordException("未审核记录不存在");
}
//如果审核人不存在
- if (!investigatorDao.existInvestigator(vo.getReviewerPhone())) {
- //TODO 抛出相应异常
- return false;
+ if(!userDao.existUser(reviewVo.getReviewerPhone())){
+ log.error("审核人不存在");
+ throw new UserException("审核人不存在");
}
- InvestigationRecord record = investigationRecordDao.selectInvestigationRecord(vo.getIdNumber(), InvestigationRecord.UNDER_REVIEW);
+ InvestigationRecord record = investigationRecordDao.selectInvestigationRecord(reviewVo.getIdNumber(), InvestigationRecord.UNDER_REVIEW);
//审核结果与版本信息
- record.setState(vo.isPass() ? InvestigationRecord.REVIEWED : InvestigationRecord.NOT_PASS);
- record.setVersion(vo.getReviewerPhone() + new Date().toString());
+ record.setState(reviewVo.isPass() ? InvestigationRecord.REVIEWED : InvestigationRecord.NOT_PASS);
+ record.setVersion(reviewVo.getReviewerPhone() + new Date().toString());
//生成操作记录
List opList = record.getOperationInformationList();
- OperationInformation op = new OperationInformation();
- op.setType(OperationInformation.REVIEW);
- op.setTime(new Date());
- op.setInvestigatorPhone(vo.getReviewerPhone());
- op.setVersion(vo.getReviewerPhone() + new Date().toString());
- op.setMsg(vo.getMsg());
- op.setResult(vo.isPass() ? "审核通过" : "审核不通过");
- opList.add(op);
+ opList.add(OperationInformation.reviewOp(reviewVo.getReviewerPhone(), reviewVo.getMsg(), reviewVo.isPass() ? "审核通过" : "审核不通过"));
record.setOperationInformationList(opList);
//更新数据库记录
@@ -157,4 +150,14 @@ public class InvestigationRecordServiceImpl implements InvestigationRecordServic
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());
+ }
+ }
}
diff --git a/src/main/java/com/example/survey/service/impl/InvestigatorServiceImpl.java b/src/main/java/com/example/survey/service/impl/InvestigatorServiceImpl.java
deleted file mode 100644
index 8a5f70f..0000000
--- a/src/main/java/com/example/survey/service/impl/InvestigatorServiceImpl.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.example.survey.service.impl;
-
-import com.example.survey.dao.InvestigatorDao;
-import com.example.survey.entity.Investigator;
-import com.example.survey.service.InvestigatorService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-/**
- * @author Pope
- */
-@Service
-public class InvestigatorServiceImpl implements InvestigatorService {
-
- @Autowired
- private InvestigatorDao investigatorDao;
-
- @Override
- public boolean addInvestigator(Investigator investigator) {
- return investigatorDao.insertInvestigator(investigator);
- }
-}
diff --git a/src/main/java/com/example/survey/service/impl/RespondentServiceImpl.java b/src/main/java/com/example/survey/service/impl/RespondentServiceImpl.java
index 91645d9..72289b1 100644
--- a/src/main/java/com/example/survey/service/impl/RespondentServiceImpl.java
+++ b/src/main/java/com/example/survey/service/impl/RespondentServiceImpl.java
@@ -1,11 +1,14 @@
package com.example.survey.service.impl;
-import com.example.survey.dao.InvestigatorDao;
import com.example.survey.dao.RespondentDao;
-import com.example.survey.entity.Investigator;
+import com.example.survey.dao.UserDao;
import com.example.survey.entity.Respondent;
+import com.example.survey.entity.User;
+import com.example.survey.entity.inner.AdministrativeArea;
import com.example.survey.service.RespondentService;
import com.example.survey.dto.RespondentDto;
+import com.example.survey.vo.CreateRespondentVo;
+import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -15,6 +18,7 @@ import java.util.List;
/**
* @author Pope
*/
+@Log4j2
@Service
public class RespondentServiceImpl implements RespondentService {
@@ -22,32 +26,32 @@ public class RespondentServiceImpl implements RespondentService {
private RespondentDao respondentDao;
@Autowired
- private InvestigatorDao investigatorDao;
+ private UserDao userDao;
@Override
- public boolean addRespondent(Respondent respondent) {
- //如果不存在对应phone的流调人员
- if (!investigatorDao.existInvestigator(respondent.getInvestigatorPhone())) {
- //TODO 改为抛出相应异常
-
- return false;
+ public boolean addRespondent(CreateRespondentVo createRespondentVo) {
+ if (!userDao.existUser(createRespondentVo.getUserPhone())) {
+ log.error("不存在对应id的用户");
}
+ Respondent respondent = new Respondent(createRespondentVo);
+
return respondentDao.insertRespondent(respondent);
}
@Override
- public List listRespondentPageByInvestigatorPhone(String investigatorPhone, int currentPage, int pageSize) {
- List voList = new ArrayList<>();
- List respondentList = respondentDao.listLimitRespondentByInvestigator(investigatorPhone, currentPage * pageSize, pageSize);
+ public List listRespondentLimit(String userPhone, String state, AdministrativeArea administrativeArea, int currentPage, int pageSize) {
+ List dtoList = new ArrayList<>();
+ List respondentList = respondentDao.listRespondentLimit(userPhone, state, administrativeArea, currentPage * pageSize, pageSize);
for (Respondent respondent : respondentList) {
- Investigator investigator = investigatorDao.selectInvestigator(respondent.getInvestigatorPhone());
- voList.add(new RespondentDto(respondent, investigator));
+ User user = userDao.selectUser(respondent.getUserPhone());
+ dtoList.add(new RespondentDto(respondent, user));
}
- return voList;
+ return dtoList;
}
@Override
- public long countRespondentByInvestigatorPhone(String investigatorPhone) {
- return respondentDao.countRespondentBuInvestigatorPhone(investigatorPhone);
+ public long countRespondent(String userPhone, String state, AdministrativeArea administrativeArea) {
+ return respondentDao.countRespondent(userPhone, state, administrativeArea);
}
+
}
diff --git a/src/main/java/com/example/survey/service/impl/RoleServiceImpl.java b/src/main/java/com/example/survey/service/impl/RoleServiceImpl.java
index ef1ad22..7536285 100644
--- a/src/main/java/com/example/survey/service/impl/RoleServiceImpl.java
+++ b/src/main/java/com/example/survey/service/impl/RoleServiceImpl.java
@@ -1,14 +1,21 @@
package com.example.survey.service.impl;
import com.example.survey.dao.RoleDao;
+import com.example.survey.dao.UserDao;
import com.example.survey.entity.Role;
import com.example.survey.enumeration.AuthEnum;
+import com.example.survey.exception.AuthException;
import com.example.survey.service.RoleService;
-import com.example.survey.vo.RoleVo;
+import com.example.survey.util.TokenUtil;
+import com.example.survey.vo.CreateRoleVo;
+import com.example.survey.vo.ModifyRoleVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Set;
/**
@@ -20,16 +27,58 @@ public class RoleServiceImpl implements RoleService {
@Autowired
private RoleDao roleDao;
+ @Autowired
+ private UserDao userDao;
+
@Override
- public boolean addRole(RoleVo roleVo) {
+ public boolean addRole(CreateRoleVo createRoleVo) {
Role role = new Role();
- role.setName(roleVo.getRoleName());
+ role.setName(createRoleVo.getRoleName());
Set authoritySet = new HashSet<>();
- for (Integer code : roleVo.getAuthList()) {
- authoritySet.add(AuthEnum.getRoleEnum(code));
+ for (String name : createRoleVo.getAuthList()) {
+ authoritySet.add(AuthEnum.getRoleEnum(name));
}
role.setAuthoritySet(authoritySet);
return roleDao.insertRole(role);
}
+
+ @Override
+ public List getRole(String roleName, int currentPage, int pageSize) {
+ List roleList = roleDao.listLimitRole(roleName, currentPage * pageSize, pageSize);
+ List roleVoList = new LinkedList<>();
+ for (Role role : roleList) {
+ roleVoList.add(new CreateRoleVo(role));
+ }
+
+ return roleVoList;
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void deleteRole(String roleName) {
+ //将用户数据库中含有该角色的用户更新
+ userDao.clearRole(roleDao.selectRole(roleName));
+ //从角色数据库删除角色
+ roleDao.deleteRole(roleName);
+
+ //删除redis中的角色
+ TokenUtil.expireKey(roleName);
+ }
+
+ @Override
+ public void modifyRole(ModifyRoleVo modifyRoleVo) {
+ Set authEnumList = new HashSet<>();
+ Set routeSet = new HashSet<>();
+ for (String authName : modifyRoleVo.getAuthList()) {
+ AuthEnum authEnum = AuthEnum.getRoleEnum(authName);
+ if(authEnum == null){
+ throw new AuthException("权限不存在");
+ }
+ authEnumList.add(authEnum);
+ routeSet.addAll(authEnum.getRoutes());
+ }
+ roleDao.updateRole(modifyRoleVo.getRoleName(), authEnumList);
+ TokenUtil.setWithoutExpireTime(modifyRoleVo.getRoleName(), routeSet);
+ }
}
diff --git a/src/main/java/com/example/survey/service/impl/UserServiceImpl.java b/src/main/java/com/example/survey/service/impl/UserServiceImpl.java
index 4a2d98b..5b5d7b7 100644
--- a/src/main/java/com/example/survey/service/impl/UserServiceImpl.java
+++ b/src/main/java/com/example/survey/service/impl/UserServiceImpl.java
@@ -1,18 +1,18 @@
package com.example.survey.service.impl;
-import com.example.survey.dao.InvestigatorDao;
+import com.example.survey.dao.InvestigationRecordDao;
import com.example.survey.dao.RoleDao;
import com.example.survey.dao.UserDao;
import com.example.survey.dto.LoginDto;
-import com.example.survey.entity.Investigator;
+import com.example.survey.dto.UserDto;
import com.example.survey.entity.Role;
import com.example.survey.entity.User;
import com.example.survey.enumeration.AuthEnum;
+import com.example.survey.exception.UserException;
import com.example.survey.service.UserService;
import com.example.survey.util.TokenUtil;
-import com.example.survey.vo.LoginVo;
-import com.example.survey.vo.SignupVo;
-import com.example.survey.vo.UserRoleVo;
+import com.example.survey.vo.*;
+import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -21,38 +21,43 @@ import java.util.*;
/**
* @author Pope
*/
+@Log4j2
@Service
public class UserServiceImpl implements UserService {
@Autowired
private UserDao userDao;
@Autowired
- private TokenUtil tokenUtil;
- @Autowired
private RoleDao roleDao;
@Autowired
- private InvestigatorDao investigatorDao;
+ private InvestigationRecordDao investigationRecordDao;
+
@Override
public LoginDto matchAuth(LoginVo loginVo) {
- User user = userDao.selectUser(loginVo.getPhoneNumber(), loginVo.getPassword());
+ User user = userDao.selectUser(loginVo.getPhoneNumber());
if (user == null) {
- return null;
+ log.error("用户不存在");
+ throw new UserException("用户不存在");
+ }
+ if (!loginVo.getPassword().equals(user.getPassword())) {
+ log.error("密码错误");
+ throw new UserException("密码错误");
}
- LoginDto loginDto = new LoginDto();
+ LoginDto loginDto = new LoginDto();
//判断是否已经登录过
- if (tokenUtil.existToken(user.getPhoneNumber())) {
- String oldToken = (String) tokenUtil.getValue(user.getPhoneNumber());
- if (tokenUtil.existToken(oldToken)) {
+ if (TokenUtil.existKey(user.getPhoneNumber())) {
+ String oldToken = (String) TokenUtil.get(user.getPhoneNumber());
+ if (TokenUtil.existKey(oldToken)) {
//已经登录,将旧token过期,
- tokenUtil.expire(oldToken);
+ TokenUtil.expireKey(oldToken);
}
}
//生成新的token并存入redis
String newToken = UUID.randomUUID().toString();
- tokenUtil.setPhoneNumberAndToken(user.getPhoneNumber(), newToken);
+ TokenUtil.set(user.getPhoneNumber(), newToken);
//生成角色列表
Set roleNameSet = new HashSet<>();
@@ -61,41 +66,93 @@ public class UserServiceImpl implements UserService {
for (AuthEnum authEnum : role.getAuthoritySet()) {
routeSet.addAll(authEnum.getRoutes());
}
- tokenUtil.setAuthAndRoute(role.getName(), routeSet);
+ TokenUtil.setWithoutExpireTime(role.getName(), routeSet);
roleNameSet.add(role.getName());
}
- tokenUtil.setTokenAndAuth(newToken, roleNameSet);
+ TokenUtil.set(newToken, roleNameSet);
loginDto.setToken(newToken);
- loginDto.setRoleList(user.getRoleList());
+ loginDto.setUsername(user.getUsername());
+ loginDto.setIdNumber(user.getIdNumber());
+ loginDto.setPhoneNumber(user.getPhoneNumber());
+ List roleVoList = new ArrayList<>();
+ for (Role role : user.getRoleList()) {
+ roleVoList.add(new RoleVo(role));
+ }
+ loginDto.setRoleList(roleVoList);
loginDto.setDepartmentList(user.getDepartmentList());
+ loginDto.setAdministrativeArea(user.getAdministrativeArea());
return loginDto;
}
@Override
- public boolean addUser(SignupVo signupVo) {
- User user = new User(signupVo);
+ public boolean addUser(CreateUserVo createUserVo) {
+ User user = new User(createUserVo);
//初始化为流调人员权限
- Role investigatorRole = roleDao.selectRole("流调人员");
- List roleList = user.getRoleList();
- roleList.add(investigatorRole);
- user.setRoleList(roleList);
- Investigator investigator = new Investigator();
- investigator.setName(user.getUsername());
- investigator.setIdNumber(user.getIdNumber());
- investigator.setPhoneNumber(user.getPhoneNumber());
- return userDao.insertUser(user) && investigatorDao.insertInvestigator(investigator);
+// Role investigatorRole = roleDao.selectRole("流调人员");
+// List roleList = user.getRoleList();
+// roleList.add(investigatorRole);
+// user.setRoleList(roleList);
+ return userDao.insertUser(user);
}
@Override
- public void modifyRoles(UserRoleVo userRoleVo) {
+ public void modifyRole(UserRoleVo userRoleVo) {
List roleList = new ArrayList<>();
for (String roleName : userRoleVo.getRoleNameList()) {
roleList.add(roleDao.selectRole(roleName));
}
- roleDao.updateUserRoles(userRoleVo.getPhoneNumber(), roleList);
+ userDao.updateUserRole(userRoleVo.getPhoneNumber(), roleList);
}
+
+ @Override
+ public List listUserLimit(String username, String phoneNumber, int currentPage, int pageSize) {
+ List userList = userDao.listUserLimit(username, phoneNumber, currentPage * pageSize, pageSize);
+ List userDtoList = new LinkedList<>();
+ for (User user : userList) {
+ userDtoList.add(new UserDto(user));
+ }
+ return userDtoList;
+ }
+
+ @Override
+ public boolean deleteUser(String phoneNumber) {
+ if (!userDao.existUser(phoneNumber)) {
+ log.error("用户不存在");
+ throw new UserException("用户不存在");
+ }
+ userDao.deleteUser(phoneNumber);
+
+ investigationRecordDao.updateManyRecordUserPhone(phoneNumber, null);
+
+ if (TokenUtil.existKey(phoneNumber)) {
+ String token = (String) TokenUtil.get(phoneNumber);
+ TokenUtil.expireKey(phoneNumber);
+ TokenUtil.expireKey(token);
+ }
+ return true;
+ }
+
+ @Override
+ public void modifyUserInfo(UserInfoVo userInfoVo) {
+ if (!userDao.existUser(userInfoVo.getPhoneNumber())) {
+ log.error("用户不存在");
+ throw new UserException("用户不存在");
+ }
+ userDao.modifyUser(userInfoVo);
+ }
+
+ @Override
+ public void resetPwd(String phoneNumber) {
+ if (!userDao.existUser(phoneNumber)) {
+ log.error("用户不存在");
+ throw new UserException("用户不存在");
+ }
+ userDao.resetPwd(phoneNumber);
+ }
+
+
}
diff --git a/src/main/java/com/example/survey/util/TokenUtil.java b/src/main/java/com/example/survey/util/TokenUtil.java
index 1a56f52..591c0a1 100644
--- a/src/main/java/com/example/survey/util/TokenUtil.java
+++ b/src/main/java/com/example/survey/util/TokenUtil.java
@@ -4,9 +4,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
-import java.util.HashSet;
+import javax.annotation.PostConstruct;
import java.util.Set;
-import java.util.UUID;
import java.util.concurrent.TimeUnit;
/**
@@ -20,46 +19,68 @@ public class TokenUtil {
*/
private static final long EXPIRATION_TIME = 6L;
+ private static TokenUtil tokenUtil;
+
@Autowired
RedisTemplate redisTemplate;
+ @PostConstruct
+ public void init() {
+ tokenUtil = this;
+ tokenUtil.redisTemplate = this.redisTemplate;
+ }
+
/**
- * 判断token是否存在
+ * 判断key是否存在
*
- * @param token key
+ * @param key key
* @return 是否存在
*/
- public boolean existToken(String token) {
- Boolean result = redisTemplate.hasKey(token);
+ public static boolean existKey(String key) {
+ Boolean result = tokenUtil.redisTemplate.hasKey(key);
return result != null && result;
}
/**
- * 设置<手机号, token>类型的键值对
+ * 存储key-value键值对,如果key已存在则更新value
+ * 过期时间为{@link TokenUtil#EXPIRATION_TIME}小时
*
- * @param phoneNumber 手机号
- * @param token token
+ * @param key key
+ * @param value value
*/
- public void setPhoneNumberAndToken(String phoneNumber, String token) {
- redisTemplate.opsForValue().set(phoneNumber, token, 6L, TimeUnit.HOURS);
- }
-
- public void refreshExpireTime(String key) {
- redisTemplate.expire(key, 6L, TimeUnit.HOURS);
+ public static void set(String key, String value) {
+ tokenUtil.redisTemplate.opsForValue().set(key, value, EXPIRATION_TIME, TimeUnit.HOURS);
}
/**
- * 存储token与对应的可访问路由集合
+ * 刷新key的过期时间
*
- * @param token token
- * @param authSet 对应权限集合
+ * @param key key
*/
- public void setTokenAndAuth(String token, Set authSet) {
- redisTemplate.opsForValue().set(token, authSet, 6L, TimeUnit.HOURS);
+ public static void refreshExpireTime(String key) {
+ tokenUtil.redisTemplate.expire(key, EXPIRATION_TIME, TimeUnit.HOURS);
}
- public void setAuthAndRoute(String authName, Set route) {
- redisTemplate.opsForValue().set(authName, route);
+ /**
+ * 存储key-set键值对,如果key已存在则更新set
+ * 过期时间为{@link TokenUtil#EXPIRATION_TIME}小时
+ *
+ * @param key key
+ * @param set 集合
+ */
+ public static void set(String key, Set set) {
+ tokenUtil.redisTemplate.opsForValue().set(key, set, 6L, TimeUnit.HOURS);
+ }
+
+ /**
+ * 存储key-set键值对,如果key已存在则更新set
+ * 无过期时间
+ *
+ * @param key key
+ * @param set set
+ */
+ public static void setWithoutExpireTime(String key, Set set) {
+ tokenUtil.redisTemplate.opsForValue().set(key, set);
}
/**
@@ -70,15 +91,18 @@ public class TokenUtil {
* @param method 请求方法
* @return 是否允许访问
*/
- public boolean isPass(String token, String route, String method) {
- if (!existToken(token)) {
+ public static boolean isPass(String token, String route, String method) {
+ if (!existKey(token)) {
return false;
}
String request = route + " : " + method;
- Set authSet = (Set) redisTemplate.opsForValue().get(token);
+ Set authSet = (Set) tokenUtil.redisTemplate.opsForValue().get(token);
+ if (authSet == null) {
+ return false;
+ }
for (String auth : authSet) {
- Set routeSet = (Set) redisTemplate.opsForValue().get(auth);
- if(routeSet.contains(request)){
+ Set routeSet = (Set) tokenUtil.redisTemplate.opsForValue().get(auth);
+ if (routeSet != null && routeSet.contains(request)) {
return true;
}
}
@@ -91,8 +115,8 @@ public class TokenUtil {
* @param key key
* @return value
*/
- public Object getValue(String key) {
- return redisTemplate.opsForValue().get(key);
+ public static Object get(String key) {
+ return tokenUtil.redisTemplate.opsForValue().get(key);
}
/**
@@ -100,7 +124,7 @@ public class TokenUtil {
*
* @param key 要过期的key
*/
- public void expire(String key) {
- redisTemplate.expire(key, 0, TimeUnit.MICROSECONDS);
+ public static void expireKey(String key) {
+ tokenUtil.redisTemplate.expire(key, 0, TimeUnit.MICROSECONDS);
}
}
diff --git a/src/main/java/com/example/survey/util/WordUtil.java b/src/main/java/com/example/survey/util/WordUtil.java
new file mode 100644
index 0000000..494e779
--- /dev/null
+++ b/src/main/java/com/example/survey/util/WordUtil.java
@@ -0,0 +1,430 @@
+package com.example.survey.util;
+
+import com.example.survey.dao.UserDao;
+import com.example.survey.entity.InvestigationRecord;
+import com.example.survey.entity.inner.*;
+import org.apache.poi.xwpf.usermodel.*;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+import javax.servlet.http.HttpServletResponse;
+import java.math.BigInteger;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author Pope
+ */
+@Component
+public class WordUtil {
+
+ @Autowired
+ private UserDao userDao;
+
+ private static WordUtil wordUtil;
+
+ @PostConstruct
+ public void init() {
+ wordUtil = this;
+ wordUtil.userDao = this.userDao;
+ }
+
+ /**
+ * 分隔符
+ */
+ private static final String SEPARATOR = " ";
+
+ private static final String OTHER = "other";
+
+ public static void writeDocx(InvestigationRecord record, HttpServletResponse response) throws Exception {
+ XWPFDocument document = new XWPFDocument();
+ int index = 1;
+
+ //添加标题
+ XWPFParagraph title = document.createParagraph();
+ title.setAlignment(ParagraphAlignment.CENTER);
+ XWPFRun titleRun = title.createRun();
+ titleRun.setText("新型冠状病毒肺炎病例个案调查表");
+ //设置字体
+ setRunFont(titleRun, "宋体", 18, true);
+
+ //换行
+ document.createParagraph().createRun().setText("\r");
+
+ //问卷编号与身份证号
+ XWPFParagraph firstPara = document.createParagraph();
+ firstPara.setAlignment(ParagraphAlignment.CENTER);
+ XWPFRun firstParaRun = firstPara.createRun();
+ firstParaRun.setText("问卷编号:" + record.getQuestionnaireNumber() + SEPARATOR + "身份证号:" + record.getIdNumber());
+ //设置字体
+ setRunFont(firstParaRun, "仿宋", 10, false);
+
+ //换行
+ document.createParagraph().createRun().setText("\r");
+
+ //信息表格
+ XWPFTable infoTable = document.createTable();
+ //列宽自动分割
+ CTTblWidth infoTableWidth = infoTable.getCTTbl().addNewTblPr().addNewTblW();
+ infoTableWidth.setType(STTblWidth.DXA);
+ infoTableWidth.setW(BigInteger.valueOf(9072));
+
+
+ //表格第一行 基本信息
+ XWPFTableRow infoTableRow1 = infoTable.getRow(0);
+ XWPFTableCell basicInfoCell = infoTableRow1.getCell(0);
+ basicInfoCell.removeParagraph(0);
+
+ //基本信息标题
+ createParaInCell(basicInfoCell, "一、基本信息", true);
+ createBreakLine(basicInfoCell);
+
+ //姓名 性别
+ createParaInCell(basicInfoCell, index++ + ".姓名:" + record.getName() + SEPARATOR + index++ + ".性别:" + record.getGender(), false);
+ //是否为境外输入病例
+ createParaInCell(basicInfoCell, index++ + ".是否为境外输入病例:" + (record.isOverseasCase() ? "是" : "否"), false);
+ if (record.isOverseasCase()) {
+ //如果为境外输入病例,填写入境信息
+ EntryExperience entryExperience = record.getEntryExperience();
+ createParaInCell(basicInfoCell, SEPARATOR + "入境前居住或旅行的国家或地区:" + entryExperience.getAreaOfResidence(), false);
+ createParaInCell(basicInfoCell, SEPARATOR + "入境前途经国家和地区:" + entryExperience.getAreaOfAccess(), false);
+ createParaInCell(basicInfoCell, SEPARATOR + "国籍:" + entryExperience.getNationality() + SEPARATOR + "护照号码:" + entryExperience.getPassportNumber(), false);
+ createParaInCell(basicInfoCell, SEPARATOR + "入境口岸:" + entryExperience.getEntryPort().getProvince() + "省" + entryExperience.getEntryPort().getPort(), false);
+
+ createParaInCell(basicInfoCell, SEPARATOR + "入境日期:" + formatDate(entryExperience.getEntryDate()), false);
+ createParaInCell(basicInfoCell, SEPARATOR + "入境交通方式:" + entryExperience.getTransportation(), false);
+ }
+
+ //病例发现与就诊
+ XWPFTableRow infoTableRow2 = infoTable.createRow();
+ XWPFTableCell hospInfoCell = infoTableRow2.getCell(0);
+ hospInfoCell.removeParagraph(0);
+
+ //病例发现与就诊标题
+ createParaInCell(hospInfoCell, "二、病例发现与就诊", true);
+ createBreakLine(hospInfoCell);
+
+ //病例发现途径
+ createParaInCell(hospInfoCell, index++ + ".病例发现途径:" + record.getWayOfBeingDiscovered(), false);
+ //入院日期
+ createParaInCell(hospInfoCell, index++ + ".入院日期:" + formatDate(record.getDateOfAdmission()), false);
+ StringBuilder symptomAndSign = new StringBuilder();
+ //入院时症状和体征
+ for (String s : record.getSymptomAndSign()) {
+ symptomAndSign.append(s).append(" ");
+ }
+ createParaInCell(hospInfoCell, index++ + ".入院症状和体征:" + symptomAndSign.toString(), false);
+ //有无并发症
+ createParaInCell(hospInfoCell, index++ + ".有无并发症:" + (record.isExistComplication() ? "有" : "无"), false);
+ if (record.getComplication() != null) {
+ StringBuilder complication = new StringBuilder("并发症:");
+ for (String s : record.getComplication()) {
+ complication.append(s);
+ }
+ createParaInCell(hospInfoCell, complication.toString(), false);
+ if (record.getComplication().contains("发热")) {
+ //如果并发症包含发热,则打印最高温度
+ createParaInCell(hospInfoCell, SEPARATOR + "发热:最高温度" + record.getMaxTemp() + "°C", false);
+ }
+
+ }
+ //胸部X线或CT检测是否有肺炎影像学特征
+ createParaInCell(hospInfoCell, index++ + ".胸部X线或CT检测是否有肺炎影像学特征:" + (record.isExistImagingFeatureOfPneumonia() ? "是" : "否"), false);
+ if (record.isExistImagingFeatureOfPneumonia()) {
+ //如果存在肺炎影像学特征,打印检测时间
+ createParaInCell(hospInfoCell, SEPARATOR + "检测时间:" + formatDate(record.getTestDate()), false);
+ }
+ //出院日期
+ createParaInCell(hospInfoCell, index++ + ".出院日期:" + formatDate(record.getDateOfDischarge()), false);
+ //是否为以下特定职业人群
+ createParaInCell(hospInfoCell, index++ + ".是否为以下特定职业人群:" + record.getSpecificOccupation(), false);
+ if (OTHER.equals(record.getSpecificOccupation())) {
+ //若职业为其他
+ createParaInCell(hospInfoCell, SEPARATOR + "职业:" + record.getOtherSpecificOccupation(), false);
+ }
+ //如为医务人员,请选择具体工作性质:
+ createParaInCell(hospInfoCell, SEPARATOR + "如为医务人员,请选择具体工作性质:" + record.getWorkInformation(), false);
+ if (OTHER.equals(record.getWorkInformation())) {
+ //若工作性质为其他
+ createParaInCell(hospInfoCell, SEPARATOR + "其他工作性质:" + record.getOtherWorkInformation(), false);
+ }
+ //是否为孕妇
+ createParaInCell(hospInfoCell, index++ + ".是否为孕妇:" + (record.isPregnant() ? "是" : "否"), false);
+ if (record.isPregnant()) {
+ //如果是孕妇,打印孕周
+ createParaInCell(hospInfoCell, SEPARATOR + "孕周:" + record.getPregnantWeek(), false);
+ }
+ //既往病史和基本情况(可多选)
+ StringBuilder medicalHistory = new StringBuilder();
+ for (String s : record.getMedicalHistory()) {
+ medicalHistory.append(s).append(" ");
+ }
+ createParaInCell(hospInfoCell, index++ + ".既往病史与基本情况:" + medicalHistory, false);
+ //既往病史描述
+ createParaInCell(hospInfoCell, SEPARATOR + "既往病史描述:" + record.getMedicalHistoryDetail(), false);
+
+
+ //发病或检测阳性前 14 天内是否有以下暴露史或接触史:
+ XWPFTableRow infoTableRow3 = infoTable.createRow();
+ XWPFTableCell contactHistoryCell = infoTableRow3.getCell(0);
+ contactHistoryCell.removeParagraph(0);
+
+ //病例发现与就诊标题
+ createParaInCell(contactHistoryCell, "三、发病或检测阳性前 14 天内是否有以下暴露史或接触史:", true);
+ createBreakLine(contactHistoryCell);
+
+ //是否有境外疫情严重国家或地区的旅行史或居住史
+ createParaInCell(contactHistoryCell, index++ + ".是否有境外疫情严重国家或地区的旅行史或居住史:" + (record.isNearSeriousRegion() ? "是" : "否"), false);
+
+ //是否接触过来自境外疫情严重的国家或地区的发热或有呼吸道症状的患者
+ createParaInCell(contactHistoryCell, index++ + ".是否接触过来自境外疫情严重的国家或地区的发热或有呼吸道症状的患者:" + (record.isContactWithSeriousRegionPatients() ? "是" : "否"), false);
+
+ //是否曾有确诊病例或无症状感染者的接触史
+ createParaInCell(contactHistoryCell, index++ + ".是否曾有确诊病例或无症状感染者的接触史:" + (record.isContactWithConfirmedCase() ? "是" : "否"), false);
+
+ //患者同一家庭、办公室、学校或托幼机构班级、车间等集体单位是否有聚集性发病
+ createParaInCell(contactHistoryCell, index++ + ".患者同一家庭、办公室、学校或托幼机构班级、车间等集体单位是否有聚集性发病:" + (record.isAggregationDisease() ? "是" : "否"), false);
+
+ //体温记录
+ XWPFTableRow infoTableRow4 = infoTable.createRow();
+ XWPFTableCell tempHistory = infoTableRow4.getCell(0);
+ tempHistory.removeParagraph(0);
+ createParaInCell(tempHistory, "四、体温记录", true);
+ createBreakLine(tempHistory);
+
+ //体温记录表
+ XWPFTable tempTable = createTableInCell(tempHistory);
+
+ //创建表头
+ XWPFTableRow tempTableHead = tempTable.createRow();
+ XWPFTableCell tempDateHead = tempTableHead.createCell();
+ tempDateHead.removeParagraph(0);
+ createParaInCell(tempDateHead, "记录时间", false);
+ setCellCenter(tempDateHead);
+
+ XWPFTableCell tempHead = tempTableHead.createCell();
+ tempHead.removeParagraph(0);
+ createParaInCell(tempHead, "温度", false);
+ setCellCenter(tempHead);
+ //创建数据
+ for (TempHistory history : record.getTempHistoryList()) {
+ XWPFTableRow row = tempTable.createRow();
+
+ XWPFTableCell temp = row.getCell(0);
+ temp.removeParagraph(0);
+ createParaInCell(temp, history.getData(), false);
+ setCellCenter(temp);
+
+ XWPFTableCell date = row.getCell(1);
+ date.removeParagraph(0);
+ createParaInCell(date, formatTime(history.getTime()), false);
+ setCellCenter(date);
+ }
+
+
+ //居住史
+ XWPFTableRow infoTableRow5 = infoTable.createRow();
+ XWPFTableCell liveAndTravelHistory = infoTableRow5.getCell(0);
+ liveAndTravelHistory.removeParagraph(0);
+
+ createParaInCell(liveAndTravelHistory, "五、居旅史", true);
+ createBreakLine(liveAndTravelHistory);
+
+ List liveHistoryList = record.getLiveHistoryList();
+ if (liveHistoryList != null) {
+ for (int i = 0; i < liveHistoryList.size(); i++) {
+ createParaInCell(liveAndTravelHistory, "居住史" + (i + 1), false);
+ createParaInCell(liveAndTravelHistory, SEPARATOR + "开始时间:" + formatDate(liveHistoryList.get(i).getBeginTime()), false);
+ createParaInCell(liveAndTravelHistory, SEPARATOR + "地点:" + liveHistoryList.get(i).getLocation().getMsg(), false);
+ createParaInCell(liveAndTravelHistory, SEPARATOR + "结束时间:" + formatDate(liveHistoryList.get(i).getEndTime()), false);
+ createParaInCell(liveAndTravelHistory, SEPARATOR + "详细信息:" + liveHistoryList.get(i).getDetail(), false);
+ }
+ }
+ List travelHistoryList = record.getTravelHistoryList();
+ if (travelHistoryList != null) {
+ for (int i = 0; i < travelHistoryList.size(); i++) {
+ createParaInCell(liveAndTravelHistory, "旅行史" + (i + 1), false);
+ createParaInCell(liveAndTravelHistory, SEPARATOR + "开始时间:" + formatDate(travelHistoryList.get(i).getBeginTime()), false);
+ createParaInCell(liveAndTravelHistory, SEPARATOR + "开始地点:" + travelHistoryList.get(i).getStartLocation().getMsg(), false);
+ createParaInCell(liveAndTravelHistory, SEPARATOR + "结束时间:" + formatDate(travelHistoryList.get(i).getEndTime()), false);
+ createParaInCell(liveAndTravelHistory, SEPARATOR + "结束地点:" + travelHistoryList.get(i).getEndLocation().getMsg(), false);
+ createParaInCell(liveAndTravelHistory, SEPARATOR + "详细信息:" + travelHistoryList.get(i).getDetail(), false);
+ }
+ }
+
+
+ //实验室检测单
+ XWPFTableRow infoTableRow6 = infoTable.createRow();
+ XWPFTableCell detectionList = infoTableRow6.getCell(0);
+ detectionList.removeParagraph(0);
+ createParaInCell(detectionList, "六、实验室检测单", true);
+ createBreakLine(detectionList);
+
+ //实验室检测单表格
+ XWPFTable detectionTable = createTableInCell(detectionList);
+
+ //创建表头
+ XWPFTableRow detectionTableHead = detectionTable.createRow();
+
+ XWPFTableCell nameHead = detectionTableHead.createCell();
+ nameHead.removeParagraph(0);
+ createParaInCell(nameHead, "标本类型:", false);
+ setCellCenter(nameHead);
+
+ XWPFTableCell detectionDate = detectionTableHead.createCell();
+ detectionDate.removeParagraph(0);
+ createParaInCell(detectionDate, "采样时间:", false);
+ setCellCenter(detectionDate);
+
+ XWPFTableCell detectionResult = detectionTableHead.createCell();
+ detectionResult.removeParagraph(0);
+ createParaInCell(detectionResult, "采样结果:", false);
+ setCellCenter(detectionResult);
+
+ for (Detection detection : record.getDetectionList()) {
+ XWPFTableRow row = detectionTable.createRow();
+
+ XWPFTableCell name = row.getCell(0);
+ name.removeParagraph(0);
+ createParaInCell(name, detection.getName(), false);
+ setCellCenter(name);
+
+ XWPFTableCell date = row.getCell(1);
+ date.removeParagraph(0);
+ createParaInCell(date, formatDate(detection.getDate()), false);
+ setCellCenter(date);
+
+ XWPFTableCell result = row.getCell(2);
+ result.removeParagraph(0);
+ createParaInCell(result, detection.getResult(), false);
+ setCellCenter(result);
+ }
+
+
+ //调查信息
+ XWPFParagraph surveyInfo = document.createParagraph();
+ XWPFRun surveyInfoRun = surveyInfo.createRun();
+ String surveyInfoStr = "调查单位:" + record.getInvestigationCompany() + " " +
+ "调查者:" + wordUtil.userDao.selectUsername(record.getUserPhone()) + " " +
+ "调查时间:" + formatDate(record.getInvestigationDate());
+ surveyInfoRun.setText(surveyInfoStr);
+ setRunFont(surveyInfoRun, "仿宋", 11, false);
+
+
+ //八进制输出流
+ response.setContentType("application/octet-stream");
+
+ //这后面可以设置导出Excel的名称,此例中名为student.xls
+ response.setHeader("Content-disposition", "attachment;filename=" + record.getIdNumber() + ".docx");
+ document.write(response.getOutputStream());
+ }
+
+
+ public static XWPFTable createTableInCell(XWPFTableCell cell) {
+ cell.addParagraph();
+ XWPFTable table = cell.insertNewTbl(cell.getParagraphArray(1).getCTP().newCursor());
+ table.getCTTbl().addNewTblPr().addNewTblBorders()
+ .addNewLeft().setVal(STBorder.SINGLE);
+ table.getCTTbl().addNewTblPr().addNewTblBorders()
+ .addNewRight().setVal(STBorder.SINGLE);
+ table.getCTTbl().addNewTblPr().addNewTblBorders()
+ .addNewTop().setVal(STBorder.SINGLE);
+ table.getCTTbl().addNewTblPr().addNewTblBorders()
+ .addNewBottom().setVal(STBorder.SINGLE);
+ table.getCTTbl().addNewTblPr().addNewTblBorders()
+ .addNewInsideH().setVal(STBorder.SINGLE);
+ table.getCTTbl().addNewTblPr().addNewTblBorders()
+ .addNewInsideV().setVal(STBorder.SINGLE);
+
+ //设置表格水平居中
+ table.getCTTbl().getTblPr().addNewJc().setVal(STJc.CENTER);
+ //设置表格垂直居中
+ cell.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
+ table.setWidth(8000);
+
+ return table;
+ }
+
+ /**
+ * 设置单元格内容居中
+ */
+ public static void setCellCenter(XWPFTableCell cell) {
+ CTTc cttc = cell.getCTTc();
+ CTTcPr ctPr = cttc.addNewTcPr();
+ ctPr.addNewVAlign().setVal(STVerticalJc.CENTER);
+ cttc.getPList().get(0).addNewPPr().addNewJc().setVal(STJc.CENTER);
+ }
+
+ /**
+ * 在单元格中创建段落
+ */
+ public static void createParaInCell(XWPFTableCell cell, String text, boolean title) {
+ XWPFParagraph paragraph = cell.addParagraph();
+ paragraph.setAlignment(ParagraphAlignment.LEFT);
+ XWPFRun run = paragraph.createRun();
+ run.setText(text);
+ if (title) {
+ setRunFont(run, "仿宋", 14, true);
+ } else {
+ setRunFont(run, "仿宋", 11, false);
+ }
+ }
+
+ /**
+ * 换行
+ */
+ public static void createBreakLine(XWPFTableCell cell) {
+ cell.addParagraph().createRun().setText("\r");
+ }
+
+ /**
+ * 设置段落字体
+ */
+ public static void setRunFont(XWPFRun run, String font, int fontSize, boolean bold) {
+ run.setFontFamily(font);
+ run.getCTR().addNewRPr().addNewRFonts().setEastAsia(font);
+ run.setBold(bold);
+ run.setFontSize(fontSize);
+ }
+
+ /**
+ * 根据日期提取时间
+ *
+ * @param date 日期
+ * @return 格式化后的时间字符串 年-月-日
+ */
+ public static String formatDate(Date date) {
+ StringBuilder res = new StringBuilder();
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ res.append(calendar.get(Calendar.YEAR)).append("年");
+ res.append(calendar.get(Calendar.MONTH) + 1).append("月");
+ res.append(calendar.get(Calendar.DAY_OF_MONTH)).append("日");
+
+ return res.toString();
+ }
+
+ /**
+ * 根据日期提取时间
+ *
+ * @param date 日期
+ * @return 格式化后的时间字符串 年-月-日-时-分-秒
+ */
+ public static String formatTime(Date date) {
+ StringBuilder res = new StringBuilder();
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ res.append(calendar.get(Calendar.YEAR)).append("年");
+ res.append(calendar.get(Calendar.MONTH) + 1).append("月");
+ res.append(calendar.get(Calendar.DAY_OF_MONTH)).append("日");
+ res.append(calendar.get(Calendar.HOUR_OF_DAY)).append("时");
+ res.append(calendar.get(Calendar.MINUTE)).append("分");
+ res.append(calendar.get(Calendar.SECOND)).append("秒");
+
+ return res.toString();
+ }
+
+}
diff --git a/src/main/java/com/example/survey/vo/CreateRespondentVo.java b/src/main/java/com/example/survey/vo/CreateRespondentVo.java
new file mode 100644
index 0000000..b52aa25
--- /dev/null
+++ b/src/main/java/com/example/survey/vo/CreateRespondentVo.java
@@ -0,0 +1,55 @@
+package com.example.survey.vo;
+
+import com.example.survey.entity.inner.AdministrativeArea;
+import lombok.*;
+import org.springframework.data.mongodb.core.index.Indexed;
+
+/**
+ * @author Pope
+ */
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+public class CreateRespondentVo {
+ /**
+ * 身份证号
+ */
+ private String idNumber;
+
+ /**
+ * 电话
+ */
+ private String phoneNumber;
+
+ /**
+ * 姓名
+ */
+ private String name;
+
+ /**
+ * 备注
+ */
+ private String msg;
+
+ /**
+ * 分配的调查人员
+ */
+ private String userPhone;
+
+ /**
+ * 是否发病
+ */
+ private boolean diseased;
+
+ /**
+ * 性别
+ */
+ private String gender;
+
+ /**
+ * 行政区划
+ */
+ private AdministrativeArea administrativeArea;
+}
diff --git a/src/main/java/com/example/survey/vo/CreateRoleVo.java b/src/main/java/com/example/survey/vo/CreateRoleVo.java
new file mode 100644
index 0000000..e063568
--- /dev/null
+++ b/src/main/java/com/example/survey/vo/CreateRoleVo.java
@@ -0,0 +1,29 @@
+package com.example.survey.vo;
+
+import com.example.survey.entity.Role;
+import com.example.survey.enumeration.AuthEnum;
+import lombok.*;
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * @author Pope
+ */
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+public class CreateRoleVo {
+ private String roleName;
+ private List authList;
+
+ public CreateRoleVo(Role role) {
+ roleName = role.getName();
+ authList = new LinkedList<>();
+ for (AuthEnum authEnum : role.getAuthoritySet()) {
+ authList.add(authEnum.getName());
+ }
+ }
+}
diff --git a/src/main/java/com/example/survey/vo/SignupVo.java b/src/main/java/com/example/survey/vo/CreateUserVo.java
similarity index 57%
rename from src/main/java/com/example/survey/vo/SignupVo.java
rename to src/main/java/com/example/survey/vo/CreateUserVo.java
index f87ce7d..e74c32c 100644
--- a/src/main/java/com/example/survey/vo/SignupVo.java
+++ b/src/main/java/com/example/survey/vo/CreateUserVo.java
@@ -1,5 +1,6 @@
package com.example.survey.vo;
+import com.example.survey.entity.inner.AdministrativeArea;
import lombok.*;
/**
@@ -10,7 +11,11 @@ import lombok.*;
@ToString
@NoArgsConstructor
@AllArgsConstructor
-public class SignupVo {
+public class CreateUserVo {
+ /**
+ * 身份证号
+ */
+ private String idNumber;
/**
* 用户名
*/
@@ -23,4 +28,8 @@ public class SignupVo {
* 密码
*/
private String password;
+ /**
+ * 行政区划
+ */
+ private AdministrativeArea administrativeArea;
}
diff --git a/src/main/java/com/example/survey/vo/DeleteRoleVo.java b/src/main/java/com/example/survey/vo/DeleteRoleVo.java
new file mode 100644
index 0000000..80608ab
--- /dev/null
+++ b/src/main/java/com/example/survey/vo/DeleteRoleVo.java
@@ -0,0 +1,17 @@
+package com.example.survey.vo;
+
+import lombok.*;
+
+/**
+ * @author Pope
+ */
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+public class DeleteRoleVo {
+
+ private String roleName;
+
+}
diff --git a/src/main/java/com/example/survey/vo/DeleteUserVo.java b/src/main/java/com/example/survey/vo/DeleteUserVo.java
new file mode 100644
index 0000000..b965738
--- /dev/null
+++ b/src/main/java/com/example/survey/vo/DeleteUserVo.java
@@ -0,0 +1,17 @@
+package com.example.survey.vo;
+
+import lombok.*;
+
+/**
+ * @author Pope
+ */
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+public class DeleteUserVo {
+
+ private String phoneNumber;
+
+}
diff --git a/src/main/java/com/example/survey/vo/InvestigationRecordVo.java b/src/main/java/com/example/survey/vo/InvestigationRecordVo.java
index a68a13c..27fac3b 100644
--- a/src/main/java/com/example/survey/vo/InvestigationRecordVo.java
+++ b/src/main/java/com/example/survey/vo/InvestigationRecordVo.java
@@ -1,15 +1,12 @@
package com.example.survey.vo;
-import com.example.survey.entity.inner.Detection;
-import com.example.survey.entity.inner.EntryExperience;
-import com.example.survey.entity.inner.LiveAndTravelHistory;
-import com.example.survey.entity.inner.TempHistory;
+import com.example.survey.entity.inner.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.*;
-import org.springframework.data.mongodb.core.index.Indexed;
import java.util.Date;
import java.util.List;
+import java.util.Map;
/**
* @author Pope
@@ -194,8 +191,7 @@ public class InvestigationRecordVo {
* 调查者(身份证)
* 外键
*/
- @Indexed
- private String investigatorPhone;
+ private String userPhone;
/**
* 调查日期
@@ -210,15 +206,23 @@ public class InvestigationRecordVo {
private List tempHistoryList;
/**
- * 居旅史
+ * 居住史
*/
- private List liveAndTravelHistoryList;
+ private List liveHistoryList;
+
+ /**
+ * 旅行史
+ */
+ private List travelHistoryList;
/**
* 备注
*/
private String msg;
-
+ /**
+ * 存放一些url
+ */
+ private Map urlMap;
}
diff --git a/src/main/java/com/example/survey/vo/ModifyRoleVo.java b/src/main/java/com/example/survey/vo/ModifyRoleVo.java
new file mode 100644
index 0000000..92ca7f0
--- /dev/null
+++ b/src/main/java/com/example/survey/vo/ModifyRoleVo.java
@@ -0,0 +1,18 @@
+package com.example.survey.vo;
+
+import lombok.*;
+
+import java.util.List;
+
+/**
+ * @author Pope
+ */
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+public class ModifyRoleVo {
+ private String roleName;
+ private List authList;
+}
diff --git a/src/main/java/com/example/survey/vo/ResetPwdVo.java b/src/main/java/com/example/survey/vo/ResetPwdVo.java
new file mode 100644
index 0000000..9eb3327
--- /dev/null
+++ b/src/main/java/com/example/survey/vo/ResetPwdVo.java
@@ -0,0 +1,19 @@
+package com.example.survey.vo;
+
+import lombok.*;
+
+/**
+ * @author Pope
+ */
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+public class ResetPwdVo {
+
+ /**
+ * 电话号码
+ */
+ private String phoneNumber;
+}
diff --git a/src/main/java/com/example/survey/vo/ResultVo.java b/src/main/java/com/example/survey/vo/ResultVo.java
index 2c07069..c4d0eda 100644
--- a/src/main/java/com/example/survey/vo/ResultVo.java
+++ b/src/main/java/com/example/survey/vo/ResultVo.java
@@ -1,9 +1,16 @@
package com.example.survey.vo;
+import lombok.*;
+
/**
* @author Pope
* 返回结果类
*/
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
public class ResultVo {
public static final int SUCCESS = 0;
@@ -23,37 +30,4 @@ public class ResultVo {
* 数据
*/
private Object data;
-
- public ResultVo() {
- }
-
- public ResultVo(int code, String msg, Object data) {
- this.code = code;
- this.msg = msg;
- this.data = data;
- }
-
- public int getCode() {
- return code;
- }
-
- public void setCode(int code) {
- this.code = code;
- }
-
- public String getMsg() {
- return msg;
- }
-
- public void setMsg(String msg) {
- this.msg = msg;
- }
-
- public Object getData() {
- return data;
- }
-
- public void setData(Object data) {
- this.data = data;
- }
}
diff --git a/src/main/java/com/example/survey/vo/RoleVo.java b/src/main/java/com/example/survey/vo/RoleVo.java
index d836224..972039c 100644
--- a/src/main/java/com/example/survey/vo/RoleVo.java
+++ b/src/main/java/com/example/survey/vo/RoleVo.java
@@ -1,7 +1,10 @@
package com.example.survey.vo;
+import com.example.survey.entity.Role;
+import com.example.survey.enumeration.AuthEnum;
import lombok.*;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -13,6 +16,15 @@ import java.util.List;
@NoArgsConstructor
@AllArgsConstructor
public class RoleVo {
+
private String roleName;
- private List authList;
+ private List authorityList;
+
+ public RoleVo(Role role) {
+ roleName = role.getName();
+ authorityList = new ArrayList<>();
+ for (AuthEnum authEnum : role.getAuthoritySet()) {
+ authorityList.add(authEnum.getName());
+ }
+ }
}
diff --git a/src/main/java/com/example/survey/vo/UserInfoVo.java b/src/main/java/com/example/survey/vo/UserInfoVo.java
new file mode 100644
index 0000000..582590e
--- /dev/null
+++ b/src/main/java/com/example/survey/vo/UserInfoVo.java
@@ -0,0 +1,39 @@
+package com.example.survey.vo;
+
+import com.example.survey.entity.Department;
+import com.example.survey.entity.inner.AdministrativeArea;
+import lombok.*;
+
+import java.util.List;
+
+/**
+ * @author Pope
+ */
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+public class UserInfoVo {
+
+ /**
+ * 电话号码
+ */
+ private String phoneNumber;
+
+ /**
+ * 用户名
+ */
+ private String username;
+
+ /**
+ * 身份证号
+ */
+ private String idNumber;
+
+ /**
+ * 行政区划
+ */
+ private AdministrativeArea administrativeArea;
+
+}
diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml
new file mode 100644
index 0000000..9af5ce5
--- /dev/null
+++ b/src/main/resources/application-dev.yml
@@ -0,0 +1,13 @@
+spring:
+ data:
+ mongodb:
+ # uri: mongodb://cveo:cveo123456@120.78.177.67:27017/survey
+ #创建索引
+ auto-index-creation: true
+ host: 127.0.0.1
+ port: 27017
+ database: survey
+
+ redis:
+ host: 127.0.0.1
+ port: 6379
diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml
new file mode 100644
index 0000000..080eb38
--- /dev/null
+++ b/src/main/resources/application-prod.yml
@@ -0,0 +1,38 @@
+spring:
+ data:
+ mongodb:
+# uri: mongodb://cveo:cveo123456@120.78.177.67:27017/survey
+ #创建索引
+ auto-index-creation: true
+ host: mongo
+ port: 27017
+ database: survey
+ username: cveo
+ password: cveo123456
+ authentication-database: admin
+
+ redis:
+ host: redis
+ port: 6379
+ password: cveo
+
+# kafka:
+# bootstrap-servers: localhost:9092 # 指定kafka 代理地址,可以多个
+# producer: # 生产者
+# retries: 0 # 设置大于0的值,则客户端会将发送失败的记录重新发送
+# # 每次批量发送消息的数量
+# batch-size: 16384
+# buffer-memory: 33554432
+# # 指定消息key和消息体的编解码方式
+# key-serializer: org.apache.kafka.common.serialization.StringSerializer
+# value-serializer: org.apache.kafka.common.serialization.StringSerializer
+# consumer:
+# group-id: consumer-test
+# enable-auto-commit: true # 是否自动提交offset
+# auto-commit-interval: 100 # 提交offset延时(接收到消息后多久提交offset)
+# auto-offset-reset: latest
+# # 指定消息key和消息体的编解码方式
+# key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
+# value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
+# topic:
+# under-review: "under_review"
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 080eb38..9f96606 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -1,38 +1,3 @@
spring:
- data:
- mongodb:
-# uri: mongodb://cveo:cveo123456@120.78.177.67:27017/survey
- #创建索引
- auto-index-creation: true
- host: mongo
- port: 27017
- database: survey
- username: cveo
- password: cveo123456
- authentication-database: admin
-
- redis:
- host: redis
- port: 6379
- password: cveo
-
-# kafka:
-# bootstrap-servers: localhost:9092 # 指定kafka 代理地址,可以多个
-# producer: # 生产者
-# retries: 0 # 设置大于0的值,则客户端会将发送失败的记录重新发送
-# # 每次批量发送消息的数量
-# batch-size: 16384
-# buffer-memory: 33554432
-# # 指定消息key和消息体的编解码方式
-# key-serializer: org.apache.kafka.common.serialization.StringSerializer
-# value-serializer: org.apache.kafka.common.serialization.StringSerializer
-# consumer:
-# group-id: consumer-test
-# enable-auto-commit: true # 是否自动提交offset
-# auto-commit-interval: 100 # 提交offset延时(接收到消息后多久提交offset)
-# auto-offset-reset: latest
-# # 指定消息key和消息体的编解码方式
-# key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
-# value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
-# topic:
-# under-review: "under_review"
+ profiles:
+ active: prod
diff --git a/src/main/resources/log4j2-spring.xml b/src/main/resources/log4j2-spring.xml
new file mode 100644
index 0000000..9a13d1f
--- /dev/null
+++ b/src/main/resources/log4j2-spring.xml
@@ -0,0 +1,98 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/java/com/example/survey/controller/Init.http b/src/test/java/com/example/survey/controller/Init.http
index 7bd2080..9b0f519 100644
--- a/src/test/java/com/example/survey/controller/Init.http
+++ b/src/test/java/com/example/survey/controller/Init.http
@@ -1,35 +1,38 @@
-POST http://localhost:8080/role/role
+#创建流调人员权限
+POST http://{{host}}:{{port}}{{prefix}}/role/role
Content-Type: application/json
{
"roleName": "流调人员",
"authList": [
- 1,
- 2,
- 3,
- 5,
- 6,
- 8,
- 9,
- 10
+ "查询调查记录的权限",
+ "提交调查记录权限",
+ "修改调查记录权限",
+ "删除调查记录权限",
+ "分析调查记录权限",
+ "查询流调人员信息的权限",
+ "增删改调查对象信息的权限",
+ "查询调查对象信息的权限"
]
}
###
-POST http://localhost:8080/role/role
+#创建管理员权限
+POST http://{{host}}:{{port}}{{prefix}}/role/role
Content-Type: application/json
{
"roleName": "管理员",
"authList": [
- 0
+ "管理员"
]
}
###
-POST http://{{host}}:8080/user/signup
+#注册用户
+POST http://{{host}}:{{port}}{{prefix}}/user/signup
Content-Type: application/json
{
@@ -40,10 +43,16 @@ Content-Type: application/json
###
-PUT http://localhost:8080/user/userRole
+#修改用户为管理员权限
+PUT http://{{host}}:{{port}}{{prefix}}/user/userRole
Content-Type:application/json
{
-"phoneNumber": "123456789",
-"roleNameList": ["管理员"]
+ "phoneNumber": "123456789",
+ "roleNameList": [
+ "管理员"
+ ]
}
+
+###
+
diff --git a/src/test/java/com/example/survey/controller/InvestigationRecordApi.http b/src/test/java/com/example/survey/controller/InvestigationRecordApi.http
index 156fe1c..6f60c44 100644
--- a/src/test/java/com/example/survey/controller/InvestigationRecordApi.http
+++ b/src/test/java/com/example/survey/controller/InvestigationRecordApi.http
@@ -2,10 +2,11 @@
#提交调查记录
POST http://localhost:8080/investigationRecord/investigationRecord
Content-Type: application/json
+Authorization: 845a6d23-8d84-4a2d-85db-4f7e99c272bd
{
- "questionnaireNumber": "002",
- "idNumber": "420704200002270011",
+ "questionnaireNumber": "001",
+ "idNumber": "420704200002270014",
"name": "Pope0",
"gender": "男",
"overseasCase": false,
@@ -65,7 +66,7 @@ Content-Type: application/json
}
],
"investigationCompany": "武汉大学",
- "investigatorPhone": "13995833301",
+ "userPhone": "cveo",
"investigationDate": "2021-1-28",
"tempHistoryList": [
{
@@ -81,42 +82,54 @@ Content-Type: application/json
],
"beginTime": "2021-1-28",
"endTime": "2021-1-29",
- "location": "鄂州市",
+ "location": {
+ "msg": "鄂州市",
+ "longitude": 100,
+ "latitude": 100
+ },
"detail": "详细描述"
}
],
- "msg": "备注信息"
+ "msg": "备注信息",
+ "urlMap":{
+ "msg1": "url1",
+ "msg2": "url2"
+ }
}
###
#查询调查记录
GET http://localhost:8080/investigationRecord/underReviewRecord?currentPage=0&state=待审核
+Authorization: 845a6d23-8d84-4a2d-85db-4f7e99c272bd
###
#查询未审核记录数量
-GET http://localhost:8080/investigationRecord/underReviewRecordCount?investigatorPhone=13995833300
+GET http://localhost:8080/investigationRecord/underReviewRecordCount?userPhone=cveo
+Authorization: 845a6d23-8d84-4a2d-85db-4f7e99c272bd
+
###
-
PUT http://localhost:8080/investigationRecord/underReviewRecord
Content-Type: application/json
+Authorization: 845a6d23-8d84-4a2d-85db-4f7e99c272bd
+
{
- "idNumber": "420704200002270011",
+ "idNumber": "420704200002270014",
"pass": true,
"passInformation": "经审核通过",
- "reviewerPhone": "13995833300"
+ "reviewerPhone": "cveo"
}
###
-
-#查询
+#修改记录提交
PUT http://localhost:8080/investigationRecord/investigationRecord
Content-Type: application/json
+Authorization: 845a6d23-8d84-4a2d-85db-4f7e99c272bd
{
- "questionnaireNumber": "002",
- "idNumber": "420704200002270011",
+ "questionnaireNumber": "001",
+ "idNumber": "420704200002270014",
"name": "Pope0",
"gender": "女",
"overseasCase": false,
@@ -176,7 +189,7 @@ Content-Type: application/json
}
],
"investigationCompany": "武汉大学",
- "investigatorPhone": "13995833301",
+ "userPhone": "cveo",
"investigationDate": "2021-1-28",
"tempHistoryList": [
{
@@ -192,9 +205,20 @@ Content-Type: application/json
],
"beginTime": "2021-1-28",
"endTime": "2021-1-29",
- "location": "鄂州市",
+ "location": {
+ "msg": "鄂州市",
+ "longitude": 100,
+ "latitude": 100
+ },
"detail": "详细描述"
}
],
- "msg": "备注信息"
+ "msg": "备注信息",
+ "urlMap":{
+ "msg1": "url1",
+ "msg2": "url2"
+ }
}
+
+###
+GET http://{{host}}:{{port}}{{prefix}}/investigationRecord/record2word?idNumber=420704200002270011
diff --git a/src/test/java/com/example/survey/controller/InvestigatorApi.http b/src/test/java/com/example/survey/controller/InvestigatorApi.http
deleted file mode 100644
index 7b586c4..0000000
--- a/src/test/java/com/example/survey/controller/InvestigatorApi.http
+++ /dev/null
@@ -1,13 +0,0 @@
-
-#创建流调人员
-POST http://localhost:8080/investigator/investigator
-Content-Type: application/json
-Authorization: fcf3f723-5a65-45ad-a518-f92e1c32b948
-
-{
- "idNumber": null,
- "name": "Pope2",
- "phoneNumber": "13995833302"
-}
-
-###
diff --git a/src/test/java/com/example/survey/controller/RespondentApi.http b/src/test/java/com/example/survey/controller/RespondentApi.http
index 31f6266..3dd2a07 100644
--- a/src/test/java/com/example/survey/controller/RespondentApi.http
+++ b/src/test/java/com/example/survey/controller/RespondentApi.http
@@ -3,20 +3,26 @@
#创建调查对象
POST http://{{host}}:{{port}}{{prefix}}/respondent/respondent
Content-Type: application/json
-Authorization: cb94336e-f849-4e04-b956-9d8f71fe7830
+Authorization: 845a6d23-8d84-4a2d-85db-4f7e99c272bd
{
- "idNumber": "420704200002270014",
- "phoneNumber": "13995833308",
- "name": "Pope4",
- "msg": "无备注",
- "investigatorPhone": "123456789",
- "diseased": false,
- "gender": "男"
+ "idNumber": "420704200002270014",
+ "phoneNumber": "13995833300",
+ "name": "Pope0",
+ "msg": "无备注",
+ "userPhone": "cveo",
+ "diseased": false,
+ "gender": "男",
+ "administrativeArea": {
+ "province": "湖北省",
+ "city": "鄂州市",
+ "county": "鄂城区"
+ }
}
###
#根据流调人员id分页查询待调查对象列表
-GET http://localhost:8080/respondent/respondent?investigatorPhone=13995833300¤tPage=0
+GET http://localhost:8080/respondent/respondent?userPhone=cveo&province=湖北省¤tPage=0
+Authorization: 845a6d23-8d84-4a2d-85db-4f7e99c272bd
diff --git a/src/test/java/com/example/survey/controller/RoleControllerApi.http b/src/test/java/com/example/survey/controller/RoleControllerApi.http
index 76ff904..29ebe8a 100644
--- a/src/test/java/com/example/survey/controller/RoleControllerApi.http
+++ b/src/test/java/com/example/survey/controller/RoleControllerApi.http
@@ -1,26 +1,79 @@
+
+#添加流调人员角色
POST http://localhost:8080/role/role
Content-Type: application/json
+Authorization: 845a6d23-8d84-4a2d-85db-4f7e99c272bd
{
- "roleName": "流调人员",
+ "roleName": "测试角色",
"authList": [
- 1,
- 2,
- 3,
- 5,
- 6,
- 8,
- 9,
- 10
+ "查询调查记录的权限",
+ "提交调查记录权限",
+ "修改调查记录权限",
+ "删除调查记录权限",
+ "分析调查记录权限",
+ "查询流调人员信息的权限",
+ "增删改调查对象信息的权限",
+ "查询调查对象信息的权限"
]
}
+
###
+#添加管理员角色
POST http://localhost:8080/role/role
Content-Type: application/json
{
"roleName": "管理员",
"authList": [
- 0
+ "管理员"
]
}
+
+###
+#添加测试角色
+POST http://{{host}}:{{port}}{{prefix}}/role/role
+Content-Type: application/json
+Authorization: 958efa46-44c3-4271-b44a-cc1b7e8e8d2e
+
+{
+ "roleName": "测试角色",
+ "authList": [
+ "管理员"
+ ]
+}
+
+###
+#查询角色
+GET http://{{host}}:{{port}}{{prefix}}/role/role?currentPage=0
+Authorization: 845a6d23-8d84-4a2d-85db-4f7e99c272bd
+
+###
+#删除角色
+DELETE http://{{host}}:{{port}}{{prefix}}/role/role
+Content-Type: application/json
+Authorization: 845a6d23-8d84-4a2d-85db-4f7e99c272bd
+
+{
+ "roleName": "测试角色"
+}
+
+
+###
+#修改角色权限
+PUT http://{{host}}:{{port}}{{prefix}}/role/role
+Content-Type: application/json
+Authorization: 845a6d23-8d84-4a2d-85db-4f7e99c272bd
+
+{
+ "roleName": "测试角色",
+ "authList": [
+ "查询调查记录的权限"
+ ]
+}
+
+
+
+###
+GET http://{{host}}:{{port}}{{prefix}}/role/authList
+Authorization: 845a6d23-8d84-4a2d-85db-4f7e99c272bd
diff --git a/src/test/java/com/example/survey/controller/UserControllerApi.http b/src/test/java/com/example/survey/controller/UserControllerApi.http
index 453d8b5..cd114aa 100644
--- a/src/test/java/com/example/survey/controller/UserControllerApi.http
+++ b/src/test/java/com/example/survey/controller/UserControllerApi.http
@@ -1,19 +1,23 @@
-POST http://localhost:8080/user/signup
+#注册用户
+POST http://{{host}}:{{port}}{{prefix}}/user/signup
Content-Type: application/json
{
- "username": "cveo",
- "phoneNumber": "123456789",
- "password": "cveo123456"
+ "username": "Pope0",
+ "phoneNumber": "13995833300",
+ "password": "13995833308"
}
###
-PUT http://localhost:8080/user/userRole
+
+#修改用户权限
+PUT http://{{host}}:{{port}}{{prefix}}/user/userRole
Content-Type:application/json
+Authorization: 845a6d23-8d84-4a2d-85db-4f7e99c272bd
{
- "phoneNumber": "123456789",
- "roleNameList": ["管理员"]
+ "phoneNumber": "13995833308",
+ "roleNameList": ["测试角色"]
}
###
@@ -21,6 +25,65 @@ POST http://{{host}}:{{port}}{{prefix}}/user/login
Content-Type: application/json
{
- "phoneNumber": "123456789",
+ "phoneNumber": "cveo",
"password": "cveo123456"
}
+
+###
+GET http://{{host}}:{{port}}{{prefix}}/user/user?currentPage=0
+Authorization: 845a6d23-8d84-4a2d-85db-4f7e99c272bd
+
+###
+DELETE http://{{host}}:{{port}}{{prefix}}/user/user
+Content-Type: application/json
+Authorization: 845a6d23-8d84-4a2d-85db-4f7e99c272bd
+
+{
+ "phoneNumber": "13995833308"
+}
+
+###
+
+#用户信息修改
+PUT http://{{host}}:{{port}}{{prefix}}/user/userInfo
+Content-Type: application/json
+Authorization: 8f54a7d3-b82b-4059-ab46-ac9eae545796
+
+{
+ "phoneNumber": "13995833308",
+ "username": "Pope",
+ "idNumber": "420704200002270011",
+ "administrativeArea": {
+ "province": "湖北省",
+ "city": "鄂州市"
+ }
+}
+
+###
+
+#用户密码重置
+PUT http://{{host}}:{{port}}{{prefix}}/user/pwd
+Content-Type: application/json
+Authorization: 8f54a7d3-b82b-4059-ab46-ac9eae545796
+
+{
+ "phoneNumber": "13995833308"
+}
+
+###
+
+#添加用户
+POST http://{{host}}:{{port}}{{prefix}}/user/user
+Content-Type: application/json
+Authorization: 8f54a7d3-b82b-4059-ab46-ac9eae545796
+
+{
+ "idNumber": "420704200002270010",
+ "username": "Pope0",
+ "phoneNumber": "139958333000",
+ "password": "139958333008",
+ "administrativeArea": {
+ "province": "湖北省",
+ "city": "鄂州市"
+ }
+}
diff --git a/src/test/java/com/example/survey/controller/http-client.env.json b/src/test/java/com/example/survey/controller/http-client.env.json
index 01c91e9..29bccfd 100644
--- a/src/test/java/com/example/survey/controller/http-client.env.json
+++ b/src/test/java/com/example/survey/controller/http-client.env.json
@@ -1,6 +1,6 @@
{
"dev": {
- "host": "120.78.177.67",
+ "host": "127.0.0.1",
"port": "8080",
"prefix": ""
},
@@ -8,5 +8,10 @@
"host": "8.136.133.77",
"port": "8081",
"prefix": "/backend"
+ },
+ "pope": {
+ "host": "http://pope.cn1.utools.club",
+ "port": "",
+ "prefix": ""
}
}