2024-09-26 16:15:51 +08:00
|
|
|
<?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.bonus.material.basic.mapper.BmUnitPersonMapper">
|
|
|
|
|
<resultMap type="com.bonus.material.basic.domain.BmUnitPerson" id="BmUnitPersonResult">
|
|
|
|
|
<result property="ID" column="ID" />
|
|
|
|
|
<result property="unitId" column="unit_id" />
|
|
|
|
|
<result property="userId" column="user_id" />
|
|
|
|
|
<result property="companyId" column="company_id" />
|
|
|
|
|
<result property="createTime" column="create_time" />
|
|
|
|
|
<result property="updateTime" column="update_time" />
|
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
<sql id="selectBmUnitPersonVo">
|
|
|
|
|
select ID, unit_id, user_id, company_id, create_time, update_time from bm_unit_person
|
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
|
|
<select id="selectBmUnitPersonList" parameterType="com.bonus.material.basic.domain.BmUnitPerson" resultMap="BmUnitPersonResult">
|
|
|
|
|
<include refid="selectBmUnitPersonVo"/>
|
|
|
|
|
<where>
|
|
|
|
|
<if test="userId != null "> and user_id = #{userId}</if>
|
|
|
|
|
<if test="companyId != null and companyId != ''"> and company_id = #{companyId}</if>
|
|
|
|
|
</where>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectBmUnitPersonByID" parameterType="Long" resultMap="BmUnitPersonResult">
|
|
|
|
|
<include refid="selectBmUnitPersonVo"/>
|
|
|
|
|
where ID = #{ID}
|
|
|
|
|
</select>
|
2024-10-14 17:11:46 +08:00
|
|
|
|
|
|
|
|
<select id="selectDeptTree" resultType="com.bonus.common.biz.domain.SysDeptTree">
|
|
|
|
|
<choose>
|
|
|
|
|
<!-- 当 isTree 为 1 时执行 -->
|
|
|
|
|
<when test="isTree != null and isTree == 1">
|
|
|
|
|
SELECT
|
|
|
|
|
d.dept_id AS deptId,
|
|
|
|
|
d.parent_id AS parentId,
|
|
|
|
|
d.ancestors,
|
|
|
|
|
d.dept_name AS deptName,
|
|
|
|
|
d.order_num,
|
|
|
|
|
d.leader,
|
|
|
|
|
d.phone,
|
|
|
|
|
d.email,
|
|
|
|
|
d.status,
|
|
|
|
|
d.del_flag,
|
|
|
|
|
d.create_by,
|
|
|
|
|
d.create_time
|
|
|
|
|
FROM sys_dept d
|
|
|
|
|
WHERE d.del_flag = '0'
|
|
|
|
|
AND d.status = '0'
|
|
|
|
|
AND (LENGTH(d.ancestors) - LENGTH(REPLACE(d.ancestors, ',', ''))) + 1 != 3
|
|
|
|
|
</when>
|
|
|
|
|
<!-- 否则执行默认查询 -->
|
|
|
|
|
<otherwise>
|
|
|
|
|
SELECT
|
|
|
|
|
*
|
|
|
|
|
FROM
|
|
|
|
|
(
|
|
|
|
|
SELECT
|
|
|
|
|
d.dept_id AS deptId,
|
|
|
|
|
d.parent_id AS parentId,
|
|
|
|
|
d.dept_name AS deptName
|
|
|
|
|
FROM sys_dept d
|
|
|
|
|
WHERE d.del_flag = '0'
|
|
|
|
|
AND d.STATUS = '0'
|
|
|
|
|
UNION
|
|
|
|
|
SELECT
|
|
|
|
|
su.user_id AS deptId,
|
|
|
|
|
su.dept_id AS parentId,
|
|
|
|
|
su.user_name AS deptName
|
|
|
|
|
FROM sys_user su
|
|
|
|
|
LEFT JOIN sys_dept sd ON su.dept_id = sd.dept_id
|
|
|
|
|
) AS combined_results
|
|
|
|
|
</otherwise>
|
|
|
|
|
</choose>
|
|
|
|
|
</select>
|
|
|
|
|
|
2024-09-26 16:15:51 +08:00
|
|
|
<insert id="insertBmUnitPerson" parameterType="com.bonus.material.basic.domain.BmUnitPerson" useGeneratedKeys="true" keyProperty="ID">
|
|
|
|
|
insert into bm_unit_person
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="unitId != null">unit_id,</if>
|
|
|
|
|
<if test="userId != null">user_id,</if>
|
|
|
|
|
<if test="companyId != null">company_id,</if>
|
|
|
|
|
<if test="createTime != null">create_time,</if>
|
|
|
|
|
<if test="updateTime != null">update_time,</if>
|
|
|
|
|
</trim>
|
|
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="unitId != null">#{unitId},</if>
|
|
|
|
|
<if test="userId != null">#{userId},</if>
|
|
|
|
|
<if test="companyId != null">#{companyId},</if>
|
|
|
|
|
<if test="createTime != null">#{createTime},</if>
|
|
|
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
|
|
|
</trim>
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<update id="updateBmUnitPerson" parameterType="com.bonus.material.basic.domain.BmUnitPerson">
|
|
|
|
|
update bm_unit_person
|
|
|
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
|
|
|
<if test="unitId != null">unit_id = #{unitId},</if>
|
|
|
|
|
<if test="userId != null">user_id = #{userId},</if>
|
|
|
|
|
<if test="companyId != null">company_id = #{companyId},</if>
|
|
|
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
|
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
|
|
|
</trim>
|
|
|
|
|
where ID = #{ID}
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteBmUnitPersonByID" parameterType="Long">
|
|
|
|
|
delete from bm_unit_person where ID = #{ID}
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteBmUnitPersonByIDs" parameterType="String">
|
|
|
|
|
delete from bm_unit_person where ID in
|
|
|
|
|
<foreach item="ID" collection="array" open="(" separator="," close=")">
|
|
|
|
|
#{ID}
|
|
|
|
|
</foreach>
|
|
|
|
|
</delete>
|
|
|
|
|
</mapper>
|