guoyujia пре 1 година
родитељ
комит
c6de62d5f1

+ 20 - 12
src/main/java/cn/ezhizao/project/system/controller/SysUserController.java

@@ -14,6 +14,7 @@ import cn.ezhizao.project.system.domain.SysDeptUser;
 import cn.ezhizao.project.system.domain.SysRole;
 import cn.ezhizao.project.system.domain.SysUser;
 import cn.ezhizao.project.system.service.*;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.validation.annotation.Validated;
@@ -121,15 +122,12 @@ public class SysUserController extends BaseController {
      * 获取用户通过deptId
      */
     @PreAuthorize("@ss.hasPermi('system:user:list')")
-    @PostMapping("/getUsersItemByDeptId")
-    public TableDataInfo getUsersItemByDeptId(@RequestBody Map<String, Object> data) {
-        startPage();
-//        Long deptId = Long.parseLong(data.get("deptId").toString());
-        String userName = data.get("userName").toString();
-        String nickName = data.get("nickName").toString();
-        List<SysUser> list = userService.selectUserItemByDeptId( userName, nickName);
-        List<SysUser> distinct = list.stream().distinct().collect(Collectors.toList());
-        return getDataTable(distinct);
+    @GetMapping("/getUsersItemByDeptId")
+    public TableDataInfo getUsersItemByDeptId(SysDeptUser sysDeptUser) {
+        String tenantId = request.getHeader("tenantId");
+        sysDeptUser.setTenantId(Long.valueOf(tenantId));
+        List<SysDeptUser> list = deptUserService.getList(sysDeptUser);
+        return getDataTable(list);
     }
 
     /** 递归获取所有下级部门 */
@@ -313,13 +311,23 @@ public class SysUserController extends BaseController {
     @Transactional
     public AjaxResult saveDeptUser(@Validated @RequestBody List<SysDeptUser> deptUserList) {
         String tenantId = request.getHeader("tenantId");
+        List<SysDeptUser> deptUsers = new ArrayList<>();
         for (SysDeptUser deptUser: deptUserList
         ) {
             deptUser.setTenantId(Long.valueOf(tenantId));
+            List<SysDeptUser> list = deptUserService.query().eq("user_id", deptUser.getUserId()).eq("dept_id", deptUser.getDeptId()).eq("tenant_id", deptUser.getTenantId()).eq("deleted", 0).list();
+            if (list.size() == 0) {
+                deptUsers.add(deptUser);
+
+            }
+
         }
-        List<SysDeptUser> oldList = deptUserService.query().eq("deleted", 0).eq("dept_id",deptUserList.get(0).getDeptId()).eq("tenant_id",Long.valueOf(tenantId)).list();
-        boolean batch = saveOrUpdateBatch(deptUserService, deptUserList, oldList);
-        return toAjax(batch);
+
+        if (deptUsers.size() == 0) {
+            return AjaxResult.error("选择用户重复,请重新选择");
+        }
+
+        return toAjax(deptUserService.saveBatch(deptUsers));
     }
 
     /**

+ 2 - 0
src/main/java/cn/ezhizao/project/system/domain/SysDeptUser.java

@@ -78,6 +78,8 @@ public class SysDeptUser extends BaseEntity {
     @TableField(exist = false)
     private String nickName ;
     @TableField(exist = false)
+    private String userName ;
+    @TableField(exist = false)
     private String deptName ;
     /**
      * 部门信息

+ 2 - 2
src/main/resources/mybatis/business/product/BizProductMapper.xml

@@ -25,8 +25,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="type != null  and type != ''"> AND type = #{type}</if>
             <if test="shaftBroadCategoryCode != null  and shaftBroadCategoryCode != ''"> AND shaft_broad_category_code = #{shaftBroadCategoryCode}</if>
             <if test="shaftCategoryCode != null  and shaftCategoryCode != ''"> AND shaft_category_code = #{shaftCategoryCode}</if>
-            <if test="specification != null  and specification != ''"> AND specification = #{specification}</if>
-            <if test="drawingNumber != null  and drawingNumber != ''"> AND drawing_number = #{drawingNumber}</if>
+            <if test="specification != null  and specification != ''"> AND specification LIKE CONCAT('%', #{specification}, '%')</if>
+            <if test="drawingNumber != null  and drawingNumber != ''"> AND drawing_number LIKE CONCAT('%',#{drawingNumber},'%')</if>
             <if test="companyAlias != null  and companyAlias != ''">  AND company_alias LIKE CONCAT('%', #{companyAlias}, '%')</if>
             <if test="description != null  and description != ''"> AND description = #{description}</if>
             <if test="diameter != null "> AND diameter = #{diameter}</if>

+ 3 - 0
src/main/resources/mybatis/system/SysDeptUserMapper.xml

@@ -44,6 +44,9 @@
         <if test="nickName!= null and nickName!= ''">
             and user_id in (select user_id from sys_user where nick_name like concat('%', #{nickName}, '%'))
         </if>
+        <if test="userName!= null and userName!= ''">
+            and user_id in (select user_id from sys_user where user_name like concat('%', #{userName}, '%'))
+        </if>
         <if test="tenantId != null  and tenantId != 0"> AND tenant_id = #{tenantId}</if>
     </select>
 

+ 7 - 1
src/main/resources/mybatis/system/SysUserMapper.xml

@@ -75,7 +75,7 @@
     </select>
 
 	<select id="selectUserItemByDeptId"  resultMap="SysUserResult">
-		SELECT u.* FROM sys_user u right join sys_dept_user d on u.user_id = d.user_id
+		SELECT u.* FROM sys_user u left join sys_dept_user d on u.user_id = d.user_id
 		WHERE u.del_flag = '0' AND d.deleted ='0' AND u.user_type = '02'
 		<if test="userName != null and userName != ''">
 			AND u.user_name LIKE concat('%', #{userName}, '%')
@@ -120,6 +120,9 @@
 		<if test="userName != null and userName != ''">
 			AND u.user_name LIKE concat('%', #{userName}, '%')
 		</if>
+		<if test="nickName != null and nickName != ''">
+			AND u.nick_name LIKE concat('%', #{nickName}, '%')
+		</if>
 		<if test="status != null and status != ''">
 			AND u.status = #{status}
 		</if>
@@ -171,6 +174,9 @@
 		<if test="userName != null and userName != ''">
 			AND u.user_name LIKE concat('%', #{userName}, '%')
 		</if>
+		<if test="nickName != null and nickName != ''">
+			AND u.nick_name LIKE concat('%', #{nickName}, '%')
+		</if>
 		<if test="status != null and status != ''">
 			AND u.status = #{status}
 		</if>