|
@@ -5,11 +5,15 @@ import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
import javax.validation.Validator;
|
|
import javax.validation.Validator;
|
|
|
|
|
|
|
|
+import com.ozs.common.core.domain.entity.SysDept;
|
|
import com.ozs.common.core.domain.entity.SysUserUpdate;
|
|
import com.ozs.common.core.domain.entity.SysUserUpdate;
|
|
|
|
+import com.ozs.common.core.domain.entity.SysUsers;
|
|
import com.ozs.common.utils.uuid.IdUtils;
|
|
import com.ozs.common.utils.uuid.IdUtils;
|
|
|
|
+import com.ozs.system.mapper.SysDeptMapper;
|
|
import icu.mhb.mybatisplus.plugln.base.service.impl.JoinServiceImpl;
|
|
import icu.mhb.mybatisplus.plugln.base.service.impl.JoinServiceImpl;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -63,6 +67,8 @@ public class SysUserServiceImpl extends JoinServiceImpl<SysUserMapper, SysUser>
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
protected Validator validator;
|
|
protected Validator validator;
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysDeptMapper deptMapper;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 根据条件分页查询用户列表
|
|
* 根据条件分页查询用户列表
|
|
@@ -510,7 +516,7 @@ public class SysUserServiceImpl extends JoinServiceImpl<SysUserMapper, SysUser>
|
|
* @return 结果
|
|
* @return 结果
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName) {
|
|
|
|
|
|
+ public String importUser(List<SysUsers> userList, Boolean isUpdateSupport, String operName) {
|
|
if (StringUtils.isNull(userList) || userList.size() == 0) {
|
|
if (StringUtils.isNull(userList) || userList.size() == 0) {
|
|
throw new ServiceException("导入用户数据不能为空!");
|
|
throw new ServiceException("导入用户数据不能为空!");
|
|
}
|
|
}
|
|
@@ -519,23 +525,31 @@ public class SysUserServiceImpl extends JoinServiceImpl<SysUserMapper, SysUser>
|
|
StringBuilder successMsg = new StringBuilder();
|
|
StringBuilder successMsg = new StringBuilder();
|
|
StringBuilder failureMsg = new StringBuilder();
|
|
StringBuilder failureMsg = new StringBuilder();
|
|
String password = configService.selectConfigByKey("sys.user.initPassword");
|
|
String password = configService.selectConfigByKey("sys.user.initPassword");
|
|
- for (SysUser user : userList) {
|
|
|
|
|
|
+ for (SysUsers user : userList) {
|
|
try {
|
|
try {
|
|
// 验证是否存在这个用户
|
|
// 验证是否存在这个用户
|
|
|
|
+ SysUser sysUser = new SysUser();
|
|
|
|
+ BeanUtils.copyProperties(user, sysUser);
|
|
SysUser u = userMapper.selectUserByUserName(user.getUserName());
|
|
SysUser u = userMapper.selectUserByUserName(user.getUserName());
|
|
if (StringUtils.isNull(u)) {
|
|
if (StringUtils.isNull(u)) {
|
|
BeanValidators.validateWithException(validator, user);
|
|
BeanValidators.validateWithException(validator, user);
|
|
- user.setPassword(SecurityUtils.encryptPassword(password));
|
|
|
|
- user.setCreateBy(operName);
|
|
|
|
- this.insertUser(user);
|
|
|
|
|
|
+ sysUser.setPassword(SecurityUtils.encryptPassword(password));
|
|
|
|
+ sysUser.setCreateBy(operName);
|
|
|
|
+ sysUser.setUpdateBy(operName);
|
|
|
|
+ sysUser.setUserId(IdUtils.fastSimpleUUID());
|
|
|
|
+ SysDept sysDept = deptMapper.selectDeptByDeptName(user.getDeptName());
|
|
|
|
+ sysUser.setDeptId(sysDept.getDeptId());
|
|
|
|
+ this.insertUser(sysUser);
|
|
successNum++;
|
|
successNum++;
|
|
successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 导入成功");
|
|
successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 导入成功");
|
|
} else if (isUpdateSupport) {
|
|
} else if (isUpdateSupport) {
|
|
BeanValidators.validateWithException(validator, user);
|
|
BeanValidators.validateWithException(validator, user);
|
|
- checkUserAllowed(user);
|
|
|
|
- checkUserDataScope(user.getId());
|
|
|
|
- user.setUpdateBy(operName);
|
|
|
|
- this.updateUser(user);
|
|
|
|
|
|
+ checkUserAllowed(sysUser);
|
|
|
|
+ checkUserDataScope(sysUser.getId());
|
|
|
|
+ sysUser.setUpdateBy(operName);
|
|
|
|
+ SysDept sysDept = deptMapper.selectDeptByDeptName(user.getDeptName());
|
|
|
|
+ sysUser.setDeptId(sysDept.getDeptId());
|
|
|
|
+ this.updateUser(sysUser);
|
|
successNum++;
|
|
successNum++;
|
|
successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 更新成功");
|
|
successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 更新成功");
|
|
} else {
|
|
} else {
|