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

271 lines
10 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.scenic.mapper.ZdySmartGuideMapper">
<resultMap type="ZdySmartGuide" id="ZdySmartGuideResult">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="description" column="description"/>
<result property="duration" column="duration"/>
<result property="difficulty" column="difficulty"/>
<result property="createTime" column="create_time"/>
<result property="createBy" column="create_by"/>
<result property="updateTime" column="update_time"/>
<result property="updateBy" column="update_by"/>
<result property="coordinate" column="coordinate"/>
<result property="deptId" column="dept_id"/>
</resultMap>
<resultMap type="ZdySmartGuideVO" id="ZdySmartGuideVOResult">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="description" column="description"/>
<result property="duration" column="duration"/>
<result property="difficulty" column="difficulty"/>
<result property="createTime" column="create_time"/>
<result property="createBy" column="create_by"/>
<result property="updateTime" column="update_time"/>
<result property="updateBy" column="update_by"/>
<result property="coordinate" column="coordinate"/>
<result property="deptId" column="dept_id"/>
<result property="scenicName" column="scenic_name"/>
</resultMap>
<sql id="selectZdySmartGuideVo">
SELECT a.id,
a.NAME,
a.description,
a.duration,
a.difficulty,
a.create_time,
a.create_by,
a.update_time,
a.update_by,
a.dept_id,
b.spot_id AS sub_id,
b.guide_id AS sub_guide_id,
b.sort AS sub_sort,
scs.longitude,
scs.point_type_id,
scs.latitude,
scs.blurb,
scs.point_name,
scs.spot_id as sub_spot_id,
scs.ticket_id,
ti.name as ticketName,
ti.classify,
ti.sales_rice,
gr.name as groupName,
zpt.image,
a.coordinate,
scs.audio_guide_url
FROM zdy_smart_guide a
LEFT JOIN zdy_spot_guide b ON b.guide_id = a.id
LEFT JOIN zdy_point_data scs ON scs.id = b.spot_id
left join zdy_ticket ti on ti.id = scs.ticket_id
left join zdy_ticket_group gr on gr.id = ti.group_id
LEFT JOIN zdy_point_type zpt ON zpt.id = scs.point_type_id
</sql>
<resultMap id="ZdySmartGuideZdySpotGuideResult" type="ZdySmartGuide" extends="ZdySmartGuideResult">
<collection property="spotGuideList" notNullColumn="sub_guide_id"
javaType="java.util.List" resultMap="ZdySpotGuideResult"/>
</resultMap>
<resultMap type="ZdySpotGuide" id="ZdySpotGuideResult">
<result property="id" column="sub_id"/>
<result property="spotId" column="sub_spot_id"/>
<result property="latitude" column="latitude"/>
<result property="longitude" column="longitude"/>
<result property="image" column="image"/>
<result property="blurb" column="blurb"/>
<result property="guideId" column="sub_guide_id"/>
<result property="pointTypeId" column="point_type_id"/>
<result property="sort" column="sub_sort"/>
<result property="pointName" column="point_name"/>
<result property="ticketId" column="ticket_id"/>
<result property="ticketName" column="ticketName"/>
<result property="classify" column="classify"/>
<result property="salesRice" column="sales_rice"/>
<result property="groupName" column="groupName"/>
<result property="audioGuideUrl" column="audio_guide_url"/>
</resultMap>
<select id="selectZdySmartGuideList" parameterType="ZdySmartGuide" resultMap="ZdySmartGuideZdySpotGuideResult">
<include refid="selectZdySmartGuideVo"/>
<where>
<if test="id != null ">
and a.id = #{id}
</if>
<if test="name != null and name != ''">
and a.name like concat('%', #{name}, '%')
</if>
<if test="description != null and description != ''">
and a.description = #{description}
</if>
<if test="duration != null ">
and a.duration = #{duration}
</if>
<if test="difficulty != null and difficulty != ''">
and a.difficulty = #{difficulty}
</if>
<if test="spotId != null and spotId != ''">
and scs.id = #{spotId}
</if>
<if test="pointTypeId != null ">
and scs.point_type_id = #{pointTypeId}
</if>
<if test="deptId != null">
and a.dept_id = #{deptId}
</if>
</where>
order by a.id, b.sort
</select>
<select id="selectZdySmartGuideColumnList" parameterType="ZdySmartGuide" resultMap="ZdySmartGuideVOResult">
SELECT a.id,
a.NAME,
a.description,
a.duration,
a.difficulty,
a.create_time,
a.create_by,
a.update_time,
a.update_by,
a.coordinate,
(select count(1) from zdy_spot_guide b where b.guide_id = a.id )as amount,
s.scenic_name
FROM zdy_smart_guide a
left join zdy_scenic s on s.dept_id = a.dept_id
<where>
<if test="id != null ">
and a.id = #{id}
</if>
<if test="name != null and name != ''">
and a.name like concat('%', #{name}, '%')
</if>
<if test="description != null and description != ''">
and a.description = #{description}
</if>
<if test="duration != null ">
and a.duration = #{duration}
</if>
<if test="difficulty != null and difficulty != ''">
and a.difficulty = #{difficulty}
</if>
<if test="deptId != null">
and a.dept_id = #{deptId}
</if>
${params.dataScope}
</where>
order by a.id desc
</select>
<select id="selectZdySmartGuideById" parameterType="Integer"
resultMap="ZdySmartGuideZdySpotGuideResult">
<include refid="selectZdySmartGuideVo"/>
where a.id = #{id} order by b.sort
</select>
<insert id="insertZdySmartGuide" parameterType="ZdySmartGuide" useGeneratedKeys="true"
keyProperty="id">
insert into zdy_smart_guide
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">name,
</if>
<if test="description != null">description,
</if>
<if test="duration != null">duration,
</if>
<if test="difficulty != null">difficulty,
</if>
<if test="createTime != null">create_time,
</if>
<if test="createBy != null">create_by,
</if>
<if test="updateTime != null">update_time,
</if>
<if test="updateBy != null">update_by,
</if>
<if test="coordinate != null">coordinate,
</if>
<if test="deptId != null">dept_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">#{name},
</if>
<if test="description != null">#{description},
</if>
<if test="duration != null">#{duration},
</if>
<if test="difficulty != null">#{difficulty},
</if>
<if test="createTime != null">#{createTime},
</if>
<if test="createBy != null">#{createBy},
</if>
<if test="updateTime != null">#{updateTime},
</if>
<if test="updateBy != null">#{updateBy},
</if>
<if test="coordinate != null">#{coordinate},
</if>
<if test="deptId != null">#{deptId},
</if>
</trim>
</insert>
<update id="updateZdySmartGuide" parameterType="ZdySmartGuide">
update zdy_smart_guide
<trim prefix="SET" suffixOverrides=",">
<if test="name != null">name =
#{name},
</if>
<if test="description != null">description =
#{description},
</if>
<if test="duration != null">duration =
#{duration},
</if>
<if test="difficulty != null">difficulty =
#{difficulty},
</if>
<if test="createTime != null">create_time =
#{createTime},
</if>
<if test="createBy != null">create_by =
#{createBy},
</if>
<if test="updateTime != null">update_time =
#{updateTime},
</if>
<if test="updateBy != null">update_by =
#{updateBy},
</if>
<if test="coordinate != null">coordinate =
#{coordinate},
</if>
<if test="deptId != null">dept_id =
#{deptId},
</if>
</trim>
where id = #{id}
</update>
<delete id="deleteZdySmartGuideById" parameterType="Integer">
delete
from zdy_smart_guide
where id = #{id}
</delete>
<delete id="deleteZdySmartGuideByIds" parameterType="String">
delete from zdy_smart_guide where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>