From 96d116fe5d5ef0ddbe3810cedc80681c56e71ea4 Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Thu, 7 Jul 2022 08:57:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8E=A5=E5=8F=A3=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E4=BB=A3=E7=90=86=E7=BB=84=E7=BB=87=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xkrs/common/config/WebSecurityConfig.java | 1 + .../xkrs/controller/SysUserController.java | 43 +++++-------------- 2 files changed, 12 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java index 8507578..247ab1d 100644 --- a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java +++ b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java @@ -60,6 +60,7 @@ class WebSecurityConfig extends WebSecurityConfigurerAdapter { .antMatchers(HttpMethod.GET, "/selectFirePointByCode").permitAll() .antMatchers(HttpMethod.POST, "/updateTypeByFireCode").permitAll() .antMatchers(HttpMethod.GET, "/api/user/verificationCode").permitAll() + .antMatchers(HttpMethod.GET, "/api/user/selectAgentOrgList").permitAll()//获取代理组织列表 .antMatchers(HttpMethod.POST, "/uploadFileMore").permitAll() .antMatchers(HttpMethod.POST, "/uploadFile").permitAll() .antMatchers(HttpMethod.GET, "/api/user/verificationCodeUpdate").permitAll() diff --git a/src/main/java/com/xkrs/controller/SysUserController.java b/src/main/java/com/xkrs/controller/SysUserController.java index fda6b1e..3a43b33 100644 --- a/src/main/java/com/xkrs/controller/SysUserController.java +++ b/src/main/java/com/xkrs/controller/SysUserController.java @@ -20,6 +20,7 @@ import com.xkrs.utils.FirePointCodeUtils; import com.xkrs.utils.RandomUtil; import org.apache.hc.core5.util.TextUtils; import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.data.domain.Sort; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.BindingResult; import org.springframework.validation.annotation.Validated; @@ -43,6 +44,9 @@ import static com.xkrs.utils.EncryptDecryptUtil.encry256; @RequestMapping(value = "/api/user") public class SysUserController { + // 获取区域信息 + private final Locale locale = LocaleContextHolder.getLocale(); + @Resource private SysUserService sysUserService; @@ -64,8 +68,6 @@ public class SysUserController { @Transactional(rollbackFor = Exception.class) @RequestMapping(value = "/updateviplevel", method = RequestMethod.POST) public String updateVipLevel(@RequestBody SysUserVipLevelQo sysUserVipLevelQo) { - // 获取区域信息 - Locale locale = LocaleContextHolder.getLocale(); String ids = sysUserVipLevelQo.getIds(); List idList = new ArrayList<>(); if (ids.contains(",")) { @@ -90,8 +92,6 @@ public class SysUserController { @Transactional(rollbackFor = Exception.class) @RequestMapping(value = "/updatereceivesms", method = RequestMethod.POST) public String updateReceiveSms(@RequestBody SysUserReceiveSmsQo sysUserReceiveSmsQo) { - // 获取区域信息 - Locale locale = LocaleContextHolder.getLocale(); String ids = sysUserReceiveSmsQo.getIds(); List idList = new ArrayList<>(); if (ids.contains(",")) { @@ -113,8 +113,6 @@ public class SysUserController { @Transactional(rollbackFor = Exception.class) @RequestMapping(value = "/updateremark", method = RequestMethod.POST) public String updateRemark(@RequestBody SysUserRemarkQo sysUserRemarkQo) { - // 获取区域信息 - Locale locale = LocaleContextHolder.getLocale(); Integer id = sysUserRemarkQo.getId(); Optional optionalById = sysUserDao.findById(id); if (optionalById.isEmpty()) { @@ -129,14 +127,12 @@ public class SysUserController { */ @RequestMapping(value = "/logged/check", method = RequestMethod.POST) public String loginUserTokenCheck() { - Locale locale = LocaleContextHolder.getLocale(); return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "", locale); } @RequestMapping(value = "/check/duplicate", method = RequestMethod.POST) public String checkDuplicate(@RequestParam(value = "userName", required = false) String userName) { - // 获取区域信息 - Locale locale = LocaleContextHolder.getLocale(); + // 验证用户名是否重复 if (!sysUserService.checkUserName(userName)) { return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, "", locale); @@ -144,13 +140,17 @@ public class SysUserController { return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "OK", locale); } + @GetMapping("/selectAgentOrgList") + public String selectAgentOrgList() { + List agentOrgList= agentOrgDao.findAll(Sort.by(Sort.Direction.ASC, "id")); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, agentOrgList, locale); + } + /** * 注册系统用户 */ @RequestMapping(value = "/add", method = RequestMethod.POST) public String addUser(@Validated({SysUserQoInsert.class}) @RequestBody SysUserQo userQo, BindingResult bindingResult, HttpServletRequest servletRequest) { - // 获取区域信息 - Locale locale = LocaleContextHolder.getLocale(); // 验证数据合法性 if (bindingResult.hasErrors()) { return outputEncapsulationErrorList(bindingResult.getFieldErrors(), locale); @@ -176,8 +176,6 @@ public class SysUserController { */ @RequestMapping(value = "/general/delete", method = RequestMethod.DELETE) public String deleteCustomUser(@RequestParam(value = "userId", required = false) int id) { - // 获取区域信息 - Locale locale = LocaleContextHolder.getLocale(); // 验证数据合法性 int res = sysUserService.softDeleteGeneralUser(id); if (res == 1) { @@ -189,8 +187,6 @@ public class SysUserController { @RequestMapping(value = "/update", method = RequestMethod.POST) public String updateUser(@Validated({SysUserQoUpdate.class}) @RequestBody SysUserQo userQo, BindingResult bindingResult) { - // 获取区域信息 - Locale locale = LocaleContextHolder.getLocale(); // 验证数据合法性 if (bindingResult.hasErrors()) { return outputEncapsulationErrorList(bindingResult.getFieldErrors(), locale); @@ -205,8 +201,6 @@ public class SysUserController { */ @GetMapping("/booleanUserName") public String booleanUserName(@RequestParam("userName") String userName) { - // 获取区域信息 - Locale locale = LocaleContextHolder.getLocale(); Map map = new HashMap(3); SysUserEntity sysUserEntity = sysUserDao.selectByUserName(userName); if (sysUserEntity == null) { @@ -223,8 +217,6 @@ public class SysUserController { */ @GetMapping("/selectAllUser") public String selectAllUser(@RequestHeader(value = "Authorization") String token) { - // 获取区域信息 - Locale locale = LocaleContextHolder.getLocale(); // 验证token String tokenUserName = TokenUtil.getTokenUserName(token); SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName); @@ -245,8 +237,6 @@ public class SysUserController { public String operateActiveFlag(@RequestBody Map map, @RequestHeader(value = "Authorization") String token) { Integer userId = (Integer) map.get("userId"); String keepType = (String) map.get("keepType"); - // 获取区域信息 - Locale locale = LocaleContextHolder.getLocale(); // 验证token String tokenUserName = TokenUtil.getTokenUserName(token); SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName); @@ -268,8 +258,6 @@ public class SysUserController { */ @PostMapping("/updatePassword") public String updatePassword(@RequestBody Map map, @RequestHeader(value = "Authorization") String token) { - // 获取区域信息 - Locale locale = LocaleContextHolder.getLocale(); String oldPassword = (String) map.get("oldPassword"); String newPassword = (String) map.get("newPassword"); String confirmPassword = (String) map.get("confirmPassword"); @@ -287,8 +275,6 @@ public class SysUserController { */ @PostMapping("/adminUpdatePassword") public String adminUpdatePassword(@RequestBody Map map, @RequestHeader(value = "Authorization") String token) { - // 获取区域信息 - Locale locale = LocaleContextHolder.getLocale(); // 要修改的用户的id Integer userId = (Integer) map.get("userId"); String newPassword = (String) map.get("newPassword"); @@ -308,8 +294,6 @@ public class SysUserController { @Transactional(rollbackFor = Exception.class) @PostMapping("/userUnRememberPassword") public String userUnRememberPassword(@RequestBody Map map) { - // 获取区域信息 - Locale locale = LocaleContextHolder.getLocale(); String phone = (String) map.get("phone"); String newPassword = (String) map.get("newPassword"); String confirmPassword = (String) map.get("confirmPassword"); @@ -330,8 +314,6 @@ public class SysUserController { */ @GetMapping("/verificationCode") public String verificationCode(@RequestParam("phone") String phone, @RequestParam(value = "agentOrgId", required = false) String agentOrgId) throws Exception { - // 获取区域信息 - Locale locale = LocaleContextHolder.getLocale(); Long finalAgentOrgId = Long.parseLong(TextUtils.isEmpty(agentOrgId) ? "1" : agentOrgId); List agentOrgList = agentOrgDao.findAll(); String targetAgentOrgName = FirePointCodeUtils.getTargetAgentOrgName(finalAgentOrgId, agentOrgList); @@ -346,8 +328,6 @@ public class SysUserController { */ @GetMapping("/verificationCodeUpdate") public String verificationCodeUpdate(@RequestParam("phone") String phone) throws Exception { - // 获取区域信息 - Locale locale = LocaleContextHolder.getLocale(); SysUserVo sysUserVo = sysUserDao.selectUserByUserName(phone); if (sysUserVo == null) { return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "手机号错误,请使用您注册的手机号", locale); @@ -365,7 +345,6 @@ public class SysUserController { */ @GetMapping("/getVerificationCode") public String getVerificationCode(@RequestParam("phone") String phone, @RequestParam("verificationCode") String verificationCode) { - Locale locale = LocaleContextHolder.getLocale(); String o = (String) redisService.get(phone); if ("".equals(o) || o == null) { return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "请先发送验证码!", locale);