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

172 lines
5.7 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
<select id="getDeptListByCompId" 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_comp = #{parentComp}
3 years ago
</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>
<select id="getDeptList" parameterType="com.engine.organization.entity.department.po.DepartmentPO"
resultMap="BaseResultMap">
select 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
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">
select 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
from jcl_org_dept t
where delete_type = 0
and id = #{id}
</select>
<select id="listParent" resultMap="BaseResultMap">
SELECT
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
FROM
jcl_org_dept t
WHERE t.delete_type = 0
<include refid="nullSql"/>
</select>
<select id="listChild" resultMap="BaseResultMap">
SELECT
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
FROM
jcl_org_dept t
WHERE t.delete_type = 0
AND parent_dept IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</select>
<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>
</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>