From 35904a4294518ed265358b69830a05e8b350d2c6 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Wed, 29 May 2024 16:25:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=94=A8=E6=88=B7=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E8=A7=92=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kqapi/user/manage/UserInfoManage.java | 10 +++++++++- .../kqapi/user/model/enumerization/RoleEnum.java | 23 ++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 kq-vas-api/src/main/java/com/ningdatech/kqapi/user/model/enumerization/RoleEnum.java 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; + +}