فهرست منبع

用户管理部门功能添加

user5 1 سال پیش
والد
کامیت
341c6104ee

+ 16 - 0
jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/controller/OfficeController.java

@@ -135,4 +135,20 @@ public class OfficeController {
     }
 
 
+    /**
+     * 获取机构JSON数据。
+     *
+     * @param extId 排除的ID
+     * @param type  类型(1:公司;2:部门)
+     * @param showAll 是否显示不可用数据 1 显示 0 隐藏
+     * @return
+     */
+    @ApiLog("获取部门数据")
+    @GetMapping("treeData3")
+    public ResponseEntity treeData3(@RequestParam(required = false) String extId, @RequestParam(required = false) String type, @RequestParam(required = false, defaultValue = CommonConstants.NO) String showAll) {
+        List<OfficeDTO> list = officeWrapper.toDTO (officeService.list (new QueryWrapper<Office>().lambda().eq(Office::getDelFlag,"0")));
+        List rootTree = officeService.getRootTree (list, extId, type, showAll, "1");
+        return ResponseEntity.ok (rootTree);
+    }
+
 }

+ 3 - 1
jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/mapper/OfficeMapper.java

@@ -3,6 +3,7 @@
  */
 package com.jeeplus.sys.mapper;
 
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.jeeplus.core.domain.TreeMapper;
@@ -28,7 +29,8 @@ public interface OfficeMapper extends TreeMapper <Office> {
      */
     OfficeDTO getOfficeById(String id);
 
-    List<String> getOfficeNameByIds(List<String> idList);
+    @InterceptorIgnore(tenantLine = "true")
+    List<String> getOfficeNameByIds(@Param("idList")List<String> idList);
 
     /**
      * 机构列表

+ 9 - 0
jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/mapper/UserMapper.java

@@ -55,6 +55,15 @@ public interface UserMapper extends BaseMapper <User> {
     /**
      * 根据条件查询用户
      *
+     * @param id
+     * @return
+     */
+    @InterceptorIgnore(tenantLine = "true")
+    String getManageOfficeIdsById(String id);
+
+    /**
+     * 根据条件查询用户
+     *
      * @param queryWrapper
      * @return
      */

+ 6 - 0
jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/mapper/xml/UserMapper.xml

@@ -18,6 +18,7 @@
         <result property="loginIp" column="loginIp"/>
         <result property="isAdmin" column="isAdmin"/>
         <result property="loginDate" column="loginDate"/>
+        <result property="manageOfficeIds" column="manage_office_ids"/>
         <result property="tenantDTO.id" column="tenantDTO.id"/>
         <result property="tenantDTO.name" column="tenantDTO.name"/>
         <result property="companyDTO.id" column="companyDTO.id"/>
@@ -61,6 +62,7 @@
 		a.create_by_id AS "createBy.id",
 		a.create_time,
 		a.update_by_id AS "updateBy.id",
+		a.manage_office_ids AS "manageOfficeIds",
 		a.update_time,
     	c.name AS "companyDTO.name",
     	c.parent_id AS "companyDTO.parent.id",
@@ -121,6 +123,10 @@
         ${ew.customSqlSegment}
     </select>
 
+    <select id="getManageOfficeIdsById" resultType="java.lang.String">
+        select manage_office_ids from sys_user where id = #{id}
+    </select>
+
     <!-- 获得用户 -->
     <select id="getFlowAbleById" resultMap="userResult">
         SELECT

+ 21 - 1
jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/service/UserService.java

@@ -32,6 +32,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -52,6 +53,9 @@ public class UserService extends ServiceImpl <UserMapper, User> {
     private UserMapper userMapper;
 
     @Autowired
+    private OfficeService officeService;
+
+    @Autowired
     private OfficeMapper officeMapper;
 
     @Autowired
@@ -122,7 +126,20 @@ public class UserService extends ServiceImpl <UserMapper, User> {
         QueryWrapper queryWrapper = new QueryWrapper ( );
         queryWrapper.eq ( "a.id", id );
         queryWrapper.eq ( "a.del_flag", CommonConstants.NOT_DELETED ); // 排除已经删除
-        return baseMapper.get ( queryWrapper );
+        UserDTO userDTO = baseMapper.get(queryWrapper);
+        //根据用户id查询其管理部门
+        if(null != userDTO && StringUtils.isNotBlank(userDTO.getId())){
+            String manageOfficeIdsById = baseMapper.getManageOfficeIdsById(userDTO.getId());
+            if(StringUtils.isNotBlank(manageOfficeIdsById)){
+                userDTO.setManageOfficeIds(manageOfficeIdsById);
+                //获取当前人管理的部门id
+                List<String> manageOfficeIdList= Arrays.asList(userDTO.getManageOfficeIds().split(","));
+                //查询这些部门信息
+                List<String> officeNameList = officeService.getOfficeNameByIds(manageOfficeIdList);
+                userDTO.setManageOfficeNameList(officeNameList);
+            }
+        }
+        return userDTO;
     }
 
     /**
@@ -254,6 +271,9 @@ public class UserService extends ServiceImpl <UserMapper, User> {
      */
     public void saveOrUpdate(UserDTO userDTO) {
         User user = userWrapper.toEntity ( userDTO );
+        if(StringUtils.isNotBlank(userDTO.getManageOfficeIds())){
+            user.setManageOfficeIds(userDTO.getManageOfficeIds());
+        }
         super.saveOrUpdate ( user );
         if ( StrUtil.isBlank ( userDTO.getId ( ) ) ) {
             userDTO.setId ( user.getId ( ) );