wlcb-smart-city-case/src/main/resources/mybatis/mapper/warning/warning-mapper.xml

267 lines
8.1 KiB
XML
Raw Normal View History

2021-11-04 10:52:21 +08:00
<?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="cn.com.tenlion.dao.warning.IWarningDao">
<resultMap id="warningDTO" type="cn.com.tenlion.pojo.dtos.warning.WarningDTO">
<result column="warning_id" property="warningId"/>
<result column="report_id" property="reportId"/>
</resultMap>
<resultMap id="warningBO" type="cn.com.tenlion.pojo.bos.warning.WarningBO">
<result column="warning_id" property="warningId"/>
<result column="report_id" property="reportId"/>
<result column="creator" property="creator"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="modifier" property="modifier"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="is_delete" property="isDelete"/>
</resultMap>
<resultMap id="warningPO" type="cn.com.tenlion.pojo.pos.warning.WarningPO">
<result column="warning_id" property="warningId"/>
<result column="report_id" property="reportId"/>
<result column="creator" property="creator"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="modifier" property="modifier"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="is_delete" property="isDelete"/>
</resultMap>
<!-- 新增案件预警 -->
<insert id="save" parameterType="map">
INSERT INTO case_warning(
warning_id,
report_id,
creator,
gmt_create,
modifier,
gmt_modified,
is_delete
) VALUES(
#{warningId},
#{reportId},
#{creator},
#{gmtCreate},
#{modifier},
#{gmtModified},
#{isDelete}
)
</insert>
<!-- 删除案件预警 -->
<update id="remove" parameterType="map">
UPDATE
case_warning
SET
gmt_modified = #{gmtModified},
modifier = #{modifier},
is_delete = 1
WHERE
warning_id IN
<foreach collection="warningIds" index="index" open="(" separator="," close=")">
#{warningIds[${index}]}
</foreach>
</update>
<!-- 删除案件预警(物理) -->
<update id="delete" parameterType="map">
DELETE FROM
case_warning
WHERE
warning_id IN
<foreach collection="warningIds" index="index" open="(" separator="," close=")">
#{warningIds[${index}]}
</foreach>
</update>
<!-- 修改案件预警 -->
<update id="update" parameterType="map">
UPDATE
case_warning
SET
<if test="reportId != null and reportId != ''">
report_id = #{reportId},
</if>
gmt_modified = #{gmtModified},
modifier = #{modifier},
warning_id = warning_id
WHERE
warning_id = #{warningId}
</update>
<!-- 案件预警详情 -->
<select id="get" parameterType="map" resultMap="warningDTO">
SELECT
t1.report_id,
t1.warning_id
FROM
case_warning t1
WHERE
t1.is_delete = 0
<if test="warningId != null and warningId != ''">
AND
t1.warning_id = #{warningId}
</if>
</select>
<!-- 案件预警详情 -->
<select id="getBO" parameterType="map" resultMap="warningBO">
SELECT
t1.warning_id,
t1.report_id,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
case_warning t1
WHERE
t1.is_delete = 0
<if test="warningId != null and warningId != ''">
AND
t1.warning_id = #{warningId}
</if>
</select>
<!-- 案件预警详情 -->
<select id="getPO" parameterType="map" resultMap="warningPO">
SELECT
t1.warning_id,
t1.report_id,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
case_warning t1
WHERE
t1.is_delete = 0
<if test="warningId != null and warningId != ''">
AND
t1.warning_id = #{warningId}
</if>
</select>
<!-- 案件预警列表 -->
<select id="list" parameterType="map" resultMap="warningDTO">
SELECT
t1.warning_id,
t1.report_id,
1
FROM
case_warning t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t1.id LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="warningIds != null and warningIds.size > 0">
AND
t1.warning_id IN
<foreach collection="warningIds" index="index" open="(" separator="," close=")">
#{warningIds[${index}]}
</foreach>
</if>
</select>
<!-- 案件预警列表 -->
<select id="listBO" parameterType="map" resultMap="warningBO">
SELECT
t1.warning_id,
t1.report_id,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
case_warning t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t1.id LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="warningIds != null and warningIds.size > 0">
AND
t1.warning_id IN
<foreach collection="warningIds" index="index" open="(" separator="," close=")">
#{warningIds[${index}]}
</foreach>
</if>
</select>
<!-- 案件预警列表 -->
<select id="listPO" parameterType="map" resultMap="warningPO">
SELECT
t1.warning_id,
t1.report_id,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
case_warning t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t1.id LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="warningIds != null and warningIds.size > 0">
AND
t1.warning_id IN
<foreach collection="warningIds" index="index" open="(" separator="," close=")">
#{warningIds[${index}]}
</foreach>
</if>
</select>
<!-- 案件预警统计 -->
<select id="count" parameterType="map" resultType="Integer">
SELECT
COUNT(*)
FROM
case_warning t1
WHERE
t1.is_delete = 0
<if test="reportId != null and reportId != ''">
AND t1.report_id = #{reportId}
</if>
</select>
</mapper>