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

561 lines
22 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.ZdyScenicMapper">
<resultMap type = "ZdyScenic" id = "ZdyScenicResult">
<result property = "id" column = "id"/>
<result property = "deptId" column = "dept_id"/>
<result property = "scenicName" column = "scenic_name"/>
<result property = "address" column = "address"/>
<result property = "coordinate" column = "coordinate"/>
<result property = "scenicLevel" column = "scenic_level"/>
<result property = "adjust" column = "adjust"/>
<result property = "officialPhone" column = "official_phone"/>
<result property = "image" column = "image"/>
<result property = "blurb" column = "blurb"/>
<result property = "reachinfo" column = "reachinfo"/>
<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 = "delFlag" column = "del_flag"/>
<result property = "deptName" column = "dept_name"/>
<result property = "scenicLevelName" column = "scenicLevelName"/>
<result property = "audioGuideUrl" column = "audio_guide_url"/>
<result property = "imagePage" column = "image_page"/>
<result property = "areaCity" column = "area_city"/>
<result property = "logo" column = "logo"/>
<result property = "complaintPhone" column = "complaint_phone"/>
<result property = "recommend" column = "recommend"/>
<result property = "textType" column = "text_type"/>
<result property = "mapId" column = "map_id"/>
<result property = "minPrice" column = "min_price"/>
<result property = "flag" column = "flag"/>
<result property = "spotNum" column = "spotNum"/>
<result property="pftId" column="pft_id"/>
<collection property = "tagList" javaType = "java.util.List" ofType = "ZdyScenicTags"
select = "selectZdyScenicTagsByScenicId" column = "id"/>
</resultMap>
<resultMap id = "ZdyScenicZdyScenicSpotResult" type = "ScenicSpotVo" extends = "ZdyScenicResult">
<collection property = "spotList" notNullColumn = "sub_scenic_id" javaType = "java.util.List" resultMap = "ZdyScenicSpotVoResult"/>
</resultMap>
<resultMap type = "ScenicSpotVo" id = "ZdyScenicSpotVoResult">
<result property = "id" column = "sub_id"/>
<result property = "scenicName" column = "sub_scenic_name"/>
</resultMap>
<resultMap id = "ZdyScenicZdyScenicTicketResult" type = "ScenicTicketVo" extends = "ZdyScenicResult">
<collection property = "ticketList" notNullColumn = "sub_scenic_id" javaType = "java.util.List" resultMap = "ZdyScenicTicketResult"/>
</resultMap>
<resultMap type = "TicketVo" id = "ZdyScenicTicketResult">
<result property = "id" column = "sub_id"/>
<result property = "ticketName" column = "sub_name"/>
</resultMap>
<resultMap type = "ZdyScenicTags" id = "ZdyScenicTagsResult">
<result property = "id" column = "tag_id"/>
<result property = "name" column = "tag_name"/>
<result property = "scenicId" column = "tag_scenic_id"/>
</resultMap>
<select id = "selectZdyScenicTagsByScenicId" parameterType = "Long" resultMap = "ZdyScenicTagsResult">
select id as tag_id, name as tag_name, scenic_id as tag_scenic_id
from zdy_scenic_tags
where scenic_id = #{id}
</select>
<sql id = "selectZdyScenicVo">
SELECT a.id,
a.dept_id,
a.scenic_name,
a.address,
a.coordinate,
a.scenic_level,
a.adjust,
a.official_phone,
a.image,
a.blurb,
a.reachinfo,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
a.del_flag,
a.audio_guide_url,
a.image_page,
a.area_city,
d.dept_name,
a.logo,
a.recommend,
a.text_type,
a.complaint_phone,
a.flag,
a.pft_id
FROM zdy_scenic a
LEFT JOIN sys_dept d ON d.dept_id = a.dept_id
</sql>
<select id = "selectZdyScenicList" parameterType = "ZdyScenic" resultMap = "ZdyScenicResult">
SELECT a.id,
a.dept_id,
a.scenic_name,
a.address,
a.coordinate,
a.scenic_level,
a.adjust,
a.official_phone,
a.image,
a.reachinfo,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
a.del_flag,
a.audio_guide_url,
a.image_page,
a.area_city,
d.dept_name,
a.logo,
a.recommend,
a.text_type,
a.complaint_phone,
a.blurb,
a.flag,
a.pft_id
FROM zdy_scenic a
LEFT JOIN sys_dept d ON d.dept_id = a.dept_id
<where>
a.del_flag = '0'
<if test = "deptId != null ">
and a.dept_id = #{deptId}
</if>
<if test = "scenicName != null and scenicName != ''">
and a.scenic_name like concat('%', #{scenicName}, '%')
</if>
<if test = "deptList != null ">
and a.dept_id in
<foreach collection = "deptList" item = "deptId" open = "(" separator = "," close = ")">
#{deptId}
</foreach>
</if>
<if test = "address != null and address != ''">
and a.address = #{address}
</if>
<if test = "coordinate != null and coordinate != ''">
and a.coordinate = #{coordinate}
</if>
<if test = "scenicLevel != null and scenicLevel != ''">
and a.scenic_level = #{scenicLevel}
</if>
<if test = "adjust != null and adjust != ''">
and a.adjust = #{adjust}
</if>
<if test = "officialPhone != null and officialPhone != ''">
and a.official_phone = #{officialPhone}
</if>
<if test = "image != null and image != ''">
and a.image = #{image}
</if>
<if test = "blurb != null and blurb != ''">
and a.blurb = #{blurb}
</if>
<if test = "reachinfo != null and reachinfo != ''">
and a.reachinfo = #{reachinfo}
</if>
<if test = "recommend != null and recommend != ''">
and a.recommend = #{recommend}
</if>
<if test = "flag != null and flag != ''">
and find_in_set(#{flag},a.flag)
</if>
${params.dataScope}
</where>
order by a.update_time desc
</select>
<select id = "selectZdyScenicListApp" parameterType = "ZdyScenic" resultMap = "ZdyScenicResult">
SELECT a.id,
a.dept_id,
a.scenic_name,
a.address,
a.coordinate,
a.scenic_level,
a.adjust,
a.official_phone,
a.image,
a.reachinfo,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
a.del_flag,
a.audio_guide_url,
a.image_page,
a.area_city,
d.dept_name,
a.logo,
a.recommend,
a.text_type,
a.complaint_phone,
a.flag,
a.pft_id,
ROUND(ST_DISTANCE_SPHERE(
POINT(substr(coordinate, 1, instr(coordinate, ',') - 1),
substr(coordinate, instr(coordinate, ',') + 1)),
POINT(#{params.longitude}, #{params.latitude})) / 1000, 2) distance,
zpm.id map_id,
i.min_price,
(select count(1) FROM zdy_scenic_spot where scenic_id = a.id and status = 1 and del_flag=0) spotNum
FROM zdy_scenic a
LEFT JOIN sys_dept d ON d.dept_id = a.dept_id
left join zdy_point_map zpm on a.dept_id = zpm.dept_id
left join (select t.scenic_id, MIN(sales_rice) min_price
from zdy_ticket t
where scenic_id is not null
group by t.scenic_id) i on a.id = i.scenic_id
<where>
a.del_flag = '0'
<if test = "deptId != null ">
and a.dept_id = #{deptId}
</if>
<if test = "scenicName != null and scenicName != ''">
and a.scenic_name like concat('%', #{scenicName}, '%')
</if>
<if test = "deptList != null ">
and a.dept_id in
<foreach collection = "deptList" item = "deptId" open = "(" separator = "," close = ")">
#{deptId}
</foreach>
</if>
<if test = "address != null and address != ''">
and a.address = #{address}
</if>
<if test = "coordinate != null and coordinate != ''">
and a.coordinate = #{coordinate}
</if>
<if test = "scenicLevel != null and scenicLevel != ''">
and a.scenic_level = #{scenicLevel}
</if>
<if test = "adjust != null and adjust != ''">
and a.adjust = #{adjust}
</if>
<if test = "officialPhone != null and officialPhone != ''">
and a.official_phone = #{officialPhone}
</if>
<if test = "image != null and image != ''">
and a.image = #{image}
</if>
<if test = "blurb != null and blurb != ''">
and a.blurb = #{blurb}
</if>
<if test = "reachinfo != null and reachinfo != ''">
and a.reachinfo = #{reachinfo}
</if>
<if test = "recommend != null and recommend != ''">
and a.recommend = #{recommend}
</if>
<if test = "flag != null and flag != ''">
and find_in_set(#{flag},a.flag)
</if>
</where>
order by ISNULL(distance),distance asc
</select>
<select id = "selectZdyScenicById" parameterType = "Long" resultMap = "ZdyScenicResult">
<include refid = "selectZdyScenicVo"/>
where a.id = #{id}
</select>
<select id = "selectZdyScenicByScenicCode" parameterType = "String" resultMap = "ZdyScenicResult">
<include refid = "selectZdyScenicVo"/>
where a.scenic_code = #{scenicCode} and a.del_flag='0' order by a.id desc
</select>
<select id = "selectZdyScenicByDeptId" parameterType = "Long" resultMap = "ZdyScenicResult">
<include refid = "selectZdyScenicVo"/>
where a.dept_id = #{deptId} and a.del_flag='0' order by a.id desc
</select>
<insert id = "insertZdyScenic" parameterType = "ZdyScenic" useGeneratedKeys = "true" keyProperty = "id">
insert into zdy_scenic
<trim prefix = "(" suffix = ")" suffixOverrides = ",">
<if test = "deptId != null">dept_id,</if>
<if test = "scenicName != null and scenicName != ''">scenic_name,</if>
<if test = "address != null">address,</if>
<if test = "coordinate != null">coordinate,</if>
<if test = "scenicLevel != null">scenic_level,</if>
<if test = "adjust != null">adjust,</if>
<if test = "officialPhone != null">official_phone,</if>
<if test = "image != null">image,</if>
<if test = "blurb != null">blurb,</if>
<if test = "reachinfo != null">reachinfo,</if>
<if test = "createBy != null">create_by,</if>
<if test = "audioGuideUrl != null">audio_guide_url,</if>
<if test = "imagePage != null">image_page,</if>
<if test = "areaCity != null">area_city,</if>
<if test = "logo != null">logo,</if>
<if test = "complaintPhone != null">complaint_phone,</if>
<if test = "textType != null">text_type,</if>
<if test = "flag != null">flag,</if>
<if test="pftId !=null">pft_id,</if>
del_flag, create_time,
</trim>
<trim prefix = "values (" suffix = ")" suffixOverrides = ",">
<if test = "deptId != null">#{deptId},</if>
<if test = "scenicName != null and scenicName != ''">#{scenicName},</if>
<if test = "address != null">#{address},</if>
<if test = "coordinate != null">#{coordinate},</if>
<if test = "scenicLevel != null">#{scenicLevel},</if>
<if test = "adjust != null">#{adjust},</if>
<if test = "officialPhone != null">#{officialPhone},</if>
<if test = "image != null">#{image},</if>
<if test = "blurb != null">#{blurb},</if>
<if test = "reachinfo != null">#{reachinfo},</if>
<if test = "createBy != null">#{createBy},</if>
<if test = "audioGuideUrl != null">#{audioGuideUrl},</if>
<if test = "imagePage != null">#{imagePage},</if>
<if test = "areaCity != null">#{areaCity},</if>
<if test = "logo != null">#{logo},</if>
<if test = "complaintPhone != null">#{complaintPhone},</if>
<if test = "textType != null">#{textType},</if>
<if test = "flag != null">#{flag},</if>
<if test="pftId !=null">#{pftId},</if>
'0', sysdate(),
</trim>
</insert>
<update id = "updateZdyScenic" parameterType = "ZdyScenic">
update zdy_scenic
<trim prefix = "SET" suffixOverrides = ",">
<if test = "deptId != null">dept_id = #{deptId},</if>
<if test = "scenicName != null and scenicName != ''">scenic_name = #{scenicName},</if>
<if test = "address != null">address = #{address},</if>
<if test = "coordinate != null">coordinate = #{coordinate},</if>
<if test = "scenicLevel != null">scenic_level = #{scenicLevel},</if>
<if test = "adjust != null">adjust = #{adjust},</if>
<if test = "officialPhone != null">official_phone = #{officialPhone},</if>
<if test = "image != null">image = #{image},</if>
<if test = "blurb != null">blurb = #{blurb},</if>
<if test = "reachinfo != null">reachinfo = #{reachinfo},</if>
<if test = "updateBy != null">update_by = #{updateBy},</if>
<if test = "audioGuideUrl != null">audio_guide_url = #{audioGuideUrl},</if>
<if test = "imagePage != null">image_page = #{imagePage},</if>
<if test = "areaCity != null">area_city = #{areaCity},</if>
<if test = "logo != null">logo = #{logo},</if>
<if test = "complaintPhone != null">complaint_phone = #{complaintPhone},</if>
<if test = "textType != null">text_type = #{textType},</if>
<if test = "flag != null">flag = #{flag},</if>
<if test="pftId !=null">pft_id = #{pftId},</if>
update_time = sysdate(),
</trim>
where id = #{id}
</update>
<delete id = "deleteZdyScenicById" parameterType = "Long">
update zdy_scenic
set del_flag = '1'
where id = #{id}
</delete>
<delete id = "deleteZdyScenicByIds" parameterType = "String">
update zdy_scenic set del_flag = '1' where id in
<foreach item = "id" collection = "array" open = "(" separator = "," close = ")">
#{id}
</foreach>
</delete>
<select id = "selectZdyScenicInfoList" resultType = "map">
SELECT id,
scenic_name as scenicName,
image,
coordinate,
blurb,
address,
logo,
image_page as imagePage
from zdy_scenic
where del_flag = '0'
order by id desc
</select>
<select id = "selectZdyScenicExpandList" resultMap = "ZdyScenicResult">
SELECT id
from zdy_scenic
where del_flag = '0'
order by id desc
</select>
<select id = "selectZdyScenicNameList" parameterType = "com.zhwl.common.core.domain.ZdyScenic" resultMap = "ZdyScenicResult">
SELECT a.id,
a.scenic_name
from zdy_scenic a
LEFT JOIN sys_dept d ON d.dept_id = a.dept_id
where a.del_flag = '0'
${params.dataScope}
order by a.id desc
</select>
<select id = "selectZdyScenicByIds" resultMap = "ZdyScenicResult" parameterType = "String">
SELECT a.id,
a.dept_id,
a.scenic_name,
a.address,
a.coordinate,
a.scenic_level,
a.adjust,
a.official_phone,
a.image,
a.reachinfo,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
a.del_flag,
a.audio_guide_url,
a.image_page,
a.area_city,
a.logo,
a.recommend,
a.text_type,
a.complaint_phone,
a.flag,
a.pft_id
FROM zdy_scenic a
WHERE a.del_flag = '0' and a.id IN
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
group by a.id
order by a.id desc
</select>
<update id = "updateZdyScenicByDeptId" parameterType = "ZdyScenic">
update zdy_scenic
<trim prefix = "SET" suffixOverrides = ",">
<if test = "scenicName != null and scenicName != ''">scenic_name = #{scenicName},
</if>
<if test = "address != null">address = #{address},
</if>
<if test = "coordinate != null">coordinate = #{coordinate},
</if>
<if test = "scenicLevel != null">scenic_level = #{scenicLevel},
</if>
<if test = "adjust != null">adjust = #{adjust},
</if>
<if test = "officialPhone != null">official_phone = #{officialPhone},
</if>
<if test = "image != null">image = #{image},
</if>
<if test = "blurb != null">blurb = #{blurb},
</if>
<if test = "reachinfo != null">reachinfo = #{reachinfo},
</if>
<if test = "updateBy != null">update_by = #{updateBy},
</if>
update_time = sysdate(),
</trim>
where dept_id = #{deptId}
</update>
<select id = "selectZdyScenicSelectList" resultType = "com.zhwl.scenic.domain.vo.ZdyScenicVo">
SELECT id,
scenic_name as scenicName
FROM zdy_scenic
where del_flag = '0'
order by update_time desc, sort
</select>
<select id = "selectZdyScenicSpotList" parameterType = "ZdyScenic" resultMap = "ZdyScenicZdyScenicTicketResult">
SELECT a.id, a.scenic_name, b.id AS sub_id, b.NAME AS sub_name, b.scenic_id AS sub_scenic_id FROM zdy_scenic a
LEFT JOIN zdy_ticket b ON b.scenic_id = a.id
<where>
${params.dataScope}
</where>
ORDER BY a.update_time DESC, a.sort
</select>
<select id = "selectZdyScenicInfoByAdminId" resultType = "Long" parameterType = "Long">
SELECT a.id
FROM zdy_scenic a
LEFT JOIN sys_user u ON u.dept_id = a.dept_id
WHERE a.del_flag = '0'
AND u.user_id = #{userId}
limit 1
</select>
<select id = "selectZdyScenicByAdminId" resultMap="ZdyScenicResult" parameterType = "long">
SELECT a.id,a.scenic_name,a.dept_id
FROM zdy_scenic a
LEFT JOIN sys_user u ON u.dept_id = a.dept_id
WHERE a.del_flag = '0'
AND u.user_id = #{userId}
limit 1
</select>
<select id = "selectZdyScenicNameById" parameterType = "Long"
resultType = "com.zhwl.scenic.domain.vo.ZdyScenicConfigVo">
select id,
scenic_name as scenicName,
coordinate,
area_city as areaCity,
official_phone as officialPhone,
complaint_phone as complaintPhone,
adjust,
dept_id as deptId
FROM zdy_scenic
where id = #{id}
</select>
<select id = "countByScenicName" resultType = "int">
select count(1)
from zdy_scenic
where del_flag = '0'
and scenic_name = #{scenicName}
</select>
<select id = "listScenicNamesAll" resultType= "com.zhwl.common.core.domain.ZdyScenic">
SELECT a.id,
a.scenic_name as scenicName
from zdy_scenic a
where a.del_flag = '0'
order by a.id desc
</select>
<select id="selectbaseList" resultType="map">
SELECT
a.id,
a.scenic_name as scenicName,
d.dict_label as scenicLevel,
a.adjust,
a.official_phone,
a.complaint_phone,
a.address,
a.coordinate,
a.image_page as image,
a.blurb,
GROUP_CONCAT( t.NAME ) AS tags
FROM
zdy_scenic a
left JOIN zdy_scenic_tags t ON a.id = t.scenic_id
LEFT JOIN sys_dict_data d ON d.dict_type = 'scenic_level' AND d.dict_value = a.scenic_level
WHERE
a.del_flag = '0'
GROUP BY
a.id, a.scenic_name, d.dict_label, a.adjust, a.official_phone,
a.complaint_phone, a.address, a.coordinate, a.image, a.blurb
</select>
<select id="selectByName" resultMap = "ZdyScenicResult">
SELECT *
FROM zdy_scenic
where del_flag='0' and scenic_name = #{name}
</select>
<select id="selectBypftId" resultMap = "ZdyScenicResult">
SELECT *
FROM zdy_scenic
where del_flag='0' and pft_id like concat('%',#{pftId},'%')
</select>
<select id="selectScenicCount" resultType="java.lang.Integer">
select count(1) from zdy_scenic where del_flag='0'
</select>
</mapper>