mirror of https://gitee.com/stylefeng/roses
【7.6.0】【sys】【portal】更新获取用户的个人信息接口
parent
295c47ecee
commit
90d6c8bae8
|
@ -5,8 +5,10 @@ import cn.stylefeng.roses.kernel.rule.enums.ResBizTypeEnum;
|
|||
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.pojo.request.SysUserRequest;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.pojo.response.PersonalInfo;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.service.SysUserService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
@ -27,6 +29,18 @@ public class PersonalInfoController {
|
|||
@Resource
|
||||
private SysUserService sysUserService;
|
||||
|
||||
/**
|
||||
* 获取个人信息详情
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/6/26 22:27
|
||||
*/
|
||||
@GetResource(name = "获取个人信息详情", path = "/personalInfo/getUserInfo")
|
||||
public ResponseData<PersonalInfo> getUserInfo() {
|
||||
PersonalInfo personalInfo = sysUserService.getPersonalInfo();
|
||||
return new SuccessResponseData<>(personalInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新个人信息
|
||||
*
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.user.pojo.response;
|
||||
|
||||
import cn.stylefeng.roses.kernel.file.api.format.FileUrlFormatProcess;
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.SimpleFieldFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 用户的个人信息
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/6/26 22:31
|
||||
*/
|
||||
@Data
|
||||
public class PersonalInfo {
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
@ChineseDescription("姓名")
|
||||
private String realName;
|
||||
|
||||
/**
|
||||
* 账号
|
||||
*/
|
||||
@ChineseDescription("账号")
|
||||
private String account;
|
||||
|
||||
/**
|
||||
* 头像,存的为文件id
|
||||
*/
|
||||
@SimpleFieldFormat(processClass = FileUrlFormatProcess.class)
|
||||
private Long avatar;
|
||||
|
||||
/**
|
||||
* 生日
|
||||
*/
|
||||
@ChineseDescription("生日")
|
||||
private Date birthday;
|
||||
|
||||
/**
|
||||
* 性别:M-男,F-女
|
||||
*/
|
||||
@ChineseDescription("性别:M-男,F-女")
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
@ChineseDescription("邮箱")
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 手机
|
||||
*/
|
||||
@ChineseDescription("手机")
|
||||
private String phone;
|
||||
|
||||
}
|
|
@ -3,6 +3,7 @@ package cn.stylefeng.roses.kernel.sys.modular.user.service;
|
|||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.entity.SysUser;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.pojo.request.SysUserRequest;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.pojo.response.PersonalInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -95,6 +96,14 @@ public interface SysUserService extends IService<SysUser> {
|
|||
*/
|
||||
void resetPassword(SysUserRequest sysUserRequest);
|
||||
|
||||
/**
|
||||
* 获取当前用户的个人信息详情
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/6/26 22:28
|
||||
*/
|
||||
PersonalInfo getPersonalInfo();
|
||||
|
||||
/**
|
||||
* 更新用户信息(一般用于更新个人信息)
|
||||
*
|
||||
|
|
|
@ -24,6 +24,7 @@ import cn.stylefeng.roses.kernel.sys.modular.user.enums.SysUserExceptionEnum;
|
|||
import cn.stylefeng.roses.kernel.sys.modular.user.factory.SysUserCreateFactory;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.mapper.SysUserMapper;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.pojo.request.SysUserRequest;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.pojo.response.PersonalInfo;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.service.SysUserOrgService;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.service.SysUserRoleService;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.service.SysUserService;
|
||||
|
@ -200,6 +201,28 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
this.updateById(sysUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PersonalInfo getPersonalInfo() {
|
||||
|
||||
// 获取当前登录用户id
|
||||
Long userId = LoginContext.me().getLoginUser().getUserId();
|
||||
|
||||
// 查询用户的详细信息
|
||||
LambdaQueryWrapper<SysUser> sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
sysUserLambdaQueryWrapper.eq(SysUser::getUserId, userId);
|
||||
sysUserLambdaQueryWrapper.select(SysUser::getRealName, SysUser::getAccount, SysUser::getAvatar, SysUser::getEmail,
|
||||
SysUser::getPhone, SysUser::getSex, SysUser::getBirthday);
|
||||
SysUser sysUser = this.getOne(sysUserLambdaQueryWrapper, false);
|
||||
|
||||
if (sysUser == null) {
|
||||
return new PersonalInfo();
|
||||
}
|
||||
|
||||
PersonalInfo personalInfo = new PersonalInfo();
|
||||
BeanUtil.copyProperties(sysUser, personalInfo);
|
||||
return personalInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void editInfo(SysUserRequest sysUserRequest) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue