feat: 个人中心用户信息获取和修改
This commit is contained in:
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.youlai.system.common.result.PageResult;
|
||||
import com.youlai.system.common.result.Result;
|
||||
import com.youlai.system.model.form.UserProfileForm;
|
||||
import com.youlai.system.util.ExcelUtils;
|
||||
import com.youlai.system.enums.LogModuleEnum;
|
||||
import com.youlai.system.model.dto.UserImportDTO;
|
||||
@@ -103,7 +104,7 @@ public class SysUserController {
|
||||
return Result.judge(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "修改用户密码")
|
||||
@Operation(summary = "重置用户密码")
|
||||
@PatchMapping(value = "/{userId}/password")
|
||||
@PreAuthorize("@ss.hasPerm('sys:user:password:reset')")
|
||||
public Result<?> updatePassword(
|
||||
@@ -169,4 +170,24 @@ public class SysUserController {
|
||||
EasyExcel.write(response.getOutputStream(), UserExportDTO.class).sheet("用户列表")
|
||||
.doWrite(exportUserList);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取个人中心用户信息")
|
||||
@GetMapping("/{userId}/profile")
|
||||
public Result<UserProfileForm> getUserProfile(
|
||||
@PathVariable Long userId
|
||||
) {
|
||||
UserProfileForm userProfile = userService.getUserProfile(userId);
|
||||
return Result.success(userProfile);
|
||||
}
|
||||
|
||||
@Operation(summary = "修改个人中心用户信息")
|
||||
@PutMapping("/{userId}/profile")
|
||||
public Result<?> updateUserProfile(
|
||||
@PathVariable Long userId,
|
||||
@RequestBody UserProfileForm formData
|
||||
) {
|
||||
boolean result = userService.updateUserProfile(formData);
|
||||
return Result.judge(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.youlai.system.model.bo.UserBO;
|
||||
import com.youlai.system.model.entity.SysUser;
|
||||
import com.youlai.system.model.form.UserForm;
|
||||
import com.youlai.system.model.dto.UserImportDTO;
|
||||
import com.youlai.system.model.form.UserProfileForm;
|
||||
import com.youlai.system.model.vo.UserInfoVO;
|
||||
import com.youlai.system.model.vo.UserPageVO;
|
||||
import org.mapstruct.InheritInverseConfiguration;
|
||||
@@ -40,4 +41,8 @@ public interface UserConverter {
|
||||
|
||||
SysUser toEntity(UserImportDTO vo);
|
||||
|
||||
|
||||
UserProfileForm toProfileForm(SysUser entity);
|
||||
|
||||
SysUser toEntity(UserProfileForm formData);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.youlai.system.model.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 个人中心用户信息
|
||||
*
|
||||
* @author Ray
|
||||
* @since 2024/8/13
|
||||
*/
|
||||
@Schema(description = "个人中心用户信息")
|
||||
@Data
|
||||
public class UserProfileForm {
|
||||
|
||||
@Schema(description = "用户ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "用户名")
|
||||
private String username;
|
||||
|
||||
@Schema(description = "用户昵称")
|
||||
private String nickname;
|
||||
|
||||
@Schema(description = "头像URL")
|
||||
private String avatar;
|
||||
|
||||
@Schema(description = "性别")
|
||||
private Integer gender;
|
||||
|
||||
@Schema(description = "手机号")
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "邮箱")
|
||||
private String email;
|
||||
|
||||
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.system.model.entity.SysUser;
|
||||
import com.youlai.system.model.form.UserForm;
|
||||
import com.youlai.system.model.dto.UserAuthInfo;
|
||||
import com.youlai.system.model.form.UserProfileForm;
|
||||
import com.youlai.system.model.query.UserPageQuery;
|
||||
import com.youlai.system.model.dto.UserExportDTO;
|
||||
import com.youlai.system.model.vo.UserInfoVO;
|
||||
@@ -87,7 +88,7 @@ public interface SysUserService extends IService<SysUser> {
|
||||
/**
|
||||
* 获取导出用户列表
|
||||
*
|
||||
* @param queryParams
|
||||
* @param queryParams 查询参数
|
||||
* @return
|
||||
*/
|
||||
List<UserExportDTO> listExportUsers(UserPageQuery queryParams);
|
||||
@@ -99,4 +100,19 @@ public interface SysUserService extends IService<SysUser> {
|
||||
* @return
|
||||
*/
|
||||
UserInfoVO getCurrentUserInfo();
|
||||
|
||||
/**
|
||||
* 获取个人中心用户信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
UserProfileForm getUserProfile(Long userId);
|
||||
|
||||
/**
|
||||
* 修改个人中心用户信息
|
||||
*
|
||||
* @param formData 表单数据
|
||||
* @return
|
||||
*/
|
||||
boolean updateUserProfile(UserProfileForm formData);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.system.common.constant.SystemConstants;
|
||||
import com.youlai.system.converter.UserConverter;
|
||||
import com.youlai.system.model.form.UserProfileForm;
|
||||
import com.youlai.system.security.util.SecurityUtils;
|
||||
import com.youlai.system.mapper.SysUserMapper;
|
||||
import com.youlai.system.model.dto.UserAuthInfo;
|
||||
@@ -250,5 +251,29 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
return userInfoVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取个人中心用户信息
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public UserProfileForm getUserProfile(Long userId) {
|
||||
SysUser entity = this.getById(userId);
|
||||
return userConverter.toProfileForm(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改个人中心用户信息
|
||||
*
|
||||
* @param formData 表单数据
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean updateUserProfile(UserProfileForm formData) {
|
||||
SysUser entity = userConverter.toEntity(formData);
|
||||
return this.updateById(entity);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user