Files
FrameTour-BE/src/main/resources/mapper/pc/SourceMapper.xml
2024-12-05 17:05:59 +08:00

57 lines
2.6 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.ycwl.basic.mapper.pc.SourceMapper">
<insert id="add">
insert into source(id, scenic_id, device_id, member_id, url) values (#{id}, #{scenicId}, #{deviceId}, #{memberId}, #{url})
</insert>
<update id="update">
update source
<set>
<if test="scenicId!= null">scenic_id = #{scenicId}, </if>
<if test="deviceId!= null">device_id = #{deviceId}, </if>
<if test="memberId!= null">member_id = #{memberId}, </if>
<if test="url!= null">url = #{url}, </if>
</set>
where id = #{id}
</update>
<delete id="deleteById">
delete from source where id = #{id}
</delete>
<select id="list" resultType="com.ycwl.basic.model.pc.source.resp.SourceRespVO">
select so.id, scenic_id, device_id, member_id, url, so.create_time, so.update_time,sc.`name` as scenicName
from source so
left join scenic sc on sc.id = so.scenic_id
<where>
<if test="scenicId!= null">and scenic_id = #{scenicId} </if>
<if test="deviceId!= null">and device_id = #{deviceId} </if>
<if test="memberId!= null">and member_id = #{memberId} </if>
<if test="url!= null">and url = #{url} </if>
<if test="isBuy!=null">
and is_buy = #{isBuy}
</if>
<if test="type!=null">and so.type = #{type} </if>
<if test="startTime!= null">and so.create_time &gt;= #{startTime} </if>
<if test="endTime!= null">and so.create_time &lt;= #{endTime} </if>
</where>
</select>
<select id="getById" resultType="com.ycwl.basic.model.pc.source.resp.SourceRespVO">
select so.id, scenic_id, device_id, member_id, url, so.create_time, so.update_time,sc.`name` as scenicName
from source so
left join scenic sc on sc.id = so.scenic_id
where so.id = #{id}
</select>
<select id="listGroupByType" resultType="com.ycwl.basic.model.pc.source.resp.SourceRespVO">
select so.id, scenic_id,sc.name scenicName, sc.longitude ,sc.latitude,so.type
from source so
left join scenic sc on sc.id = so.scenic_id
<where>
<if test="scenicId!= null">and scenic_id = #{scenicId} </if>
<if test="memberId!= null">and member_id = #{memberId} </if>
<if test="isBuy!=null">
and is_buy = #{isBuy}
</if>
</where>
group by so.type
</select>
</mapper>