Merge remote-tracking branch 'base-version/main' into dev
# Conflicts: # zt-module-system/zt-module-system-server/src/main/java/com/zt/plat/module/system/controller/admin/user/vo/profile/UserProfileUpdateReqVO.java
This commit is contained in:
@@ -41,7 +41,7 @@ public class AuthPermissionInfoRespVO {
|
||||
@Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码")
|
||||
private String nickname;
|
||||
|
||||
@Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.jpg")
|
||||
@Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
|
||||
private String avatar;
|
||||
|
||||
@Schema(description = "部门编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048")
|
||||
|
||||
@@ -34,7 +34,7 @@ public class UserProfileRespVO {
|
||||
@Schema(description = "用户性别,参见 SexEnum 枚举类", example = "1")
|
||||
private Integer sex;
|
||||
|
||||
@Schema(description = "用户头像", example = "https://www.iocoder.cn/xxx.png")
|
||||
@Schema(description = "用户头像", example = "123456" )
|
||||
private String avatar;
|
||||
|
||||
@Schema(description = "最后登录 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "192.168.1.1")
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.zt.plat.module.system.controller.admin.user.vo.profile;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonSetter;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Email;
|
||||
import jakarta.validation.constraints.Size;
|
||||
@@ -28,8 +30,16 @@ public class UserProfileUpdateReqVO {
|
||||
@Schema(description = "用户性别,参见 SexEnum 枚举类", example = "1")
|
||||
private Integer sex;
|
||||
|
||||
@Schema(description = "角色头像", example = "https://www.iocoder.cn/1.png")
|
||||
@URL(message = "头像地址格式不正确")
|
||||
@Schema(description = "用户头像", example = "123456" )
|
||||
private String avatar;
|
||||
|
||||
@JsonIgnore
|
||||
private boolean avatarPresent;
|
||||
|
||||
@JsonSetter("avatar")
|
||||
public void setAvatarValue(String avatar) {
|
||||
this.avatar = avatar;
|
||||
this.avatarPresent = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class UserRespVO{
|
||||
@DictFormat(DictTypeConstants.USER_SEX)
|
||||
private Integer sex;
|
||||
|
||||
@Schema(description = "用户头像", example = "https://www.iocoder.cn/xxx.png")
|
||||
@Schema(description = "用户头像", example = "123456789")
|
||||
private String avatar;
|
||||
|
||||
@Schema(description = "状态,参见 CommonStatusEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.zt.plat.module.system.controller.admin.user.vo.user;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonSetter;
|
||||
import com.mzt.logapi.starter.annotation.DiffLogField;
|
||||
import com.zt.plat.framework.common.validation.Mobile;
|
||||
import com.zt.plat.framework.common.validation.Password;
|
||||
@@ -67,10 +68,19 @@ public class UserSaveReqVO {
|
||||
@Schema(description = "用户状态", example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "用户头像", example = "https://www.iocoder.cn/xxx.png")
|
||||
@Schema(description = "用户头像", example = "123456789")
|
||||
@DiffLogField(name = "用户头像")
|
||||
private String avatar;
|
||||
|
||||
@JsonIgnore
|
||||
private boolean avatarPresent;
|
||||
|
||||
@JsonSetter("avatar")
|
||||
public void setAvatarValue(String avatar) {
|
||||
this.avatar = avatar;
|
||||
this.avatarPresent = true;
|
||||
}
|
||||
|
||||
@Schema(description = "用户来源类型", example = "1")
|
||||
private Integer userSource;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public interface AuthConvert {
|
||||
AuthLoginRespVO convert(OAuth2AccessTokenDO bean);
|
||||
|
||||
default AuthPermissionInfoRespVO convert(AdminUserDO user, List<RoleDO> roleList, List<MenuDO> menuList) {
|
||||
return AuthPermissionInfoRespVO.builder()
|
||||
AuthPermissionInfoRespVO respVO = AuthPermissionInfoRespVO.builder()
|
||||
.user(BeanUtils.toBean(user, AuthPermissionInfoRespVO.UserVO.class))
|
||||
.roles(convertSet(roleList, RoleDO::getCode))
|
||||
// 权限标识信息
|
||||
@@ -37,6 +37,10 @@ public interface AuthConvert {
|
||||
// 菜单树
|
||||
.menus(buildMenuTree(menuList))
|
||||
.build();
|
||||
if (respVO.getUser() != null) {
|
||||
respVO.getUser().setAvatar(user.getAvatar());
|
||||
}
|
||||
return respVO;
|
||||
}
|
||||
|
||||
AuthPermissionInfoRespVO.MenuVO convertTreeNode(MenuDO menu);
|
||||
|
||||
@@ -31,6 +31,7 @@ public interface UserConvert {
|
||||
|
||||
default UserRespVO convert(AdminUserDO user) {
|
||||
UserRespVO vo = BeanUtils.toBean(user, UserRespVO.class);
|
||||
vo.setAvatar(user.getAvatar());
|
||||
if (user.getDeptIds() != null) {
|
||||
vo.setDeptIds(CollectionUtils.convertList(user.getDeptIds(), Long::longValue));
|
||||
}
|
||||
@@ -47,6 +48,7 @@ public interface UserConvert {
|
||||
default UserProfileRespVO convert(AdminUserDO user, List<RoleDO> userRoles,
|
||||
List<DeptDO> depts, List<PostDO> posts) {
|
||||
UserProfileRespVO userVO = BeanUtils.toBean(user, UserProfileRespVO.class);
|
||||
userVO.setAvatar(user.getAvatar());
|
||||
userVO.setRoles(BeanUtils.toBean(userRoles, RoleSimpleRespVO.class));
|
||||
userVO.setDepts(BeanUtils.toBean(depts, DeptSimpleRespVO.class));
|
||||
userVO.setPosts(BeanUtils.toBean(posts, PostSimpleRespVO.class));
|
||||
|
||||
@@ -119,6 +119,7 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
if (user.getUserSource() == null) {
|
||||
user.setUserSource(UserSourceEnum.EXTERNAL.getSource());
|
||||
}
|
||||
user.setAvatar(normalizeAvatarValue(createReqVO.getAvatar()));
|
||||
user.setPassword(encodePassword(createReqVO.getPassword()));
|
||||
userMapper.insert(user);
|
||||
// 2.2 插入关联部门
|
||||
@@ -202,6 +203,9 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
if (StrUtil.isNotBlank(updateReqVO.getRemark())) {
|
||||
updateObj.setRemark(updateReqVO.getRemark());
|
||||
}
|
||||
if (updateReqVO.isAvatarPresent()) {
|
||||
updateObj.setAvatar(normalizeAvatarValue(updateReqVO.getAvatar()));
|
||||
}
|
||||
userMapper.updateById(updateObj);
|
||||
|
||||
// 2.2 更新部门
|
||||
@@ -250,7 +254,12 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
validateEmailUnique(id, reqVO.getEmail());
|
||||
validateMobileUnique(id, reqVO.getMobile());
|
||||
// 执行更新
|
||||
userMapper.updateById(BeanUtils.toBean(reqVO, AdminUserDO.class).setId(id));
|
||||
AdminUserDO updateObj = BeanUtils.toBean(reqVO, AdminUserDO.class);
|
||||
updateObj.setId(id);
|
||||
if (reqVO.isAvatarPresent()) {
|
||||
updateObj.setAvatar(normalizeAvatarValue(reqVO.getAvatar()));
|
||||
}
|
||||
userMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -313,12 +322,14 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
|
||||
@Override
|
||||
public AdminUserDO getUserByUsername(String username) {
|
||||
return userMapper.selectByUsername(username);
|
||||
AdminUserDO user = userMapper.selectByUsername(username);
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdminUserDO getUserByMobile(String mobile) {
|
||||
return userMapper.selectByMobile(mobile);
|
||||
AdminUserDO user = userMapper.selectByMobile(mobile);
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -375,7 +386,8 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
if (CollUtil.isEmpty(userIds)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return userMapper.selectBatchIds(userIds);
|
||||
List<AdminUserDO> users = userMapper.selectBatchIds(userIds);
|
||||
return users;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -383,7 +395,8 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return userMapper.selectListByIds(ids);
|
||||
List<AdminUserDO> users = userMapper.selectListByIds(ids);
|
||||
return users;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -408,7 +421,8 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
|
||||
@Override
|
||||
public List<AdminUserDO> getUserListByNickname(String nickname) {
|
||||
return userMapper.selectListByNickname(nickname);
|
||||
List<AdminUserDO> users = userMapper.selectListByNickname(nickname);
|
||||
return users;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -468,6 +482,10 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
});
|
||||
}
|
||||
|
||||
private String normalizeAvatarValue(String avatarValue) {
|
||||
return StrUtil.isBlank(avatarValue) ? null : avatarValue.trim();
|
||||
}
|
||||
|
||||
private AdminUserDO validateUserForCreateOrUpdate(Long id, String username, String mobile, String email,
|
||||
Set<Long> deptIds, Set<Long> postIds) {
|
||||
// 关闭数据权限,避免因为没有数据权限,查询不到数据,进而导致唯一校验不正确
|
||||
@@ -572,7 +590,8 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
|
||||
@Override
|
||||
public List<AdminUserDO> getUserListByStatus(Integer status) {
|
||||
return userMapper.selectListByStatus(status);
|
||||
List<AdminUserDO> users = userMapper.selectListByStatus(status);
|
||||
return users;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user