SafetyAlertSystem/bonus-modules/bonus-base/src/main/resources/mapper/TbProDepartMapper.xml

138 lines
5.4 KiB
XML
Raw Normal View History

2024-09-09 11:53:59 +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.base.mapper.TbProDepartMapper">
2024-09-09 12:09:30 +08:00
<delete id="deleteById">
update tb_pro_depart set del_flag = 1
where id = #{id}
</delete>
2024-09-09 11:53:59 +08:00
<select id="queryByPage" resultType="com.bonus.base.domain.TbProDepart">
select
tpd.id as id,
depart_name as departName, depart_type as departType, area_id as areaId, ta.area_name as areaName,head_user as
headUser,
head_user_phone as headUserPhone, remarks as remarks, create_time as createTime, create_user as createUser,
update_time as updateTime,
update_user as updateUser, del_flag as delFlag
from tb_pro_depart tpd
left join tb_area ta on tpd.area_id = ta.id
2024-09-09 13:59:30 +08:00
where del_flag = '0'
2024-09-09 11:53:59 +08:00
<if test="id != null">
2024-09-09 13:59:30 +08:00
and tpd.id = #{id}
2024-09-09 11:53:59 +08:00
</if>
<if test="areaName != null and areaName != ''">
and ta.area_name like concat('%',#{areaName},'%')
</if>
<if test="departName != null and departName != ''">
and depart_name like concat('%',#{departName},'%')
</if>
<if test="headUser != null and headUser != ''">
and head_user like concat('%',#{headUser},'%')
</if>
</select>
<!--查询单个-->
<select id="queryById" resultType="com.bonus.base.domain.TbProDepart">
select tpd.id as id,
depart_name as departName,
depart_type as departType,
area_id as areaId,
ta.area_name as areaName,
2024-09-09 13:59:30 +08:00
head_user as headUser,
2024-09-09 11:53:59 +08:00
head_user_phone as headUserPhone,
remarks as remarks,
create_time as createTime,
create_user as createUser,
update_time as updateTime,
update_user as updateUser,
del_flag as delFlag
from tb_pro_depart tpd
left join tb_areata on tpd.area_id = ta.id
2024-09-09 13:59:30 +08:00
where del_flag = '0'
and tpd.id = #{id}
</select>
<select id="getAreaList" resultType="com.bonus.base.domain.TbArea">
select id as id, area_name as areaName, area_type as areaType, p_id as pId
from tb_area
where del_flag = '0'
<if test="areaType != null and areaType != ''">
and area_type = #{areaType}
</if>
</select>
<select id="getDataList" resultType="com.bonus.base.domain.TbData">
select dict_code as dictCode, dict_label as dictLabel, dict_value as dictValue, dict_sort as dictSort, dict_type as
dictType
from sys_dict_data
where status = '0'
<if test="dictType != null and dictType != ''">
and dict_type = #{dictType}
</if>
2024-09-09 11:53:59 +08:00
</select>
<!--新增所有列-->
<insert id="insert">
INSERT INTO tb_pro_depart
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="departName != null">depart_name,</if>
<if test="departType != null">depart_type,</if>
<if test="areaId != null">area_id,</if>
<if test="headUser != null">head_user,</if>
<if test="headUserPhone != null">head_user_phone,</if>
<if test="remarks != null">remarks,</if>
create_time,
<if test="createUser != null">create_user,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateUser != null">update_user,</if>
del_flag
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="departName != null">#{departName},</if>
<if test="departType != null">#{departType},</if>
<if test="areaId != null">#{areaId},</if>
<if test="headUser != null">#{headUser},</if>
<if test="headUserPhone != null">#{headUserPhone},</if>
<if test="remarks != null">#{remarks},</if>
NOW(),
<if test="createUser != null">#{createUser},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateUser != null">#{updateUser},</if>
0
</trim>
</insert>
<!--通过主键修改数据-->
<update id="update">
update tb_pro_depart
<set>
<if test="departName != null and departName != ''">
depart_name = #{departName},
</if>
<if test="departType != null and departType != ''">
depart_type = #{departType},
</if>
<if test="areaId != null">
area_id = #{areaId},
</if>
<if test="headUser != null and headUser != ''">
head_user = #{headUser},
</if>
<if test="headUserPhone != null and headUserPhone != ''">
head_user_phone = #{headUserPhone},
</if>
<if test="remarks != null and remarks != ''">
remarks = #{remarks},
</if>
2024-09-09 12:09:30 +08:00
update_time = NOW(),
2024-09-09 11:53:59 +08:00
<if test="updateUser != null">
update_user = #{updateUser},
</if>
<if test="delFlag != null">
del_flag = #{delFlag},
</if>
</set>
where id = #{id}
</update>
</mapper>