From fe923f19877500f3f95bb55d1853ffd129e01f1d Mon Sep 17 00:00:00 2001 From: wanggeng <450292408@qq.com> Date: Mon, 28 Nov 2022 09:52:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BD=91=E7=AB=99=E7=94=A8=E6=88=B7=E4=B8=AA?= =?UTF-8?q?=E4=BA=BA=E4=BF=A1=E6=81=AF=E6=9B=B4=E6=96=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/userexpand/UserExpandController.java | 2 +- .../userexpand/UserExpandAppController.java | 2 +- .../userexpand/IUserExpandService.java | 2 +- .../impl/UserExpandServiceImpl.java | 43 ++++++++----------- 4 files changed, 20 insertions(+), 29 deletions(-) diff --git a/src/main/java/cn/com/tenlion/xzszwhy/base/controller/api/userexpand/UserExpandController.java b/src/main/java/cn/com/tenlion/xzszwhy/base/controller/api/userexpand/UserExpandController.java index 439f7c3..604a3b9 100644 --- a/src/main/java/cn/com/tenlion/xzszwhy/base/controller/api/userexpand/UserExpandController.java +++ b/src/main/java/cn/com/tenlion/xzszwhy/base/controller/api/userexpand/UserExpandController.java @@ -43,7 +43,7 @@ public class UserExpandController extends DefaultBaseController { @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @PutMapping("update-byuserid/{userId}") @CheckRequestBodyAnnotation - public SuccessResult update(@PathVariable("userId") String userId, @RequestBody UserExpandVO userExpandVO) { + public SuccessResult update(@PathVariable("userId") String userId, @RequestBody UserExpandVO userExpandVO) throws Exception { userExpandService.updateByUserId(null, userId, userExpandVO); return new SuccessResult(); } diff --git a/src/main/java/cn/com/tenlion/xzszwhy/base/controller/app/api/userexpand/UserExpandAppController.java b/src/main/java/cn/com/tenlion/xzszwhy/base/controller/app/api/userexpand/UserExpandAppController.java index 587f6a0..e56fba3 100644 --- a/src/main/java/cn/com/tenlion/xzszwhy/base/controller/app/api/userexpand/UserExpandAppController.java +++ b/src/main/java/cn/com/tenlion/xzszwhy/base/controller/app/api/userexpand/UserExpandAppController.java @@ -44,7 +44,7 @@ public class UserExpandAppController extends DefaultBaseController { @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @PutMapping("update-byuserid/{userId}") @CheckRequestBodyAnnotation - public SuccessResult updateUserExpand(@RequestHeader("token") String token, @PathVariable("userId") String userId, @RequestBody UserExpandVO userExpandVO) { + public SuccessResult updateUserExpand(@RequestHeader("token") String token, @PathVariable("userId") String userId, @RequestBody UserExpandVO userExpandVO) throws Exception { userExpandService.updateByUserId(token, userId, userExpandVO); return new SuccessResult(); } diff --git a/src/main/java/cn/com/tenlion/xzszwhy/base/service/userexpand/IUserExpandService.java b/src/main/java/cn/com/tenlion/xzszwhy/base/service/userexpand/IUserExpandService.java index eb6ea8b..51d731c 100644 --- a/src/main/java/cn/com/tenlion/xzszwhy/base/service/userexpand/IUserExpandService.java +++ b/src/main/java/cn/com/tenlion/xzszwhy/base/service/userexpand/IUserExpandService.java @@ -35,7 +35,7 @@ public interface IUserExpandService extends IUserExpandBaseService params = super.getHashMap(3); - params.put("userId",userId); + Map params = super.getHashMap(3); + params.put("userId", userId); UserExpandDTO userExpandDTO = this.get(params); - if(userExpandDTO == null){ + if (userExpandDTO == null) { userExpandDTO = new UserExpandDTO(); } userExpandDTO.setUserName(userDTO.getUserName()); @@ -69,32 +69,28 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx } - public void updateByUserId(String token, String userId, UserExpandVO userExpandVO){ - Map params = super.getHashMap(1); + public void updateByUserId(String token, String userId, UserExpandVO userExpandVO) throws Exception { + Map params = super.getHashMap(1); params.put("userId", userId); UserExpandDTO userExpandDTO = this.get(params); // 1.保存拓展信息 - if(userExpandDTO == null){ + if (userExpandDTO == null) { this.saveReturnId(token, userId, userExpandVO); - }else{ - this.update(token,userExpandDTO.getUserExpandId(),userExpandVO); + } else { + this.update(token, userExpandDTO.getUserExpandId(), userExpandVO); + } + if (StringUtils.isBlank(token)) { + return; } // 2.更新用户信息 UpdateUserVO updateUserVO = new UpdateUserVO(); - try { - updateUserVO.setName(userExpandVO.getName()); - updateUserVO.setPhone(userExpandVO.getPhone()); - updateUserVO.setEmail(userExpandVO.getEmail()); - userService.updateInfo(token,updateUserVO); - } catch (Exception e) { - throw new UpdateException("更新用户信息失败"); - } - - + updateUserVO.setName(userExpandVO.getName()); + updateUserVO.setPhone(userExpandVO.getPhone()); + updateUserVO.setEmail(userExpandVO.getEmail()); + userService.updateInfo(token, updateUserVO); } - @Override public UserExpandDTO getByUsername(String username) { return null; @@ -137,11 +133,6 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx } - - - - - @Override public void save(UserExpandVO userExpandVO) { saveReturnId(userExpandVO); @@ -156,6 +147,7 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx public String saveReturnId(UserExpandVO userExpandVO) { return saveReturnId(null, userExpandVO); } + @Override public String saveReturnId(String token, UserExpandVO userExpandVO) { String userExpandId = UUIDUtil.getUUID(); @@ -287,7 +279,6 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx } - @Override public Integer count(Map params) { Integer count = userExpandDao.count(params);