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

149 lines
6.0 KiB
XML

<?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">
<delete id="deleteById">
update tb_pro_depart set del_flag = 1
where id = #{id}
</delete>
<select id="queryByPage" resultType="com.bonus.base.domain.TbProDepart">
select
tpd.id as id,
tpd.depart_name as departName, sda.dict_label as departType, sda.dict_code as dictCode, tpd.area_id as areaId,
ta.area_name as areaName, tpd.head_user as headUser,
tpd.head_user_phone as headUserPhone, tpd.remarks as remarks, tpd.create_time as createTime, tpd.create_user as
createUser,
tpd.update_time as updateTime,
tpd.update_user as updateUser, tpd.del_flag as delFlag
from tb_pro_depart tpd
left join tb_area ta on tpd.area_id = ta.id
left join sys_dict_data sda on tpd.depart_type = sda.dict_code
where tpd.del_flag = '0'
<if test="id != null">
and tpd.id = #{id}
</if>
<if test="areaId != null and areaId != ''">
and tpd.area_id = #{areaId}
</if>
<if test="departName != null and departName != ''">
and tpd.depart_name like concat('%',#{departName},'%')
</if>
<if test="headUser != null and headUser != ''">
and tpd.head_user like concat('%',#{headUser},'%')
</if>
</select>
<!--查询单个-->
<select id="queryById" resultType="com.bonus.base.domain.TbProDepart">
select tpd.id as id,
tpd.depart_name as departName,
tpd.depart_type as departType,
tpd.area_id as areaId,
ta.area_name as areaName,
tpd.head_user as headUser,
tpd.head_user_phone as headUserPhone,
tpd.remarks as remarks,
tpd.create_time as createTime,
tpd.create_user as createUser,
tpd.update_time as updateTime,
tpd.update_user as updateUser,
tpd.del_flag as delFlag
from tb_pro_depart tpd
left join tb_area ta on tpd.area_id = ta.id
where del_flag = '0'
and tpd.id = #{id}
</select>
<select id="getAreaList" resultType="com.bonus.base.domain.TbArea">
select id as areaId, 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>
</select>
<select id="selectByName" resultType="com.bonus.base.domain.TbProDepart">
select id as id, depart_name as departName, depart_type as departType, area_id as areaId, 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
where del_flag = '0'
<if test="departName != null and departName != ''">
and depart_name = #{departName}
</if>
<if test="areaId != null and areaId != ''">
and area_id = #{areaId}
</if>
</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>
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>
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>
update_time = NOW(),
<if test="updateUser != null">
update_user = #{updateUser},
</if>
<if test="delFlag != null">
del_flag = #{delFlag},
</if>
</set>
where id = #{id}
</update>
</mapper>