Ver código fonte

模糊查询修改

anderx 2 anos atrás
pai
commit
3088decfb8

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ProjectTaskController.java

@@ -85,7 +85,7 @@ public class ProjectTaskController extends BaseController {
      */
     @PostMapping("/addStaff")
     @ApiOperation("新增项目成员")
-    public AjaxResult addStaff( @RequestBody ProjectStaff in){
+    public AjaxResult addStaff(@Validated @RequestBody ProjectStaff in){
 
         return projectStaffService.addStaff(in);
     }

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/project/domain/ProjectStaff.java

@@ -3,6 +3,7 @@ package com.ruoyi.project.domain;
 import com.fasterxml.jackson.annotation.JsonFormat;
 
 import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 import java.util.Date;
 
@@ -61,6 +62,7 @@ public class ProjectStaff implements Serializable {
         this.pid = pid;
     }
 
+    @NotNull(message = "用户编号不能为空.")
     public Long getAid() {
         return aid;
     }

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

@@ -125,7 +125,7 @@ public interface SysUserMapper
      */
     public SysUser checkEmailUnique(String email);
 
-    List<SysUser> selectName(@Param("name") String name,@Param("roleId") Long roleId);
+    List<SysUser> selectName(@Param("name") String name, @Param("roleId") Long roleId, @Param("companyId") Long companyId);
 
     void userAddDuration(@Param("userId") Long userId, @Param("duration") Double duration);
 

+ 4 - 2
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java

@@ -313,9 +313,11 @@ public class SysDeptServiceImpl implements ISysDeptService
 
     @Override
     public Long selectCompanyByDeptId() {
-        if (SecurityUtils.hashRoles(UserRolesType.CEO.getCode())){
+        if (SecurityUtils.hashRoles(UserRolesType.ADMIN.getCode())){
+            return null;
+        }else if (SecurityUtils.hashRoles(UserRolesType.CEO.getCode())){
             return SecurityUtils.getDeptId();
-        }else {
+        } {
             SysDept sysDept = SecurityUtils.getLoginUser().getUser().getDept();
             String[] split = sysDept.getAncestors().split(",");
             if (split.length==2)return Long.valueOf(split[1]);

+ 2 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java

@@ -555,7 +555,8 @@ public class SysUserServiceImpl implements ISysUserService
         if (type==0)roleId= UserRolesType.COMMON.getCode();
         else if (type==1)roleId=UserRolesType.MANAGE.getCode();
         if (name==null||name.length()<2)return new ArrayList<>();
-        return userMapper.selectName(name,roleId);
+        Long companyId = deptService.selectCompanyByDeptId();
+        return userMapper.selectName(name,roleId,companyId);
     }
 
     @Override

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

@@ -302,11 +302,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  	</delete>
 
 	<select id="selectName" resultType="com.ruoyi.common.core.domain.entity.SysUser">
-		select user_id userId, user_name userName,nick_name nickName
-		from sys_user
-		where user_id >1 and nick_name like concat('%',#{name},'%')
+		select a.user_id userId, a.user_name userName,a.nick_name nickName
+		from sys_user a
+		where a.user_id >1 and a.nick_name like concat('%',#{name},'%')
 		<if test="roleId!=null">
-		and user_id in (select user_id from sys_user_role where role_id = #{roleId})
+		and a.user_id in (select user_id from sys_user_role where role_id = #{roleId})
+		</if>
+		<if test="companyId !=null and companyId != 0">
+			AND (a.dept_id = #{companyId} OR a.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{companyId}, ancestors) ))
 		</if>
 	</select>