feat: 用户更改自己基本信息功能

This commit is contained in:
萌狼蓝天 2024-11-08 11:17:15 +08:00
parent 74807cfa96
commit 8e2e54de3a
5 changed files with 27 additions and 2 deletions

View File

@ -7,10 +7,8 @@ import com.guaiguailang.harmony.domain.entity.MenuDataItem;
import com.guaiguailang.harmony.domain.entity.SystemRole; import com.guaiguailang.harmony.domain.entity.SystemRole;
import com.guaiguailang.harmony.domain.entity.SystemRoleMenu; import com.guaiguailang.harmony.domain.entity.SystemRoleMenu;
import com.guaiguailang.harmony.domain.vo.ResponseResult; import com.guaiguailang.harmony.domain.vo.ResponseResult;
import com.guaiguailang.harmony.domain.vo.SystemRoleMenuVO;
import com.guaiguailang.harmony.service.AuthService; import com.guaiguailang.harmony.service.AuthService;
import io.swagger.v3.oas.annotations.Operation; 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.Content;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponse;

View File

@ -122,4 +122,13 @@ public class UserController {
public ResponseEntity deleteUserRealy(@RequestBody ParamUserAdd userAddParam){ public ResponseEntity deleteUserRealy(@RequestBody ParamUserAdd userAddParam){
return ResponseEntity.ok(userService.deleteUserReay(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));
}
} }

View File

@ -42,4 +42,6 @@ public interface UserMapper extends BaseMapper<UserInfo> {
SystemRole getRoleLevelByUserId(Long id); SystemRole getRoleLevelByUserId(Long id);
@Update("update user_info set deleted=1 where id=#{id}") @Update("update user_info set deleted=1 where id=#{id}")
Integer changeDelete(Long 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);
} }

View File

@ -23,4 +23,6 @@ public interface UserService {
ResponseResult deleteUser(ParamUserAdd userAddParam); ResponseResult deleteUser(ParamUserAdd userAddParam);
ResponseResult deleteUserReay(ParamUserAdd userAddParam); ResponseResult deleteUserReay(ParamUserAdd userAddParam);
ResponseResult selfUpdateUserInfo(ParamUserAdd userAddParam);
} }

View File

@ -13,6 +13,7 @@ import com.guaiguailang.harmony.mapper.UserMapper;
import com.guaiguailang.harmony.service.UserService; import com.guaiguailang.harmony.service.UserService;
import com.guaiguailang.harmony.utils.PasswordEncryptor; import com.guaiguailang.harmony.utils.PasswordEncryptor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; 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){ public UserInfo getUserByAccount(String username){
return userMapper.getUserByAccount(username); return userMapper.getUserByAccount(username);