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);