zhwl/zhwl-business/zhwl-customer/target/classes/mapper/customer/ZdyGuideMapper.xml
2025-07-01 17:54:58 +08:00

369 lines
13 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.zhwl.customer.mapper.ZdyGuideMapper">
<resultMap type="ZdyGuide" id="ZdyGuideResult">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="label" column="label"/>
<result property="gender" column="gender"/>
<result property="phone" column="phone"/>
<result property="idCard" column="id_card"/>
<result property="grade" column="grade"/>
<result property="tourGuideIdNumber" column="tour_guide_id_number"/>
<result property="image" column="image"/>
<result property="introduction" column="introduction"/>
<result property="guideNoticeId" column="guide_notice_id"/>
<result property="delFlag" column="del_flag"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
</resultMap>
<resultMap type="ZdyGuideVO" id="ZdyGuideVOResult">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="label" column="label"/>
<result property="gender" column="gender"/>
<result property="phone" column="phone"/>
<result property="idCard" column="id_card"/>
<result property="grade" column="grade"/>
<result property="tourGuideIdNumber" column="tour_guide_id_number"/>
<result property="image" column="image"/>
<result property="introduction" column="introduction"/>
<result property="guideNoticeContent" column="guide_notice_content"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
<result property="scenicName" column="scenic_name"/>
</resultMap>
<sql id="selectZdyGuideVo">
select id,
name,
label,
gender,
phone,
id_card,
grade,
tour_guide_id_number,
image,
introduction,
guide_notice_id,
del_flag,
create_by,
create_time,
update_by,
update_time,
remark
from zdy_guide g
</sql>
<select id="selectZdyGuideList" parameterType="ZdyGuide" resultMap="ZdyGuideResult">
<include refid="selectZdyGuideVo"/>
<where>
del_flag = '0'
<if test="name != null and name != ''">
and name like concat('%', #{name}, '%')
</if>
<if test="label != null and label != ''">
and label = #{label}
</if>
<if test="gender != null ">
and gender = #{gender}
</if>
<if test="phone != null and phone != ''">
and phone like concat('%', #{phone}, '%')
</if>
<if test="idCard != null and idCard != ''">
and id_card like concat('%', #{idCard}, '%')
</if>
<if test="grade != null ">
and grade = #{grade}
</if>
<if test="tourGuideIdNumber != null and tourGuideIdNumber != ''">
and tour_guide_id_number = #{tourGuideIdNumber}
</if>
<if test="image != null and image != ''">
and image = #{image}
</if>
<if test="introduction != null and introduction != ''">
and introduction = #{introduction}
</if>
<if test="guideNoticeId != null ">
and guide_notice_id = #{guideNoticeId}
</if>
${params.dataScope}
</where>
</select>
<select id="selectZdyGuideById" parameterType="Long"
resultMap="ZdyGuideResult">
<include refid="selectZdyGuideVo"/>
where id = #{id}
and del_flag = '0'
</select>
<insert id="insertZdyGuide" parameterType="ZdyGuide" useGeneratedKeys="true"
keyProperty="id">
insert into zdy_guide
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">name,
</if>
<if test="deptId != null ">dept_id,
</if>
<if test="label != null and label != ''">label,
</if>
<if test="gender != null">gender,
</if>
<if test="phone != null and phone != ''">phone,
</if>
<if test="idCard != null and idCard != ''">id_card,
</if>
<if test="grade != null">grade,
</if>
<if test="tourGuideIdNumber != null and tourGuideIdNumber != ''">tour_guide_id_number,
</if>
<if test="image != null and image != ''">image,
</if>
<if test="introduction != null and introduction != ''">introduction,
</if>
<if test="guideNoticeId != null">guide_notice_id,
</if>
<if test="delFlag != null">del_flag,
</if>
<if test="createBy != null">create_by,
</if>
<if test="createTime != null">create_time,
</if>
<if test="updateBy != null">update_by,
</if>
<if test="updateTime != null">update_time,
</if>
<if test="remark != null">remark,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">#{name},
</if>
<if test="deptId != null ">#{deptId},
</if>
<if test="label != null and label != ''">#{label},
</if>
<if test="gender != null">#{gender},
</if>
<if test="phone != null and phone != ''">#{phone},
</if>
<if test="idCard != null and idCard != ''">#{idCard},
</if>
<if test="grade != null">#{grade},
</if>
<if test="tourGuideIdNumber != null and tourGuideIdNumber != ''">#{tourGuideIdNumber},
</if>
<if test="image != null and image != ''">#{image},
</if>
<if test="introduction != null and introduction != ''">#{introduction},
</if>
<if test="guideNoticeId != null">#{guideNoticeId},
</if>
<if test="delFlag != null">#{delFlag},
</if>
<if test="createBy != null">#{createBy},
</if>
<if test="createTime != null">#{createTime},
</if>
<if test="updateBy != null">#{updateBy},
</if>
<if test="updateTime != null">#{updateTime},
</if>
<if test="remark != null">#{remark},
</if>
</trim>
</insert>
<update id="updateZdyGuide" parameterType="ZdyGuide">
update zdy_guide
<trim prefix="SET" suffixOverrides=",">
<if test="name != null and name != ''">name =
#{name},
</if>
<if test="deptId != null">dept_id =
#{deptId},
</if>
<if test="label != null and label != ''">label =
#{label},
</if>
<if test="gender != null">gender =
#{gender},
</if>
<if test="phone != null and phone != ''">phone =
#{phone},
</if>
<if test="idCard != null and idCard != ''">id_card =
#{idCard},
</if>
<if test="grade != null">grade =
#{grade},
</if>
<if test="tourGuideIdNumber != null and tourGuideIdNumber != ''">tour_guide_id_number =
#{tourGuideIdNumber},
</if>
<if test="image != null and image != ''">image =
#{image},
</if>
<if test="introduction != null and introduction != ''">introduction =
#{introduction},
</if>
<if test="guideNoticeId != null">guide_notice_id =
#{guideNoticeId},
</if>
<if test="delFlag != null">del_flag =
#{delFlag},
</if>
<if test="createBy != null">create_by =
#{createBy},
</if>
<if test="createTime != null">create_time =
#{createTime},
</if>
<if test="updateBy != null">update_by =
#{updateBy},
</if>
<if test="updateTime != null">update_time =
#{updateTime},
</if>
<if test="remark != null">remark =
#{remark},
</if>
</trim>
where id = #{id}
</update>
<delete id="deleteZdyGuideById" parameterType="Long">
delete
from zdy_guide
where id = #{id}
</delete>
<delete id="deleteZdyGuideByIds" parameterType="String">
update zdy_guide set del_flag = '1' where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="checkPhoneUnique" parameterType="string" resultMap="ZdyGuideResult">
select id, phone
from zdy_guide
where phone = #{phone}
and del_flag = '0' limit 1
</select>
<select id="checkIdCardUnique" parameterType="string" resultMap="ZdyGuideResult">
select id, id_card
from zdy_guide
where id_card = #{idCard}
and del_flag = '0' limit 1
</select>
<select id="checkTourGuideIdNumberUnique" resultMap="ZdyGuideResult">
select id, tour_guide_id_number
from zdy_guide
where dept_id = #{deptId}
and tour_guide_id_number = #{tourGuideIdNumber}
and del_flag = '0' limit 1
</select>
<select id="countByGuideNoticeId" resultType="integer">
select count(id)
from zdy_guide
where del_flag = '0'
and guide_notice_id = #{guideNoticeId}
</select>
<select id="selectZdyGuideVOList" parameterType="ZdyGuide" resultMap="ZdyGuideVOResult">
select g.id,
g.name,
g.label,
g.gender,
g.phone,
g.id_card,
g.grade,
g.tour_guide_id_number,
g.image,
g.introduction,
gn.content guide_notice_content,
g.del_flag,
g.create_by,
g.create_time,
g.update_by,
g.update_time,
g.remark,
zs.scenic_name
from zdy_guide g
left join zdy_guide_notice gn on g.guide_notice_id = gn.id
left join zdy_scenic zs on zs.dept_id = g.dept_id
<where>
g.del_flag = '0'
<if test="name != null and name != ''">
and g.name like concat('%', #{name}, '%')
</if>
<if test="label != null and label != ''">
and g.label = #{label}
</if>
<if test="gender != null ">
and g.gender = #{gender}
</if>
<if test="phone != null and phone != ''">
and g.phone like concat('%', #{phone}, '%')
</if>
<if test="idCard != null and idCard != ''">
and g.id_card like concat('%', #{idCard}, '%')
</if>
<if test="grade != null ">
and g.grade = #{grade}
</if>
<if test="tourGuideIdNumber != null and tourGuideIdNumber != ''">
and g.tour_guide_id_number = #{tourGuideIdNumber}
</if>
<if test="image != null and image != ''">
and g.image = #{image}
</if>
<if test="introduction != null and introduction != ''">
and g.introduction = #{introduction}
</if>
<if test="guideNoticeId != null ">
and g.guide_notice_id = #{guideNoticeId}
</if>
<if test="deptId != null ">
and g.dept_id = #{deptId}
</if>
${params.dataScope}
</where>
</select>
<select id="selectBaseList" resultType="java.util.Map">
SELECT
g.id,
g.name,
sex.dict_label AS gender,
g.phone,
g.id_card as idCard,
grade.dict_label AS grade,
g.tour_guide_id_number as tourGuideIdNumber,
g.image,
g.introduction,
g.label
FROM
zdy_guide g
LEFT JOIN sys_dict_data sex ON sex.dict_type = 'sys_user_sex' AND sex.dict_value = g.gender
LEFT JOIN sys_dict_data grade ON grade.dict_type = 'custom_guide_grade' AND grade.dict_value = g.grade
where g.del_flag=0
</select>
</mapper>