anderx лет назад: 2
Родитель
Сommit
873ec01ee8

+ 8 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java

@@ -138,6 +138,10 @@ public class SysUserController extends BaseController
         {
             return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
         }
+        else if (userService.checkJobNumber(user))
+        {
+            return error("新增用户'" + user.getUserName() + "'失败,工号已存在");
+        }
         user.setCreateBy(getUsername());
         user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
         return toAjax(userService.insertUser(user));
@@ -165,6 +169,10 @@ public class SysUserController extends BaseController
         {
             return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
         }
+        else if (userService.checkJobNumber(user))
+        {
+            return error("修改用户'" + user.getUserName() + "'失败,工号已存在");
+        }
         user.setUpdateBy(getUsername());
         return toAjax(userService.updateUser(user));
     }

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java

@@ -134,4 +134,6 @@ public interface SysUserMapper
     SysUser selectSuperUserByUid(Long aid);
 
     void updateUserProjectSum(@Param("aid") Long aid, @Param("type") Integer type);
+
+    SysUser checkJobNumber(String jobNumber);
 }

+ 1 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java

@@ -208,4 +208,5 @@ public interface ISysUserService
 
     String setOpenId(String code);
 
+    boolean checkJobNumber(SysUser user);
 }

+ 11 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java

@@ -568,4 +568,15 @@ public class SysUserServiceImpl implements ISysUserService
         return openId;
     }
 
+    @Override
+    public boolean checkJobNumber(SysUser user) {
+        SysUser sysUser = userMapper.checkJobNumber(user.getJobNumber());
+        if (StringUtils.isNotNull(user.getUserId())&&user.getUserId().equals(sysUser.getUserId())){
+            return false;
+        }else {
+            if (sysUser!=null)return true;
+        }
+        return false;
+    }
+
 }

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

@@ -175,6 +175,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1
 	</select>
 
+	<select id="checkJobNumber" parameterType="String" resultMap="SysUserResult">
+		select user_id, Job_number from sys_user where Job_number = #{JobNumber} and del_flag = '0' limit 1
+	</select>
+
 
 	<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
  		insert into sys_user(
@@ -292,6 +296,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		where a.user_id=#{aid}
 	</select>
 
+
 	<update id="userAddDuration">
 		update sys_user set duration = duration+#{duration}
 		where user_id = #{userId}