diff --git a/kq-vas-api/src/main/java/com/ningdatech/kqapi/user/manage/UserInfoManage.java b/kq-vas-api/src/main/java/com/ningdatech/kqapi/user/manage/UserInfoManage.java index 3e63f88..a755eab 100644 --- a/kq-vas-api/src/main/java/com/ningdatech/kqapi/user/manage/UserInfoManage.java +++ b/kq-vas-api/src/main/java/com/ningdatech/kqapi/user/manage/UserInfoManage.java @@ -15,6 +15,7 @@ import com.ningdatech.kqapi.security.model.UserInfoDetails; import com.ningdatech.kqapi.user.model.entity.UserAuth; import com.ningdatech.kqapi.user.model.entity.UserInfo; import com.ningdatech.kqapi.user.model.enumerization.AccountStatus; +import com.ningdatech.kqapi.user.model.enumerization.RoleEnum; import com.ningdatech.kqapi.user.model.po.ChangeAccountStatusReq; import com.ningdatech.kqapi.user.model.po.ModifyPasswordReq; import com.ningdatech.kqapi.user.model.po.SaveUserReq; @@ -77,10 +78,14 @@ public class UserInfoManage { @Transactional(rollbackFor = Exception.class) public synchronized void saveUser(SaveUserReq req) { Long userId = req.getUserId(); - UserInfo oldUser = null; + UserInfo oldUser; if (userId == null) { + oldUser = null; BizUtils.password(req.getPassword()); } else { + if (StrUtil.isNotBlank(req.getPassword())) { + BizUtils.password(req.getPassword()); + } oldUser = userInfoService.getById(userId); } // 校验 账号是否已经使用 @@ -94,6 +99,9 @@ public class UserInfoManage { entity.setUsername(req.getUserName()); entity.setAvatarFileId(req.getAvatarFileId()); entity.setAccountStatus(AccountStatus.ENABLE); + if (userId == null) { + entity.setRole(RoleEnum.USER.name()); + } userInfoService.saveOrUpdate(entity); if (userId == null) { saveUserAuth(req, entity); diff --git a/kq-vas-api/src/main/java/com/ningdatech/kqapi/user/model/enumerization/RoleEnum.java b/kq-vas-api/src/main/java/com/ningdatech/kqapi/user/model/enumerization/RoleEnum.java new file mode 100644 index 0000000..2eac9d0 --- /dev/null +++ b/kq-vas-api/src/main/java/com/ningdatech/kqapi/user/model/enumerization/RoleEnum.java @@ -0,0 +1,23 @@ +package com.ningdatech.kqapi.user.model.enumerization; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + *

+ * RoleEnum + *

+ * + * @author WendyYang + * @since 16:19 2024/5/29 + */ +@Getter +@AllArgsConstructor +public enum RoleEnum { + + SUPER_ADMIN("超级管理员"), + USER("普通用户"); + + private final String displayName; + +}