<?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.gkhy.safePlatform.account.repository.DepartmentInfoRepository" >
|
|
<resultMap id="DepartmentDO" type="com.gkhy.safePlatform.account.entity.enterprise.DepartmentInfoDO">
|
<result property="id" column="id"/>
|
<result property="name" column="name" />
|
<result property="code" column="code" />
|
<result property="info" column="info" />
|
<result property="parentId" column="parent_id" />
|
<result property="status" column="status" />
|
<result property="level" column="level" />
|
</resultMap>
|
|
<resultMap id="DepartmentInfo" type="com.gkhy.safePlatform.account.entity.enterprise.DepartmentInfo">
|
<result property="id" column="id"/>
|
<result property="name" column="name" />
|
<result property="code" column="code" />
|
<result property="info" column="info" />
|
<result property="parentId" column="parent_id" />
|
<result property="gmtCreate" column="gmt_create" />
|
<result property="gmtModified" column="gmt_modified" />
|
<result property="status" column="status"/>
|
<result property="level" column="level"/>
|
</resultMap>
|
|
<insert id="insertDepartmentInfo"
|
parameterType="com.gkhy.safePlatform.account.entity.enterprise.DepartmentInfo"
|
keyProperty="id"
|
useGeneratedKeys="true">
|
insert into
|
sys_department
|
<trim prefix="(" suffix=")" suffixOverrides="," >
|
<if test="name != null" >
|
name,
|
</if>
|
<if test="code != null" >
|
code,
|
</if>
|
<if test="info != null" >
|
info,
|
</if>
|
<if test="parentId != null" >
|
parent_id,
|
</if>
|
<if test="status != null" >
|
status,
|
</if>
|
<if test="level != null" >
|
level,
|
</if>
|
<if test="gmtCreate != null" >
|
gmt_create,
|
</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides="," >
|
<if test="name != null" >
|
#{name},
|
</if>
|
<if test="code != null" >
|
#{code},
|
</if>
|
<if test="info != null" >
|
#{info},
|
</if>
|
<if test="parentId != null" >
|
#{parentId},
|
</if>
|
<if test="status != null" >
|
#{status},
|
</if>
|
<if test="level != null" >
|
#{level},
|
</if>
|
<if test="gmtCreate != null" >
|
#{gmtCreate},
|
</if>
|
</trim>
|
|
|
</insert>
|
<update id="updateDepartmentInfo" parameterType="com.gkhy.safePlatform.account.entity.enterprise.DepartmentInfoDO">
|
update sys_department
|
<set>
|
<if test="name != null">
|
name = #{name},
|
</if>
|
<if test="code != null">
|
code = #{code},
|
</if>
|
<if test="info != null">
|
info = #{info},
|
</if>
|
<if test="status != null">
|
status = #{status},
|
</if>
|
<if test="level != null">
|
level = #{level},
|
</if>
|
<if test="parentId != null">
|
parent_id = #{parentId},
|
</if>
|
<if test="gmtModified != null" >
|
gmt_modified = #{gmtModified},
|
</if>
|
</set>
|
where id = #{id,jdbcType=BIGINT}
|
|
</update>
|
|
|
<select id="getDepartmentListByStatus"
|
parameterType="long"
|
resultMap="DepartmentDO">
|
select
|
department.id,
|
department.name,
|
department.info,
|
department.code,
|
department.status,
|
department.level,
|
department.parent_id
|
from sys_department as department
|
<where>
|
status = #{status}
|
</where>
|
|
</select>
|
<select id="getDepartmentInfoById" parameterType="long" resultMap="DepartmentInfo">
|
select
|
department.id,
|
department.name,
|
department.code,
|
department.info,
|
department.status,
|
department.level,
|
department.parent_id,
|
department.gmt_create,
|
department.gmt_modified
|
from sys_department as department
|
where department.id = #{id}
|
and department.status = 1
|
</select>
|
<select id="listDepartmentByParentId"
|
parameterType="long"
|
resultMap="DepartmentDO">
|
select
|
department.id,
|
department.name,
|
department.code,
|
department.info,
|
department.status,
|
department.level,
|
department.parent_id
|
from sys_department as department
|
where 1 = 1
|
and department.status = 1
|
<choose>
|
<when test="parentId != null">
|
and department.parent_id = #{parentId}
|
</when>
|
<otherwise>
|
and department.parent_id is null
|
</otherwise>
|
</choose>
|
</select>
|
<select id="getDepartmentInfoDOById"
|
parameterType="long"
|
resultMap="DepartmentDO">
|
select
|
department.id,
|
department.name,
|
department.code,
|
department.info,
|
department.status,
|
department.level,
|
department.parent_id
|
from sys_department as department
|
where department.id = #{id}
|
</select>
|
<select id="getParentDepartmentInfoDOByDepId"
|
parameterType="long"
|
resultMap="DepartmentDO">
|
select
|
parentDep.id,
|
parentDep.name,
|
parentDep.code,
|
parentDep.info,
|
parentDep.status,
|
parentDep.level,
|
parentDep.parent_id
|
from sys_department as department
|
inner join sys_department as parentDep on parentDep.id = department.parent_id
|
where department.id = #{id}
|
</select>
|
|
<select id="listSubDepIdsByParentId"
|
parameterType="long"
|
resultType="java.lang.Long">
|
select
|
id
|
from sys_department
|
where status = 1
|
and parent_id = #{depId}
|
|
|
</select>
|
</mapper>
|