Explorar el Código

用户导入修改

gao.qiang hace 2 años
padre
commit
74d0e6a450

+ 38 - 27
base-system/src/main/java/com/ozs/system/service/impl/SysUserServiceImpl.java

@@ -540,35 +540,46 @@ public class SysUserServiceImpl extends JoinServiceImpl<SysUserMapper, SysUser>
                 BeanUtils.copyProperties(user, sysUser);
                 SysUser u = userMapper.selectUserByUserName(user.getUserName());
                 if (StringUtils.isNull(u)) {
-                    BeanValidators.validateWithException(validator, user);
-                    sysUser.setPassword(SecurityUtils.encryptPassword(password));
-                    sysUser.setCreateBy(operName);
-                    sysUser.setUpdateBy(operName);
-                    sysUser.setUserId(IdUtils.fastSimpleUUID());
-                    SysDept sysDept = deptMapper.selectDeptByDeptName(user.getDeptName());
-                    if (ObjectUtils.isEmpty(sysDept)) {
-                        errMsg.append("部门名称:" + user.getDeptName() + "不存在");
-                    }
-                    sysUser.setDeptId(sysDept.getDeptId());
-                    sysUser.setPassword(SecurityUtils.encryptPassword(defaultPassword));
-                    this.insertUser(sysUser);
-                    SysUser sysUser1 = userMapper.selectUserByUserName(user.getUserName());
-                    String roleName = sysUser.getRoleName();
-                    String[] split = roleName.split(",");
-                    if (StringUtils.isNotEmpty(split)) {
-                        List<Long> id = new ArrayList<>();
-                        for (int i = 0; i < split.length; i++) {
-                            Long roleId = roleMapper.getRoleId(split[i]);
-                            List<SysUserRole> list = new ArrayList<SysUserRole>(id.size());
-                            SysUserRole ur = new SysUserRole();
-                            ur.setUserId(sysUser1.getId());
-                            ur.setRoleId(roleId);
-                            list.add(ur);
-                            userRoleMapper.batchUserRole(list);
+                    if (!ObjectUtils.isEmpty(user.getPhoneNum())
+                            && UserConstants.NOT_UNIQUE.equals(userMapper.checkPhoneUnique(user.getPhoneNum()))) {
+                        errMsg.append("手机号码:" + user.getPhoneNum() + "已存在");
+                    }else {
+                        if (!ObjectUtils.isEmpty(user.getEmail())
+                                && UserConstants.NOT_UNIQUE.equals(userMapper.checkEmailUnique(user.getEmail()))) {
+                            errMsg.append("邮箱:" + user.getEmail() + "已存在");
+                        } else {
+                            BeanValidators.validateWithException(validator, user);
+                            sysUser.setPassword(SecurityUtils.encryptPassword(password));
+                            sysUser.setCreateBy(operName);
+                            sysUser.setUpdateBy(operName);
+                            sysUser.setUserId(IdUtils.fastSimpleUUID());
+                            SysDept sysDept = deptMapper.selectDeptByDeptName(user.getDeptName());
+                            if (ObjectUtils.isEmpty(sysDept)) {
+                                errMsg.append("部门名称:" + user.getDeptName() + "不存在");
+                            } else {
+                                sysUser.setDeptId(sysDept.getDeptId());
+                                sysUser.setPassword(SecurityUtils.encryptPassword(defaultPassword));
+                                this.insertUser(sysUser);
+                                SysUser sysUser1 = userMapper.selectUserByUserName(user.getUserName());
+                                String roleName = sysUser.getRoleName();
+                                String[] split = roleName.split(",");
+                                if (StringUtils.isNotEmpty(split)) {
+                                    List<Long> id = new ArrayList<>();
+                                    for (int i = 0; i < split.length; i++) {
+                                        Long roleId = roleMapper.getRoleId(split[i]);
+                                        List<SysUserRole> list = new ArrayList<SysUserRole>(id.size());
+                                        SysUserRole ur = new SysUserRole();
+                                        ur.setUserId(sysUser1.getId());
+                                        ur.setRoleId(roleId);
+                                        list.add(ur);
+                                        userRoleMapper.batchUserRole(list);
+                                    }
+                                }
+                                successNum++;
+                                successMsg.append(successNum + "、账号 " + user.getUserName() + " 导入成功");
+                            }
                         }
                     }
-                    successNum++;
-                    successMsg.append(successNum + "、账号 " + user.getUserName() + " 导入成功");
                 } else if (isUpdateSupport) {
                     BeanValidators.validateWithException(validator, user);
 //                    checkUserAllowed(sysUser);

+ 1 - 1
base-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -268,7 +268,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		  AND status = 1
 	</select>
 	<select id="selectUserLists" resultMap="SysUserResult" parameterType="com.ozs.common.core.domain.vo.SysUserVo">
-		select u.id,u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phone_num, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.data_permission
+		select u.id,u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phone_num, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.data_permission,update_by,update_time
         from sys_user u
 		<where>
 			<if test="userName != null and userName != ''">