关联关系修改

This commit is contained in:
2024-12-30 14:37:27 +08:00
parent fd7511ad55
commit aa7d1fab52
17 changed files with 154 additions and 71 deletions

View File

@@ -6,14 +6,14 @@
values (#{id}, #{scenicId}, #{deviceId}, #{url}, #{videoUrl}, #{type}, #{faceSampleId}, #{posJson})
</insert>
<insert id="addRelation">
replace member_source(member_id, source_id, is_buy, type)
values (#{memberId}, #{sourceId}, #{isBuy}, #{type})
replace member_source(member_id, source_id, is_buy, type, order_id)
values (#{memberId}, #{sourceId}, #{isBuy}, #{type}, #{orderId})
</insert>
<insert id="addRelations">
replace member_source(member_id, source_id, is_buy, type)
replace member_source(member_id, source_id, is_buy, type, order_id)
values
<foreach collection="list" item="item" separator=",">
(#{item.memberId}, #{item.sourceId}, #{item.isBuy}, #{item.type})
(#{item.memberId}, #{item.sourceId}, #{item.isBuy}, #{item.type}, #{orderId})
</foreach>
</insert>
<update id="update">
@@ -30,12 +30,20 @@
</set>
where id = #{id}
</update>
<update id="updateRelation">
update member_source
<set>
<if test="isBuy!=null">is_buy = #{isBuy}, </if>
<if test="orderId!=null">order_id = #{orderId}, </if>
</set>
where member_id = #{memberId} and source_id = #{sourceId} and type = #{type}
</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, so.video_url, so.`type`, so.face_sample_id
select so.id, scenic_id, device_id, url, so.create_time, so.update_time,sc.`name` as scenicName, so.video_url, so.`type`, so.face_sample_id
from source so
left join scenic sc on sc.id = so.scenic_id
<where>
@@ -104,17 +112,27 @@
limit 1
</select>
<select id="listUser" resultType="com.ycwl.basic.model.pc.source.resp.SourceRespVO">
select so.id, scenic_id, device_id, url, so.create_time, so.update_time,sc.`name` as scenicName
select so.id, ms.scenic_id, device_id, url, so.create_time, so.update_time,sc.`name` as scenicName
from member_source ms
left join source so on ms.source_id = so.id
left join scenic sc on sc.id = so.scenic_id
where
ms.member_id = #{memberId}
<if test="scenicId!= null">and so.scenic_id = #{scenicId} </if>
<if test="deviceId!= null">and so.device_id = #{deviceId} </if>
<if test="scenicId!= null">and ms.scenic_id = #{scenicId} </if>
<if test="isBuy!=null">and ms.is_buy = #{isBuy}</if>
<if test="type!=null">and ms.type = #{type} </if>
<if test="faceId!=null">and FIND_IN_SET(so.face_sample_id, (select face.match_sample_ids from face where id = #{faceId})) </if>
order by so.create_time desc
</select>
<select id="queryByRelation" resultType="com.ycwl.basic.model.pc.source.resp.SourceRespVO">
select so.id, ms.scenic_id, ms.type, so.url, so.create_time, so.update_time,sc.`name` as scenicName
from member_source ms
left join source so on ms.source_id = so.id
left join scenic sc on sc.id = so.scenic_id
where
ms.member_id = #{memberId}
<if test="type!=null">and ms.type = #{type} </if>
<if test="scenicId!= null">and ms.scenic_id = #{scenicId} </if>
<if test="isBuy!=null">and ms.is_buy = #{isBuy}</if>
</select>
</mapper>