You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
weaver-hrm-organization/src/com/engine/organization/mapper/department/DepartmentMapper.xml

289 lines
9.5 KiB
XML

3 years ago
<?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.engine.organization.mapper.department.DepartmentMapper">
<resultMap id="BaseResultMap" type="com.engine.organization.entity.department.po.DepartmentPO">
<result column="id" property="id"/>
<result column="dept_no" property="deptNo"/>
<result column="dept_name" property="deptName"/>
<result column="dept_name_short" property="deptNameShort"/>
<result column="parent_comp" property="parentComp"/>
<result column="parent_dept" property="parentDept"/>
<result column="dept_principal" property="deptPrincipal"/>
<result column="show_order" property="showOrder"/>
<result column="description" property="description"/>
<result column="forbidden_tag" property="forbiddenTag"/>
<result column="creator" property="creator"/>
<result column="delete_type" property="deleteType"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
3 years ago
3 years ago
<!-- 表字段 -->
<sql id="baseColumns">
t
.
id
,
t.dept_no,
t.dept_name,
t.dept_name_short,
t.parent_comp,
t.parent_dept,
t.dept_principal,
t.show_order,
t.forbidden_tag
</sql>
3 years ago
<select id="getDeptListByCompId" resultType="com.engine.organization.entity.department.po.DepartmentPO">
select t.id, t.dept_name, t.parent_dept, t.dept_principal,t.parent_dept,t.parent_comp
3 years ago
from jcl_org_dept t
where delete_type = 0
</select>
<select id="getDeptListByPId" resultType="com.engine.organization.entity.department.po.DepartmentPO">
select t.id, t.dept_name, t.parent_dept, t.dept_principal
3 years ago
from jcl_org_dept t
where delete_type = 0
and parent_dept = #{PId}
3 years ago
</select>
<select id="getDeptNameById" resultType="string">
select t.dept_name
from jcl_org_dept t
where id = #{id}
</select>
3 years ago
<select id="listByFilter" parameterType="com.engine.organization.entity.department.po.DepartmentPO"
resultMap="BaseResultMap">
3 years ago
select
<include refid="baseColumns"/>
from jcl_org_dept t
where delete_type = 0
<include refid="likeSQL"/>
<if test=" parentComp != null ">
and t.parent_comp = #{parentComp}
</if>
<if test=" parentDept != null ">
and t.parent_dept = #{parentDept}
</if>
<if test=" deptPrincipal != null ">
and t.dept_principal = #{deptPrincipal}
</if>
<if test=" showOrder != null ">
and t.show_order = #{showOrder}
</if>
<if test=" forbiddenTag != null ">
and t.forbidden_tag = #{forbiddenTag}
</if>
</select>
<select id="getDeptById" resultType="com.engine.organization.entity.department.po.DepartmentPO">
3 years ago
select
<include refid="baseColumns"/>
from jcl_org_dept t
where delete_type = 0
3 years ago
and id = #{id}
</select>
<select id="listDeptsByIds" resultType="java.util.Map">
select
id,
dept_name as name
from jcl_org_dept t
WHERE delete_type = 0
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</select>
3 years ago
<select id="list" resultType="com.engine.organization.entity.department.po.DepartmentPO">
SELECT
<include refid="baseColumns"/>
FROM jcl_org_dept t
WHERE t.delete_type = 0
</select>
<select id="listByNo" resultType="com.engine.organization.entity.department.po.DepartmentPO">
select
<include refid="baseColumns"/>
from jcl_org_dept t where dept_no = #{deptNo} AND delete_type = 0
</select>
<select id="countChildByPID" resultType="java.lang.Integer">
select count(1)
from jcl_org_dept t
where delete_type = 0
and parent_dept = #{pid}
</select>
<insert id="insertIgnoreNull" parameterType="com.engine.organization.entity.department.po.DepartmentPO"
keyProperty="id"
keyColumn="id" useGeneratedKeys="true">
INSERT INTO jcl_org_dept
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="creator != null">
creator,
</if>
<if test="deleteType != null">
delete_type,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="deptNo != null ">
dept_no,
</if>
<if test="deptName != null ">
dept_name,
</if>
<if test="deptNameShort != null ">
dept_name_short,
</if>
<if test="parentComp != null ">
parent_comp,
</if>
<if test="parentDept != null ">
parent_dept,
</if>
<if test="deptPrincipal != null ">
dept_principal,
</if>
<if test="showOrder != null ">
show_order,
</if>
<if test="description != null ">
description,
</if>
forbidden_tag,
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="creator != null">
#{creator},
</if>
<if test="deleteType != null">
#{deleteType},
</if>
<if test="createTime != null">
#{createTime},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
<if test="deptNo != null ">
#{deptNo},
</if>
<if test="deptName != null ">
#{deptName},
</if>
<if test="deptNameShort != null ">
#{deptNameShort},
</if>
<if test="parentComp != null ">
#{parentComp},
</if>
<if test="parentDept != null ">
#{parentDept},
</if>
<if test="deptPrincipal != null ">
#{deptPrincipal},
</if>
<if test="showOrder != null ">
#{showOrder},
</if>
<if test="description != null ">
#{description},
</if>
0,
</trim>
</insert>
<update id="updateBaseDept" parameterType="com.engine.organization.entity.department.po.DepartmentPO">
update jcl_org_dept
<set>
creator=#{creator},
update_time=#{updateTime},
dept_name=#{deptName},
dept_name_short=#{deptNameShort},
parent_comp=#{parentComp},
parent_dept=#{parentDept},
dept_principal=#{deptPrincipal},
show_order=#{showOrder},
description=#{description},
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<update id="updateForbiddenTagById" parameterType="com.engine.organization.entity.department.po.DepartmentPO">
update jcl_org_dept
<set>
forbidden_tag=#{forbiddenTag},
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<update id="deleteByIds">
UPDATE jcl_org_dept
SET delete_type = 1
WHERE delete_type = 0
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</update>
<sql id="likeSQL">
<if test=" deptNo != null and deptNo != '' ">
and t.dept_no like CONCAT('%',#{deptNo},'%')
</if>
<if test=" deptName != null and deptName != '' ">
and t.dept_name like CONCAT('%',#{deptName},'%')
</if>
<if test=" deptNameShort != null and deptNameShort != '' ">
and t.dept_name_short like CONCAT('%',#{deptNameShort},'%')
</if>
3 years ago
<if test=" deptNameShort != null and deptNameShort != '' ">
and t.dept_name_short like CONCAT('%',#{deptNameShort},'%')
</if>
</sql>
<sql id="likeSQL" databaseId="oracle">
<if test=" deptNo != null and deptNo != '' ">
and t.dept_no like '%'||#{deptNo}||'%'
</if>
<if test=" deptName != null and deptName != '' ">
and t.dept_name like '%'||#{deptName}||'%'
</if>
<if test=" deptNameShort != null and deptNameShort != '' ">
and t.dept_name_short like '%'||#{deptNameShort}||'%'
</if>
</sql>
<sql id="likeSQL" databaseId="sqlserver">
<if test=" deptNo != null and deptNo != '' ">
and t.dept_no like '%'+#{deptNo}+'%'
</if>
<if test=" deptName != null and deptName != '' ">
and t.dept_name like '%'+#{deptName}+'%'
</if>
<if test=" deptNameShort != null and deptNameShort != '' ">
and t.dept_name_short like '%'+#{deptNameShort}+'%'
</if>
</sql>
<sql id="nullSql">
and ifnull(parent_dept,'0')='0'
</sql>
<sql id="nullSql" databaseId="sqlserver">
and isnull(parent_dept,'0')='0'
</sql>
<sql id="nullSql" databaseId="oracle">
and NVL(parent_dept,'0')='0'
</sql>
3 years ago
</mapper>