| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
- <mapper namespace="com.izouma.awesomeadmin.dao.DepartInfoMapper">
- <resultMap id="BaseResultMap" type="com.izouma.awesomeadmin.model.DepartInfo">
- <id column="id" property="id" jdbcType="INTEGER"/>
- <result column="depart_name" property="departName" jdbcType="VARCHAR"/>
- <result column="parent_id" property="parentId" jdbcType="INTEGER"/>
- <result column="all_parent_id" property="allParentId" jdbcType="VARCHAR"/>
- <result column="description" property="description" jdbcType="VARCHAR"/>
- <result column="depart_code" property="departCode" jdbcType="VARCHAR"/>
- <result column="org_code" property="orgCode" jdbcType="VARCHAR"/>
- <result column="type" property="type" jdbcType="INTEGER"/>
- <result column="remark" property="remark" jdbcType="VARCHAR"/>
- <result column="sort" property="sort" jdbcType="INTEGER"/>
- <result column="del_flag" property="delFlag" jdbcType="CHAR"/>
- <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
- <result column="permission" property="permission" jdbcType="VARCHAR"/>
- <result column="mis_org_code" property="misOrgCode" jdbcType="VARCHAR"/>
- <result column="mis_org_name" property="misOrgName" jdbcType="VARCHAR"/>
- <result column="mis_include" property="misInclude" jdbcType="CHAR"/>
- <result column="mis_child" property="misChild" jdbcType="VARCHAR"/>
- </resultMap>
- <sql id="Base_Column_List">
- id, depart_name, parent_id, all_parent_id, description, depart_code,
- org_code, type, remark, sort, del_flag, create_time, permission,
- mis_org_code, mis_org_name, mis_include, mis_child
- </sql>
- <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
- select
- <include refid="Base_Column_List"/>
- from sys_depart
- where id = #{id,jdbcType=INTEGER}
- </select>
- <select id="selectByPrimaryKeys" resultMap="BaseResultMap" parameterType="java.lang.String">
- select
- <include refid="Base_Column_List"/>
- from sys_depart
- where FIND_IN_SET(id, #{ids,jdbcType=INTEGER}) and del_flag = 'N'
- </select>
- <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
- delete from sys_depart
- where id = #{id,jdbcType=INTEGER}
- </delete>
- <insert id="insertSelective" parameterType="com.izouma.awesomeadmin.model.DepartInfo" useGeneratedKeys="true"
- keyProperty="id">
- insert into sys_depart
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="id != null">
- id,
- </if>
- <if test="departName != null">
- depart_name,
- </if>
- <if test="parentId != null">
- parent_id,
- </if>
- <if test="allParentId != null">
- all_parent_id,
- </if>
- <if test="description != null">
- description,
- </if>
- <if test="departCode != null">
- depart_code,
- </if>
- <if test="orgCode != null">
- org_code,
- </if>
- <if test="type != null">
- type,
- </if>
- <if test="remark != null">
- remark,
- </if>
- <if test="sort != null">
- sort,
- </if>
- <if test="delFlag != null">
- del_flag,
- </if>
- <if test="createTime != null">
- create_time,
- </if>
- <if test="permission != null">
- permission,
- </if>
- <if test="misOrgCode != null">
- mis_org_code,
- </if>
- <if test="misOrgName != null">
- mis_org_name,
- </if>
- <if test="misInclude != null">
- mis_include,
- </if>
- <if test="misChild != null">
- mis_child,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="id != null">
- #{id,jdbcType=INTEGER},
- </if>
- <if test="departName != null">
- #{departName,jdbcType=VARCHAR},
- </if>
- <if test="parentId != null">
- #{parentId,jdbcType=INTEGER},
- </if>
- <if test="allParentId != null">
- #{allParentId,jdbcType=VARCHAR},
- </if>
- <if test="description != null">
- #{description,jdbcType=VARCHAR},
- </if>
- <if test="departCode != null">
- #{departCode,jdbcType=VARCHAR},
- </if>
- <if test="orgCode != null">
- #{orgCode,jdbcType=VARCHAR},
- </if>
- <if test="type != null">
- #{type,jdbcType=INTEGER},
- </if>
- <if test="remark != null">
- #{remark,jdbcType=VARCHAR},
- </if>
- <if test="sort != null">
- #{sort,jdbcType=INTEGER},
- </if>
- <if test="delFlag != null">
- #{delFlag,jdbcType=CHAR},
- </if>
- <if test="createTime != null">
- #{createTime,jdbcType=TIMESTAMP},
- </if>
- <if test="permission != null">
- #{permission,jdbcType=VARCHAR},
- </if>
- <if test="misOrgCode != null">
- #{misOrgCode,jdbcType=VARCHAR},
- </if>
- <if test="misOrgName != null">
- #{misOrgName,jdbcType=VARCHAR},
- </if>
- <if test="misInclude != null">
- #{misInclude,jdbcType=CHAR},
- </if>
- <if test="misChild != null">
- #{misChild,jdbcType=VARCHAR},
- </if>
- </trim>
- </insert>
- <update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.DepartInfo">
- UPDATE sys_depart
- <set>
- <if test="departName != null">
- depart_name = #{departName,jdbcType=VARCHAR},
- </if>
- <if test="parentId != null">
- parent_id = #{parentId,jdbcType=INTEGER},
- </if>
- <if test="allParentId != null">
- all_parent_id = #{allParentId,jdbcType=VARCHAR},
- </if>
- <if test="description != null">
- description = #{description,jdbcType=VARCHAR},
- </if>
- <if test="departCode != null">
- depart_code = #{departCode,jdbcType=VARCHAR},
- </if>
- <if test="orgCode != null">
- org_code = #{orgCode,jdbcType=VARCHAR},
- </if>
- <if test="type != null">
- type = #{type,jdbcType=INTEGER},
- </if>
- <if test="remark != null">
- remark = #{remark,jdbcType=VARCHAR},
- </if>
- <if test="sort != null">
- sort = #{sort,jdbcType=INTEGER},
- </if>
- <if test="delFlag != null">
- del_flag = #{delFlag,jdbcType=CHAR},
- </if>
- <if test="createTime != null">
- create_time = #{createTime,jdbcType=TIMESTAMP},
- </if>
- <if test="permission != null">
- permission = #{permission,jdbcType=VARCHAR},
- </if>
- <if test="misOrgCode != null">
- mis_org_code = #{misOrgCode,jdbcType=VARCHAR},
- </if>
- <if test="misOrgName != null">
- mis_org_name = #{misOrgName,jdbcType=VARCHAR},
- </if>
- <if test="misInclude != null">
- mis_include = #{misInclude,jdbcType=CHAR},
- </if>
- <if test="misChild != null">
- mis_child = #{misChild,jdbcType=VARCHAR},
- </if>
- </set>
- where id = #{id,jdbcType=INTEGER}
- </update>
- <select id="queryDepartInfosByPage" parameterType="java.util.Map"
- resultType="com.izouma.awesomeadmin.model.DepartInfo">
- select
- <include refid="Base_Column_List"/>
- from sys_depart
- <where>
- and del_flag = 'N'
- <if test="record.id != null and !"".equals(record.id)">
- and id = #{record.id}
- </if>
- <if test="record.departName != null and !"".equals(record.departName)">
- and depart_name = #{record.departName}
- </if>
- <if test="record.parentId != null and !"".equals(record.parentId)">
- and parent_id = #{record.parentId}
- </if>
- <if test="record.allParentId != null and !"".equals(record.allParentId)">
- and all_parent_id = #{record.allParentId}
- </if>
- <if test="record.description != null and !"".equals(record.description)">
- and description = #{record.description}
- </if>
- <if test="record.departCode != null and !"".equals(record.departCode)">
- and depart_code = #{record.departCode}
- </if>
- <if test="record.orgCode != null and !"".equals(record.orgCode)">
- and org_code = #{record.orgCode}
- </if>
- <if test="record.type != null and !"".equals(record.type)">
- and type = #{record.type}
- </if>
- <if test="record.remark != null and !"".equals(record.remark)">
- and remark = #{record.remark}
- </if>
- <if test="record.sort != null and !"".equals(record.sort)">
- and sort = #{record.sort}
- </if>
- <if test="record.delFlag != null and !"".equals(record.delFlag)">
- and del_flag = #{record.delFlag}
- </if>
- <if test="record.createTime != null and !"".equals(record.createTime)">
- and create_time = #{record.createTime}
- </if>
- <if test="record.permission != null and !"".equals(record.permission)">
- and permission = #{record.permission}
- </if>
- </where>
- order by id desc
- </select>
- <select id="queryAllDepartInfo" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.DepartInfo">
- select
- <include refid="Base_Column_List"/>
- from sys_depart
- <where>
- and del_flag = 'N'
- <if test="id != null and !"".equals(id)">
- and id = #{id}
- </if>
- <if test="idStr != null and !"".equals(idStr)">
- and id in (${idStr})
- </if>
- <if test="departName != null and !"".equals(departName)">
- and depart_name = #{departName}
- </if>
- <if test="parentId != null and !"".equals(parentId)">
- and parent_id = #{parentId}
- </if>
- <if test="allParentId != null and !"".equals(allParentId)">
- and all_parent_id = #{allParentId}
- </if>
- <if test="description != null and !"".equals(description)">
- and description = #{description}
- </if>
- <if test="departCode != null and !"".equals(departCode)">
- and depart_code = #{departCode}
- </if>
- <if test="orgCode != null and !"".equals(orgCode)">
- and org_code = #{orgCode}
- </if>
- <if test="type != null and !"".equals(type)">
- and type = #{type}
- </if>
- <if test="remark != null and !"".equals(remark)">
- and remark = #{remark}
- </if>
- <if test="sort != null and !"".equals(sort)">
- and sort = #{sort}
- </if>
- <if test="delFlag != null and !"".equals(delFlag)">
- and del_flag = #{delFlag}
- </if>
- <if test="createTime != null and !"".equals(createTime)">
- and create_time = #{createTime}
- </if>
- <if test="permission != null and !"".equals(permission)">
- and permission = #{permission}
- </if>
- </where>
- order by id desc
- </select>
- <select id="queryDepartInfo" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.DepartInfo">
- select
- <include refid="Base_Column_List"/>
- from sys_depart
- <where>
- and del_flag = 'N'
- <if test="id != null and !"".equals(id)">
- and id = #{id}
- </if>
- <if test="departName != null and !"".equals(departName)">
- and depart_name = #{departName}
- </if>
- <if test="parentId != null and !"".equals(parentId)">
- and parent_id = #{parentId}
- </if>
- <if test="allParentId != null and !"".equals(allParentId)">
- and all_parent_id = #{allParentId}
- </if>
- <if test="description != null and !"".equals(description)">
- and description = #{description}
- </if>
- <if test="departCode != null and !"".equals(departCode)">
- and depart_code = #{departCode}
- </if>
- <if test="orgCode != null and !"".equals(orgCode)">
- and org_code = #{orgCode}
- </if>
- <if test="type != null and !"".equals(type)">
- and type = #{type}
- </if>
- <if test="remark != null and !"".equals(remark)">
- and remark = #{remark}
- </if>
- <if test="sort != null and !"".equals(sort)">
- and sort = #{sort}
- </if>
- <if test="delFlag != null and !"".equals(delFlag)">
- and del_flag = #{delFlag}
- </if>
- <if test="createTime != null and !"".equals(createTime)">
- and create_time = #{createTime}
- </if>
- <if test="permission != null and !"".equals(permission)">
- and permission = #{permission}
- </if>
- </where>
- LIMIT 1
- </select>
- <select id="findPower" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.DepartInfo">
- select * from sys_depart where all_parent_id LIKE '${allParentId}%' and id= #{parentId}
- </select>
- <update id="delete">
- UPDATE sys_depart SET del_flag = 'Y'
- <where>
- AND id = #{id}
- </where>
- </update>
- <select id="getParentList" resultType="departInfo" parameterType="integer">
- SELECT * from sys_depart WHERE FIND_IN_SET(id,(SELECT all_parent_id from sys_depart WHERE id = #{id})) AND del_flag = 'N'
- </select>
- <select id="getUserDeparts" resultType="com.izouma.awesomeadmin.model.DepartInfo">
- select
- <include refid="Base_Column_List"/>
- from sys_depart
- where id in (select depart_id from sys_user_depart where user_id = #{userId})
- and del_flag = 'N'
- </select>
- <insert id="setUserDeparts">
- insert into sys_user_depart (user_id, depart_id)
- values
- <foreach collection="departs" item="departId" separator=",">
- (#{userId}, #{departId})
- </foreach>
- </insert>
- <delete id="clearUserDeparts">
- delete from sys_user_depart where user_id = #{userId}
- </delete>
- <select id="getUserDepartId" resultType="java.lang.String">
- SELECT group_concat(depart_id) FROM sys_user_depart WHERE user_id = #{id}
- </select>
- <select id="getDepartUsers" resultType="com.izouma.awesomeadmin.model.UserInfo">
- select * from sys_user where id in (select user_id from sys_user_depart where depart_id = #{departId}) and del_flag = 'N'
- </select>
- <select id="getChildDepartsByUserId" resultType="com.izouma.awesomeadmin.model.DepartInfo">
- SELECT
- *
- FROM
- sys_depart
- WHERE
- sys_depart.del_flag = 'N'
- AND (
- FIND_IN_SET(
- sys_depart.id,
- (
- SELECT
- sys_user.mis_child
- FROM
- sys_user
- WHERE
- sys_user.del_flag = 'N'
- AND sys_user.id = #{userId}
- )
- )
- OR FIND_IN_SET(
- sys_depart.id,
- (
- SELECT
- child_depart.mis_child
- FROM
- sys_depart child_depart
- WHERE
- child_depart.id = (
- SELECT
- sys_user_depart.depart_id
- FROM
- sys_user_depart,
- sys_user
- WHERE
- sys_user_depart.user_id = #{userId}
- AND sys_user.inherit_flag = 'Y'
- AND sys_user.id = #{userId}
- ORDER BY
- sys_user_depart.id DESC
- LIMIT 1
- )
- )
- )
- )
- </select>
- </mapper>
|