From 8e2e54de3a462a38a5a65e3268979cde133423e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=8C=E7=8B=BC=E8=93=9D=E5=A4=A9?= Date: Fri, 8 Nov 2024 11:17:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=94=A8=E6=88=B7=E6=9B=B4=E6=94=B9?= =?UTF-8?q?=E8=87=AA=E5=B7=B1=E5=9F=BA=E6=9C=AC=E4=BF=A1=E6=81=AF=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../harmony/controller/AuthController.java | 2 -- .../harmony/controller/UserController.java | 9 +++++++++ .../guaiguailang/harmony/mapper/UserMapper.java | 2 ++ .../guaiguailang/harmony/service/UserService.java | 2 ++ .../harmony/service/impl/UserServiceImpl.java | 14 ++++++++++++++ 5 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/guaiguailang/harmony/controller/AuthController.java b/src/main/java/com/guaiguailang/harmony/controller/AuthController.java index f51cd5c..b3b8fd9 100644 --- a/src/main/java/com/guaiguailang/harmony/controller/AuthController.java +++ b/src/main/java/com/guaiguailang/harmony/controller/AuthController.java @@ -7,10 +7,8 @@ import com.guaiguailang.harmony.domain.entity.MenuDataItem; import com.guaiguailang.harmony.domain.entity.SystemRole; import com.guaiguailang.harmony.domain.entity.SystemRoleMenu; import com.guaiguailang.harmony.domain.vo.ResponseResult; -import com.guaiguailang.harmony.domain.vo.SystemRoleMenuVO; import com.guaiguailang.harmony.service.AuthService; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; diff --git a/src/main/java/com/guaiguailang/harmony/controller/UserController.java b/src/main/java/com/guaiguailang/harmony/controller/UserController.java index 67f3b5d..36e5471 100644 --- a/src/main/java/com/guaiguailang/harmony/controller/UserController.java +++ b/src/main/java/com/guaiguailang/harmony/controller/UserController.java @@ -122,4 +122,13 @@ public class UserController { public ResponseEntity deleteUserRealy(@RequestBody ParamUserAdd userAddParam){ return ResponseEntity.ok(userService.deleteUserReay(userAddParam)); } + @Operation( + summary = "用户 更新", + description = "用户更新(不涉及密码)", + tags = {"用户相关接口"} + ) + @PostMapping("/self/update-base-info") + public ResponseEntity selfUpdateUserInfo(@RequestBody ParamUserAdd userAddParam){ + return ResponseEntity.ok(userService.selfUpdateUserInfo(userAddParam)); + } } diff --git a/src/main/java/com/guaiguailang/harmony/mapper/UserMapper.java b/src/main/java/com/guaiguailang/harmony/mapper/UserMapper.java index a7d6883..3ddac85 100644 --- a/src/main/java/com/guaiguailang/harmony/mapper/UserMapper.java +++ b/src/main/java/com/guaiguailang/harmony/mapper/UserMapper.java @@ -42,4 +42,6 @@ public interface UserMapper extends BaseMapper { SystemRole getRoleLevelByUserId(Long id); @Update("update user_info set deleted=1 where id=#{id}") Integer changeDelete(Long id); + @Update("update user_info set name=#{name},email=#{email},telephone=#{telephone} where id=#{id}") + Integer selfUpdateUserInfo(Long id, String name, String email, String telephone); } diff --git a/src/main/java/com/guaiguailang/harmony/service/UserService.java b/src/main/java/com/guaiguailang/harmony/service/UserService.java index e8185e3..3513b8c 100644 --- a/src/main/java/com/guaiguailang/harmony/service/UserService.java +++ b/src/main/java/com/guaiguailang/harmony/service/UserService.java @@ -23,4 +23,6 @@ public interface UserService { ResponseResult deleteUser(ParamUserAdd userAddParam); ResponseResult deleteUserReay(ParamUserAdd userAddParam); + + ResponseResult selfUpdateUserInfo(ParamUserAdd userAddParam); } diff --git a/src/main/java/com/guaiguailang/harmony/service/impl/UserServiceImpl.java b/src/main/java/com/guaiguailang/harmony/service/impl/UserServiceImpl.java index 2621e6c..576c3f2 100644 --- a/src/main/java/com/guaiguailang/harmony/service/impl/UserServiceImpl.java +++ b/src/main/java/com/guaiguailang/harmony/service/impl/UserServiceImpl.java @@ -13,6 +13,7 @@ import com.guaiguailang.harmony.mapper.UserMapper; import com.guaiguailang.harmony.service.UserService; import com.guaiguailang.harmony.utils.PasswordEncryptor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -280,6 +281,19 @@ return ResponseResult.error("删除失败"); } } + @Override + public ResponseResult selfUpdateUserInfo(ParamUserAdd userAddParam) { + if (StringUtils.isAnyBlank(userAddParam.getId().toString(),userAddParam.getName())) { + return ResponseResult.error("请输入昵称"); + } + Integer result = userMapper.selfUpdateUserInfo(userAddParam.getId(),userAddParam.getName(),userAddParam.getEmail(),userAddParam.getTelphone()); + if (result==1){ + return ResponseResult.success(); + }else { + return ResponseResult.error("删除失败"); + } + } + // 方法 public UserInfo getUserByAccount(String username){ return userMapper.getUserByAccount(username);