248 lines
9.3 KiB
XML
248 lines
9.3 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">
|
||
|
|
|
||
|
|
<!--查询指定行数据-->
|
||
|
|
<select id="queryAllByLimit" resultMap="TbProDepartMap">
|
||
|
|
select
|
||
|
|
id, depart_name, depart_type, area_id, head_user, head_user_phone, remarks, create_time, create_user,
|
||
|
|
update_time, update_user, del_flag
|
||
|
|
from tb_pro_depart
|
||
|
|
<where>
|
||
|
|
<if test="id != null">
|
||
|
|
and id = #{id}
|
||
|
|
</if>
|
||
|
|
<if test="departName != null and departName != ''">
|
||
|
|
and depart_name = #{departName}
|
||
|
|
</if>
|
||
|
|
<if test="departType != null and departType != ''">
|
||
|
|
and depart_type = #{departType}
|
||
|
|
</if>
|
||
|
|
<if test="areaId != null">
|
||
|
|
and area_id = #{areaId}
|
||
|
|
</if>
|
||
|
|
<if test="headUser != null and headUser != ''">
|
||
|
|
and head_user = #{headUser}
|
||
|
|
</if>
|
||
|
|
<if test="headUserPhone != null and headUserPhone != ''">
|
||
|
|
and head_user_phone = #{headUserPhone}
|
||
|
|
</if>
|
||
|
|
<if test="remarks != null and remarks != ''">
|
||
|
|
and remarks = #{remarks}
|
||
|
|
</if>
|
||
|
|
<if test="createTime != null">
|
||
|
|
and create_time = #{createTime}
|
||
|
|
</if>
|
||
|
|
<if test="createUser != null">
|
||
|
|
and create_user = #{createUser}
|
||
|
|
</if>
|
||
|
|
<if test="updateTime != null">
|
||
|
|
and update_time = #{updateTime}
|
||
|
|
</if>
|
||
|
|
<if test="updateUser != null">
|
||
|
|
and update_user = #{updateUser}
|
||
|
|
</if>
|
||
|
|
<if test="delFlag != null">
|
||
|
|
and del_flag = #{delFlag}
|
||
|
|
</if>
|
||
|
|
</where>
|
||
|
|
limit #{pageable.offset}, #{pageable.pageSize}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<!--统计总行数-->
|
||
|
|
<select id="count" resultType="java.lang.Long">
|
||
|
|
select count(1)
|
||
|
|
from tb_pro_depart
|
||
|
|
<where>
|
||
|
|
<if test="id != null">
|
||
|
|
and id = #{id}
|
||
|
|
</if>
|
||
|
|
<if test="departName != null and departName != ''">
|
||
|
|
and depart_name = #{departName}
|
||
|
|
</if>
|
||
|
|
<if test="departType != null and departType != ''">
|
||
|
|
and depart_type = #{departType}
|
||
|
|
</if>
|
||
|
|
<if test="areaId != null">
|
||
|
|
and area_id = #{areaId}
|
||
|
|
</if>
|
||
|
|
<if test="headUser != null and headUser != ''">
|
||
|
|
and head_user = #{headUser}
|
||
|
|
</if>
|
||
|
|
<if test="headUserPhone != null and headUserPhone != ''">
|
||
|
|
and head_user_phone = #{headUserPhone}
|
||
|
|
</if>
|
||
|
|
<if test="remarks != null and remarks != ''">
|
||
|
|
and remarks = #{remarks}
|
||
|
|
</if>
|
||
|
|
<if test="createTime != null">
|
||
|
|
and create_time = #{createTime}
|
||
|
|
</if>
|
||
|
|
<if test="createUser != null">
|
||
|
|
and create_user = #{createUser}
|
||
|
|
</if>
|
||
|
|
<if test="updateTime != null">
|
||
|
|
and update_time = #{updateTime}
|
||
|
|
</if>
|
||
|
|
<if test="updateUser != null">
|
||
|
|
and update_user = #{updateUser}
|
||
|
|
</if>
|
||
|
|
<if test="delFlag != null">
|
||
|
|
and del_flag = #{delFlag}
|
||
|
|
</if>
|
||
|
|
</where>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<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
|
||
|
|
<where>
|
||
|
|
<if test="id != null">
|
||
|
|
tpd.id = #{id}
|
||
|
|
</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>
|
||
|
|
</where>
|
||
|
|
</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,
|
||
|
|
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_areata on tpd.area_id = ta.id
|
||
|
|
where tpd.id = #{id}
|
||
|
|
</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>
|
||
|
|
|
||
|
|
|
||
|
|
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
|
||
|
|
insert into tb_pro_depart(depart_name, depart_type, area_id, head_user, head_user_phone, remarks, create_time,
|
||
|
|
create_user, update_time, update_user, del_flag)
|
||
|
|
values
|
||
|
|
<foreach collection="entities" item="entity" separator=",">
|
||
|
|
(#{entity.departName}, #{entity.departType}, #{entity.areaId}, #{entity.headUser}, #{entity.headUserPhone},
|
||
|
|
#{entity.remarks}, #{entity.createTime}, #{entity.createUser}, #{entity.updateTime}, #{entity.updateUser},
|
||
|
|
#{entity.delFlag})
|
||
|
|
</foreach>
|
||
|
|
on duplicate key update
|
||
|
|
depart_name = values(depart_name),
|
||
|
|
depart_type = values(depart_type),
|
||
|
|
area_id = values(area_id),
|
||
|
|
head_user = values(head_user),
|
||
|
|
head_user_phone = values(head_user_phone),
|
||
|
|
remarks = values(remarks),
|
||
|
|
create_time = values(create_time),
|
||
|
|
create_user = values(create_user),
|
||
|
|
update_time = values(update_time),
|
||
|
|
update_user = values(update_user),
|
||
|
|
del_flag = values(del_flag)
|
||
|
|
</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>
|
||
|
|
<if test="createTime != null">
|
||
|
|
create_time = #{createTime},
|
||
|
|
</if>
|
||
|
|
<if test="createUser != null">
|
||
|
|
create_user = #{createUser},
|
||
|
|
</if>
|
||
|
|
<if test="updateTime != null">
|
||
|
|
update_time = #{updateTime},
|
||
|
|
</if>
|
||
|
|
<if test="updateUser != null">
|
||
|
|
update_user = #{updateUser},
|
||
|
|
</if>
|
||
|
|
<if test="delFlag != null">
|
||
|
|
del_flag = #{delFlag},
|
||
|
|
</if>
|
||
|
|
</set>
|
||
|
|
where id = #{id}
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<!--通过主键删除-->
|
||
|
|
<delete id="deleteById">
|
||
|
|
delete
|
||
|
|
from tb_pro_depart
|
||
|
|
where id = #{id}
|
||
|
|
</delete>
|
||
|
|
|
||
|
|
</mapper>
|
||
|
|
|