干燥机配套车间生产管理系统/云平台服务端
bsw215583320
2024-04-16 c2fccb01b972176dc3da5a497b5e904025e9e98d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package org.jeecg.modules.system.mapper;
 
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.jeecg.modules.system.entity.SysDepart;
import org.jeecg.modules.system.model.SysDepartTreeModel;
import org.jeecg.modules.system.model.TreeModel;
import org.springframework.data.repository.query.Param;
 
import java.util.List;
 
/**
 * <p>
 * 部门 Mapper 接口
 * <p>
 * 
 * @Author: Steve
 * @Since:   2019-01-22
 */
public interface SysDepartMapper extends BaseMapper<SysDepart> {
    
    /**
     * 根据用户ID查询部门集合
     * @param userId 用户id
     * @return List<SysDepart>
     */
    public List<SysDepart> queryUserDeparts(@Param("userId") String userId);
 
    /**
     * 根据用户名查询部门
     *
     * @param username
     * @return
     */
    public List<SysDepart> queryDepartsByUsername(@Param("username") String username);
 
    /**
     * 通过部门编码获取部门id
     * @param orgCode 部门编码
     * @return String
     */
    @Select("select id from sys_depart where org_code=#{orgCode}")
    public String queryDepartIdByOrgCode(@Param("orgCode") String orgCode);
 
    /**
     * 通过部门id 查询部门id,父id
     * @param departId 部门id
     * @return
     */
    @Select("select id,parent_id from sys_depart where id=#{departId}")
    public SysDepart getParentDepartId(@Param("departId") String departId);
 
    /**
     *  根据部门Id查询,当前和下级所有部门IDS
     * @param departId
     * @return
     */
    List<String> getSubDepIdsByDepId(@Param("departId") String departId);
 
    /**
     * 根据部门编码获取部门下所有IDS
     * @param orgCodes
     * @return
     */
    List<String> getSubDepIdsByOrgCodes(@org.apache.ibatis.annotations.Param("orgCodes") String[] orgCodes);
 
    /**
     * 根据parent_id查询下级部门
     * @param parentId 父id
     * @return List<SysDepart>
     */
    List<SysDepart> queryTreeListByPid(@Param("parentId") String parentId);
    /**
     * 根据id下级部门数量
     * @param parentId
     * @return
     */
    @Select("SELECT count(*) FROM sys_depart where del_flag ='0' AND parent_id = #{parentId,jdbcType=VARCHAR}")
    Integer queryCountByPid(@Param("parentId")String parentId);
    /**
     * 根据OrgCod查询所属公司信息
     * @param orgCode
     * @return
     */
    SysDepart queryCompByOrgCode(@Param("orgCode")String orgCode);
    /**
     * 根据id下级部门
     * @param parentId
     * @return
     */
    @Select("SELECT * FROM sys_depart where del_flag ='0' AND parent_id = #{parentId,jdbcType=VARCHAR}")
    List<SysDepart> queryDeptByPid(@Param("parentId")String parentId);
 
    /**
     * 通过父级id和租户id查询部门
     * @param parentId
     * @param tenantId
     * @return
     */
    @InterceptorIgnore(tenantLine = "true")
    List<SysDepart> queryBookDepTreeSync(@Param("parentId") String parentId, @Param("tenantId") Integer tenantId, @Param("departName") String departName);
 
    @InterceptorIgnore(tenantLine = "true")
    @Select("SELECT * FROM sys_depart where id = #{id,jdbcType=VARCHAR}")
    SysDepart getDepartById(@Param("id") String id);
 
    @InterceptorIgnore(tenantLine = "true")
    List<SysDepart> getMaxCodeDepart(@Param("page") Page<SysDepart> page, @Param("parentId") String parentId);
 
    /**
     * 修改部门状态字段: 是否子节点
     * @param id 部门id
     * @param leaf 叶子节点
     * @return int
     */
    @Update("UPDATE sys_depart SET iz_leaf=#{leaf} WHERE id = #{id}")
    int setMainLeaf(@Param("id") String id, @Param("leaf") Integer leaf);
}