From c76a16e77c5551582bc8415ce7f30a362a765e09 Mon Sep 17 00:00:00 2001
From: 田源 <lastanimals@163.com>
Date: 星期四, 04 一月 2024 16:05:53 +0800
Subject: [PATCH] 整合代码
---
Source/UBCS/ubcs-service/ubcs-user/src/main/java/com/vci/ubcs/system/user/service/impl/UserServiceImpl.java | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 56 insertions(+), 3 deletions(-)
diff --git a/Source/UBCS/ubcs-service/ubcs-user/src/main/java/com/vci/ubcs/system/user/service/impl/UserServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-user/src/main/java/com/vci/ubcs/system/user/service/impl/UserServiceImpl.java
index f7418ec..53de504 100644
--- a/Source/UBCS/ubcs-service/ubcs-user/src/main/java/com/vci/ubcs/system/user/service/impl/UserServiceImpl.java
+++ b/Source/UBCS/ubcs-service/ubcs-user/src/main/java/com/vci/ubcs/system/user/service/impl/UserServiceImpl.java
@@ -20,6 +20,7 @@
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.vci.ubcs.starter.web.util.VciBaseUtil;
@@ -35,6 +36,7 @@
import com.vci.ubcs.system.user.cache.UserCache;
import com.vci.ubcs.system.user.entity.*;
import com.vci.ubcs.system.user.enums.UserEnum;
+import com.vci.ubcs.system.user.enums.UserStatus;
import com.vci.ubcs.system.user.excel.UserExcel;
import com.vci.ubcs.system.user.mapper.UserMapper;
import com.vci.ubcs.system.user.service.IUserDeptService;
@@ -43,6 +45,7 @@
import com.vci.ubcs.system.user.vo.UserVO;
import com.vci.ubcs.system.user.wrapper.UserWrapper;
import lombok.RequiredArgsConstructor;
+import org.springblade.core.log.annotation.GrantLog;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Condition;
@@ -91,6 +94,9 @@
if (Func.isNotEmpty(user.getPassword())) {
user.setPassword(DigestUtil.encrypt(user.getPassword()));
}
+ if(Func.isEmpty(user.getUserStatus())){
+ user.setUserStatus(UserStatus.Enable.getValue());
+ }
Long userCount = baseMapper.selectCount(Wrappers.<User>query().lambda().eq(User::getTenantId, tenantId).eq(User::getAccount, user.getAccount()));
if (userCount > 0L && Func.isEmpty(user.getId())) {
throw new ServiceException(StringUtil.format("褰撳墠鐢ㄦ埛 [{}] 宸插瓨鍦�!", user.getAccount()));
@@ -122,6 +128,7 @@
@Override
@Transactional(rollbackFor = Exception.class)
+ @GrantLog("grantUser")
public boolean updateUser(User user) {
String tenantId = user.getTenantId();
Long userCount = baseMapper.selectCount(
@@ -130,6 +137,7 @@
.eq(User::getAccount, user.getAccount())
.notIn(User::getId, user.getId())
);
+ // 鍒ゆ柇鏄惁琚慨鏀逛负宸插瓨鍦ㄧ殑鐢ㄦ埛鍚�
if (userCount > 0L) {
throw new ServiceException(StringUtil.format("褰撳墠鐢ㄦ埛 [{}] 宸插瓨鍦�!", user.getAccount()));
}
@@ -142,8 +150,41 @@
return updateById(user);
}
+ /**
+ * 鏍规嵁鏃ц处鍙凤紝淇敼涓烘柊璐﹀彿鍚�
+ * @param oldAccount
+ * @param newAccount
+ * @return
+ */
+ @Override
+ public boolean updateByAccount(String oldAccount,String newAccount) {
+ User user = this.userByAccount(AuthUtil.getTenantId(), oldAccount);
+ if(Func.isEmpty(user)){
+ return true;
+ }
+ user.setAccount(newAccount);
+ return this.updateUser(user);
+ }
+
+ /**
+ * 鎹处鍙凤紝淇敼涓虹敤鎴风姸鎬�
+ * @param accounts
+ * @param status
+ * @return
+ */
+ @Override
+ public boolean updateStatusByAccount(String accounts, String status) {
+ LambdaUpdateWrapper<User> updateWrapper = Wrappers.<User>update()
+ .lambda().in(User::getAccount, accounts)
+ .set(User::getUserStatus, status);
+ return this.update(updateWrapper);
+ }
+
private boolean submitUserDept(User user) {
List<Long> deptIdList = Func.toLongList(user.getDeptId());
+ if(deptIdList.isEmpty()){
+ return true;
+ }
List<UserDept> userDeptList = new ArrayList<>();
deptIdList.forEach(deptId -> {
UserDept userDept = new UserDept();
@@ -313,6 +354,16 @@
return this.update(user, Wrappers.<User>update().lambda().in(User::getId, Func.toLongList(userIds)));
}
+ /**
+ * 鎺堟潈鏃ュ織鎻掑叆鎿嶄綔
+ * @param res
+ */
+ @Override
+ @GrantLog("grantUser")
+ public boolean grantLog(String res, boolean isException){
+ return true;
+ }
+
@Override
public boolean resetPassword(String userIds) {
User user = new User();
@@ -327,9 +378,6 @@
if (!newPassword.equals(newPassword1)) {
throw new ServiceException("璇疯緭鍏ユ纭殑纭瀵嗙爜!");
}
- if (!user.getPassword().equals(DigestUtil.hex(oldPassword))) {
- throw new ServiceException("鍘熷瘑鐮佷笉姝g‘!");
- }
//鑾峰彇鐢ㄦ埛閲囩敤鐨勫瘑鐮佺瓥鐣�
Strategy strategy = sysClient.getByUserId(userId).getData();
// 鍑犱箮涓嶄細鍑虹幇杩欑鎯呭喌
@@ -340,6 +388,11 @@
if(newPassword1.length() < strategy.getMinPwdLen() || newPassword1.length() > strategy.getMaxPwdLen()){
throw new ServiceException("瀵嗙爜涓繀椤诲惈鏈夈��"+strategy.getCombinationNames()+"銆戜腑鐨勩��"+strategy.getRequiredType()+"銆戠瀵嗙爜缁勫悎鏂瑰紡锛屼笖瀵嗙爜闀垮害蹇呴』鍦ㄣ��"+strategy.getMinPwdLen()+"-"+strategy.getMaxPwdLen()+"銆戣寖鍥村唴");
}
+
+ String hexOldPassword = DigestUtil.hex(oldPassword);
+ if (!user.getPassword().equals(hexOldPassword)) {
+ throw new ServiceException("鍘熷瘑鐮佷笉姝g‘!");
+ }
List<String> regexs = sysClient.getRegexByList(Arrays.asList(strategy.getCombinationIds().split(","))).getData();
//鍒ゆ柇鏄惁婊¤冻缁勫悎鏂瑰紡涓殑蹇呭~绉嶇被鏁�
int reqType = 0;
--
Gitblit v1.9.3