<?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.qianwen.smartman.modules.smis.mapper.CommonGroupMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="groupResultMap" type="com.qianwen.smartman.modules.smis.entity.CommonGroup">
|
<id column="id" property="id"/>
|
<result column="parent_id" property="parentId"/>
|
<result column="name" property="name"/>
|
<result column="full_name" property="fullName"/>
|
<result column="code" property="code"/>
|
<result column="group_category" property="groupCategory"/>
|
<result column="sort" property="sort"/>
|
<result column="remark" property="remark"/>
|
<result column="is_deleted" property="isDeleted"/>
|
</resultMap>
|
|
<resultMap id="groupVOResultMap" type="com.qianwen.smartman.modules.smis.vo.CommonGroupVO">
|
<id column="id" property="id"/>
|
<result column="parent_id" property="parentId"/>
|
<result column="name" property="name"/>
|
<result column="full_name" property="fullName"/>
|
<result column="group_category" property="groupCategory"/>
|
<result column="sort" property="sort"/>
|
<result column="remark" property="remark"/>
|
<result column="has_children" property="hasChildren"/>
|
</resultMap>
|
|
<resultMap id="treeNodeResultMap" type="com.qianwen.core.tool.node.TreeNode">
|
<id column="id" property="id"/>
|
<result column="parent_id" property="parentId"/>
|
<result column="title" property="title"/>
|
<result column="value" property="value"/>
|
<result column="key" property="key"/>
|
<result column="has_children" property="hasChildren"/>
|
</resultMap>
|
|
<delete id="removeOrgByIds">
|
DELETE
|
FROM
|
blade_common_group
|
WHERE
|
group_type = 'group_organization'
|
AND group_category =1
|
<if test="deptIds != null and deptIds.size() > 0">
|
AND id IN
|
<foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
|
#{deptId}
|
</foreach>
|
</if>
|
</delete>
|
|
<!--物理删除组织机构-->
|
<delete id="removeOrg">
|
DELETE
|
FROM blade_common_group
|
WHERE group_type = 'group_organization'
|
AND group_category = 1
|
</delete>
|
<!--物理删除组织机构与员工的关系-->
|
<delete id="removeOrgContact">
|
DELETE
|
FROM blade_common_group_of_item
|
WHERE group_type = 'group_organization'
|
AND group_category = 1
|
</delete>
|
|
|
<select id="lazyList" resultMap="groupVOResultMap">
|
SELECT
|
common_group.* ,
|
(
|
SELECT
|
CASE WHEN count(1) > 0 THEN 1 ELSE 0 END
|
FROM
|
blade_common_group
|
WHERE
|
parent_id = common_group.id and is_deleted = 0
|
) AS "has_children"
|
FROM
|
blade_common_group common_group
|
WHERE common_group.is_deleted = 0
|
<if test="tenantId!=null and tenantId!=''">
|
and common_group.tenant_id = #{tenantId}
|
</if>
|
<if test="parentId!=null">
|
and common_group.parent_id = #{parentId}
|
</if>
|
and common_group.group_type = #{groupType}
|
and common_group.group_category = #{groupCategory}
|
<if test="p.name!=null and p.name!=''">
|
and common_group.name like concat(concat('%', #{p.name}),'%')
|
</if>
|
<if test="p.fullName!=null and p.fullName!=''">
|
and common_group.full_name like concat(concat('%', #{p.fullName}),'%')
|
</if>
|
ORDER BY common_group.sort
|
</select>
|
|
<select id="tree" resultMap="treeNodeResultMap">
|
select id, parent_id, name as title, id as "value", id as "key" from blade_common_group where is_deleted = 0
|
<if test="tenantId!=null and tenantId!=''">
|
and tenant_id = #{tenantId}
|
</if>
|
and group_category = #{groupCategory}
|
and group_type = #{groupType}
|
ORDER BY sort
|
</select>
|
|
<select id="lazyTree" resultMap="treeNodeResultMap">
|
SELECT
|
common_group.id,
|
common_group.parent_id,
|
common_group.name AS title,
|
common_group.id AS "value",
|
common_group.id AS "key",
|
(
|
SELECT
|
CASE WHEN count(1) > 0 THEN 1 ELSE 0 END
|
FROM
|
blade_common_group
|
WHERE
|
parent_id = common_group.id and is_deleted = 0
|
) AS "has_children"
|
FROM
|
blade_common_group common_group
|
WHERE
|
common_group.parent_id = #{parentId} AND common_group.is_deleted = 0
|
<if test="tenantId!=null and tenantId!=''">
|
and common_group.tenant_id = #{tenantId}
|
</if>
|
ORDER BY common_group.sort
|
</select>
|
|
<select id="getGroupNames" resultType="java.lang.String">
|
SELECT
|
name
|
FROM
|
blade_common_group
|
WHERE
|
id IN
|
<foreach collection="array" item="ids" index="index" open="(" close=")" separator=",">
|
#{ids}
|
</foreach>
|
and is_deleted = 0
|
</select>
|
|
<select id="getAllSubGroup" resultType="com.qianwen.smartman.modules.smis.entity.CommonGroup">
|
select *
|
from blade_common_group bcg1
|
where code like concat((select bcg2.code
|
from blade_common_group bcg2
|
where bcg2.id = #{id}
|
and bcg2.is_deleted = 0), '%')
|
and bcg1.is_deleted = 0
|
and bcg1.group_type = #{groupType}
|
and bcg1.group_category = #{groupCategory}
|
</select>
|
|
</mapper>
|