Przeglądaj źródła

用户导入,公司LOGO与名称开发

anderx 2 lat temu
rodzic
commit
8dc83898fa

+ 15 - 9
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java

@@ -532,8 +532,7 @@ public class SysUserServiceImpl implements ISysUserService
             {
                 // 验证是否存在这个用户
                 SysUser u = userMapper.checkJobNumber(user.getJobNumber(),company);
-                if (StringUtils.isNull(u))
-                {
+                if (StringUtils.isNull(u)){
                     user.setPassword(SecurityUtils.encryptPassword(password));
                     user.setCreateBy(operName);
                     user.setUserId(null);
@@ -563,18 +562,25 @@ public class SysUserServiceImpl implements ISysUserService
                     }
                     successNum++;
                     successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 导入成功");
-                }
-                else if (isUpdateSupport)
-                {
-                    BeanValidators.validateWithException(validator, user);
+                } else if (isUpdateSupport) {
+//                    BeanValidators.validateWithException(validator, user);
                     checkUserAllowed(u);
                     checkUserDataScope(u.getUserId());
                     user.setUserId(u.getUserId());
                     user.setUpdateBy(operName);
-                    SysUser sysUser = userMapper.selectByNikeName(u.getSuperiorName(),company);
-                    if (sysUser != null){
-                        user.setSuperiorId(sysUser.getUserId());
+                    if (user.getSuperiorName()!=null&&!user.getSuperiorName().equals(u.getSuperiorName())){
+                        SysUser sysUser = userMapper.selectByNikeName(user.getSuperiorName(),company);
+                        if (sysUser != null){
+                            user.setSuperiorId(sysUser.getUserId());
+                        }
                     }
+                    if (user.getDeptName()!=null&&!user.getDeptName().equals(u.getDeptName())){
+                        SysDept sysDept = deptService.selectByDepName(user.getDeptName(), company);
+                        if (sysDept !=null){
+                            user.setDeptId(sysDept.getDeptId());
+                        }
+                    }
+
                     userMapper.updateUser(user);
                     successNum++;
                     successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 更新成功");

+ 5 - 4
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -33,6 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<result property="duration"       column="duration"       />
 		<result property="postName"       column="post_name"       />
 		<result property="roleName"       column="roleName"       />
+		<result property="deptName"  column="dept_name"   />
 		<result property="superiorName"       column="superiorName"       />
         <association property="dept"    javaType="SysDept"         resultMap="deptResult" />
         <collection  property="roles"   javaType="java.util.List"  resultMap="RoleResult" />
@@ -207,12 +208,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	</select>
 
 	<select id="checkJobNumber"  resultMap="SysUserResult">
-		select user_id, Job_number from sys_user a
-		where Job_number = #{jobNumber}
+		<include refid="selectUserVo"/>
+		where u.Job_number = #{jobNumber}
 		<if test="companyId !=null">
-		AND (a.dept_id = #{companyId} OR a.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{companyId}, ancestors) ))
+		AND (u.dept_id = #{companyId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{companyId}, ancestors) ))
 		</if>
-		and del_flag = '0' limit 1
+		and u.del_flag = '0' limit 1
 	</select>