From 7f046650eea24ba1a43f09831407e4e37b8cb898 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Tue, 12 Oct 2021 23:34:28 +0800
Subject: [PATCH] 用户,保安员新增同账号判断修改
---
src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java | 49 ++++++++++++++++++++++++++++++++++---------------
1 files changed, 34 insertions(+), 15 deletions(-)
diff --git a/src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java b/src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
index 259e77a..a7e5f52 100644
--- a/src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
+++ b/src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
@@ -106,9 +106,10 @@
user.setPassword(DigestUtil.encrypt(user.getPassword()));
}
// Integer userCount = baseMapper.selectCount(Wrappers.<User>query().lambda().eq(User::getTenantId, tenantId).eq(User::getAccount, user.getAccount()));
-// if (userCount > 0 && Func.isEmpty(user.getId())) {
-// throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount()));
-// }
+ Integer userCount = baseMapper.selectCountAccount(user.getAccount());
+ if (userCount > 0 && Func.isEmpty(user.getId())) {
+ throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount()));
+ }
boolean b = save(user) && submitUserDept(user);
String rtime = null;
if (null != user.getRtime()) {
@@ -143,16 +144,16 @@
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updateUser(User user) {
- String tenantId = user.getTenantId();
- Integer userCount = baseMapper.selectCount(
- Wrappers.<User>query().lambda()
- .eq(User::getTenantId, tenantId)
- .eq(User::getAccount, user.getAccount())
- .notIn(User::getId, user.getId())
- );
- if (userCount > 0) {
- throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount()));
- }
+// String tenantId = user.getTenantId();
+// Integer userCount = baseMapper.selectCount(
+// Wrappers.<User>query().lambda()
+// .eq(User::getTenantId, tenantId)
+// .eq(User::getAccount, user.getAccount())
+// .notIn(User::getId, user.getId())
+// );
+// if (userCount > 0) {
+// throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount()));
+// }
return updateUserInfo(user) && submitUserDept(user);
}
@@ -382,7 +383,7 @@
@Override
@Transactional(rollbackFor = Exception.class)
- public void importUser(List<UserExcel> data, Boolean isCovered) {
+ public void importUser(List<UserExcel> data, Boolean isCovered,String deptId) {
data.forEach(userExcel -> {
User user = Objects.requireNonNull(BeanUtil.copy(userExcel, User.class));
// 设置租户ID
@@ -413,7 +414,15 @@
}
}
//设置部门id
- user.setDeptId(userDeptService.selectIn(user.getDeptId()));
+ String deptIds = userDeptService.selectIn(user.getDeptId());
+ if (null!=deptIds && !deptIds.equals("")) {
+ if (null != deptId && !deptId.equals("")) {
+ if (!deptId.equals(deptIds)) {
+ throw new ServiceException("不能导入不是本公司的保安员数据!");
+ }
+ }
+ user.setDeptId(deptIds);
+ }
//设置账号
user.setAccount(user.getCardid());
//获取默认密码配置
@@ -757,4 +766,14 @@
public Integer selectCount(String account) {
return baseMapper.selectCountAccount(account);
}
+
+ /**
+ * 查询用户表中未删除,未离职的用户信息
+ * @param username
+ * @return
+ */
+ @Override
+ public User getUserInfo(String username) {
+ return baseMapper.getUserInfo(username);
+ }
}
--
Gitblit v1.9.3