Bonus-Cloud-Material/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/BmTeamMapper.xml

113 lines
4.7 KiB
XML
Raw Normal View History

2025-06-27 14:43:33 +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.clz.mapper.BmTeamMapper">
2025-07-11 16:33:19 +08:00
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
2025-06-27 14:43:33 +08:00
INSERT INTO bm_unit
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="teamName != null">unit_name,</if>
<if test="departId != null">depart_id,</if>
<if test="relName != null">link_man,</if>
<if test="relPhone != null">telphone,</if>
create_time,
<if test="createUser != null">create_by,</if>
del_flag,
<if test="projectId != null">project_id,</if>
2025-07-11 16:33:19 +08:00
<if test="idCard != null and idCard != ''">bzz_idcard,</if>
2025-07-04 18:07:30 +08:00
<if test="typeId != null">type_id,</if>
2025-06-27 14:43:33 +08:00
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="teamName != null">#{teamName},</if>
<if test="departId != null">#{departId},</if>
<if test="relName != null">#{relName},</if>
<if test="relPhone != null">#{relPhone},</if>
NOW(),
<if test="createUser != null">#{createUser},</if>
0,
<if test="projectId != null">#{projectId},</if>
2025-07-11 16:33:19 +08:00
<if test="idCard != null and idCard != ''">#{idCard},</if>
2025-07-04 18:07:30 +08:00
<if test="typeId != null">#{typeId},</if>
2025-06-27 14:43:33 +08:00
</trim>
</insert>
<update id="update">
UPDATE bm_unit
<set>
<if test="teamName != null">unit_name = #{teamName},</if>
2025-07-11 16:33:19 +08:00
<if test="typeId != null">type_id = #{typeId},</if>
2025-06-27 14:43:33 +08:00
<if test="relName != null">link_man = #{relName},</if>
<if test="relPhone != null">telphone = #{relPhone},</if>
<if test="updateUser != null">update_by = #{updateUser},</if>
<if test="status != null">status = #{status},</if>
2025-07-11 16:33:19 +08:00
<if test="projectId != null">project_id = #{projectId},</if>
<if test="idCard != null">bzz_idcard = #{idCard},</if>
2025-06-27 14:43:33 +08:00
update_time = NOW()
</set>
WHERE unit_id = #{id}
</update>
<delete id="deleteById">
update bm_unit
set del_flag = '2'
where unit_id = #{id}
</delete>
<select id="queryByPage" resultType="com.bonus.material.clz.domain.BmTeam">
select t.unit_id as id,
t.unit_name as teamName,
t.depart_id as departId,
sd.depart_name as departName,
t.link_man as relName,
t.telphone as relPhone,
t.create_time as createTime,
t.create_by as createUser,
t.update_time as updateTime,
t.update_by as updateUser,
t.del_flag as delFlag,
t.bzz_idcard as teamLeaderIdCard
from bm_unit t
left join clz_pro_depart sd on t.depart_id = sd.id
where t.del_flag = 0 and t.status = '0'
<if test="departId != null ">
and t.depart_id = #{departId}
</if>
<if test="createUser != null">
and t.create_by = #{createUser}
</if>
<if test="idCard != null">
and t.bzz_idcard = #{idCard}
</if>
<if test="keyWord != null and keyWord != ''">
and (
t.unit_name like concat('%', #{keyWord}, '%') or
sd.depart_name like concat('%', #{keyWord}, '%') or
t.link_man like concat('%', #{keyWord}, '%') or
t.telphone like concat('%', #{keyWord}, '%')
)
</if>
ORDER BY t.create_time DESC
</select>
<select id="selectByName" resultType="com.bonus.material.clz.domain.BmTeam">
select unit_id as id, unit_name as teamName, link_man as relName,
telphone as relPhone, create_time as createTime, create_by as createUser,
2025-07-12 10:21:07 +08:00
update_time as updateTime, update_by as updateUser, del_flag as delFlag
2025-06-27 14:43:33 +08:00
from bm_unit
where del_flag = 0 and status = '0'
<if test="teamName != null and teamName != ''">
and unit_name = #{teamName}
</if>
</select>
2025-07-11 16:33:19 +08:00
<select id="getTeamList" resultType="com.bonus.material.clz.domain.BmTeam">
SELECT DISTINCT bu.unit_id AS id,
bu.unit_name AS teamName,
bu.link_man AS relName,
bu.telphone AS relPhone
FROM bm_project bpl
LEFT JOIN clz_bm_agreement_info bai ON bpl.pro_id = bai.project_id AND bai.`status` = '1'
LEFT JOIN bm_unit bu ON bai.unit_id = bu.unit_id AND bu.del_flag = '0'
WHERE bpl.pro_id = #{proId} AND bpl.del_flag = '0'
</select>
2025-06-27 14:43:33 +08:00
</mapper>