| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- <?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.fs.watch.mapper.WatchAlarmDataMapper">
- <resultMap id="BaseResultMap" type="com.fs.watch.domain.WatchAlarmData">
- <result property="id" column="id" jdbcType="OTHER" typeHandler="com.fs.watch.handler.UUIDTypeHandler"/>
- <result property="deviceId" column="device_id" jdbcType="VARCHAR"/>
- <result property="title" column="title" jdbcType="VARCHAR"/>
- <result property="description" column="description" jdbcType="VARCHAR"/>
- <result property="dateTime" column="date_time" jdbcType="TIMESTAMP"/>
- <result property="type" column="type" jdbcType="VARCHAR"/>
- <result property="extra" column="extra" jdbcType="VARCHAR"/>
- <result property="location" column="location" jdbcType="VARCHAR"/>
- <result property="status" column="status" jdbcType="TINYINT"/>
- <result property="appStatus" column="app_status" jdbcType="TINYINT"/>
- <result property="isDel" column="is_del" jdbcType="TINYINT"/>
- </resultMap>
- <sql id="Base_Column_List">
- id, device_id, title, description, date_time, type, extra, location, status,app_status,is_del
- </sql>
- <!-- 单条插入 -->
- <update id="insert" parameterType="com.fs.watch.domain.WatchAlarmData">
- INSERT INTO watch_alarm_data
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="data.id != null">
- id,
- </if>
- <if test="data.deviceId != null">
- device_id,
- </if>
- <if test="data.title != null">
- title,
- </if>
- <if test="data.description != null">
- description,
- </if>
- <if test="data.dateTime != null">
- date_time,
- </if>
- <if test="data.type != null">
- type,
- </if>
- <if test="data.extra != null">
- extra,
- </if>
- <if test="data.location != null">
- location,
- </if>
- </trim>
- <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
- <if test="data.id != null">
- #{data.id},
- </if>
- <if test="data.deviceId != null">
- #{data.deviceId},
- </if>
- <if test="data.title != null">
- #{data.title},
- </if>
- <if test="data.description != null">
- #{data.description},
- </if>
- <if test="data.dateTime != null">
- #{data.dateTime},
- </if>
- <if test="data.type != null">
- #{data.type},
- </if>
- <if test="data.extra != null">
- #{data.extra},
- </if>
- <if test="data.location != null">
- #{data.location},
- </if>
- </trim>
- </update>
- <!-- 批量插入 -->
- <update id="batchInsertData" parameterType="java.util.List">
- INSERT INTO watch_alarm_data (device_id, title, description, date_time, type, extra, location,status,app_status,is_del)
- VALUES
- <foreach collection="list" item="item" index="index" separator=",">
- (
- #{item.deviceId},
- #{item.title},
- #{item.description},
- #{item.dateTime},
- #{item.type},
- #{item.extra},
- #{item.location},
- #{item.status},
- #{item.appStatus},
- #{item.isDel}
- )
- </foreach>
- </update>
- <!-- 根据状态查询 -->
- <select id="queryByStatus" resultMap="BaseResultMap">
- SELECT <include refid="Base_Column_List"/>
- FROM watch.watch_alarm_data WHERE is_del = 0
- <if test="status != null">
- and status = #{status}
- </if>
- ORDER BY date_time DESC
- </select>
- <!-- <update id="setAppStatusById">-->
- <!-- update watch_alarm_data set app_status = 1 WHERE id IN-->
- <!-- <foreach collection="ids" item="id" open="(" separator="," close=")">-->
- <!-- #{id}-->
- <!-- </foreach>-->
- <!-- </update>-->
- <update id="setAppStatusById">
- ALTER TABLE watch.watch_alarm_data UPDATE app_status = 1 WHERE id IN
- <foreach collection="ids" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </update>
- <update id="setIsDel">
- ALTER TABLE watch.watch_alarm_data UPDATE is_del = 1 WHERE id IN
- <foreach collection="ids" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </update>
- <update id="deleteByDeviceId">
- ALTER TABLE watch.watch_alarm_data UPDATE is_del = 1
- WHERE device_id
- like #{deviceId}
- </update>
- <!-- 根据ID批量更新状态 -->
- <update id="setStatusById" parameterType="java.util.List">
- ALTER TABLE watch.watch_alarm_data UPDATE status = 1 WHERE id IN
- <foreach collection="ids" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </update>
- <update id="setAppStatusByDeviceId">
- ALTER TABLE watch.watch_alarm_data UPDATE app_status = 1
- WHERE device_id
- like #{deviceId}
- </update>
- <update id="setLocation">
- ALTER TABLE watch.watch_alarm_data UPDATE location = #{data.location}
- WHERE id = #{data.id}
- </update>
- <!-- 分页查询 -->
- <select id="queryPageByStatus" resultMap="BaseResultMap">
- SELECT <include refid="Base_Column_List"/>
- FROM watch.watch_alarm_data where is_del = 0
- <if test="status != null">
- and status = #{status}
- </if>
- <if test="appStatus != null">
- and app_status = #{appStatus}
- </if>
- <if test="deviceId != null and deviceId!=''">
- and device_id like concat('%',#{deviceId},'%')
- </if>
- ORDER BY date_time DESC
- <!-- 数据范围过滤 -->
- ${params.dataScope}
- </select>
- <select id="queryByStatusAndDeviceid" resultMap="BaseResultMap">
- SELECT <include refid="Base_Column_List"/>
- FROM watch.watch_alarm_data where is_del = 0
- <if test="status != null ">
- and status = #{status}
- </if>
- <if test="appStatus != null ">
- and app_status = #{appStatus}
- </if>
- <if test="deviceId != null">
- and device_id like concat('%',#{deviceId},'%')
- </if>
- ORDER BY date_time DESC
- </select>
- <select id="getUnreadNum" resultType="java.lang.Integer">
- SELECT COUNT(1) FROM watch.watch_alarm_data WHERE app_status = 0 and is_del = 0
- <if test="deviceId != null and deviceId !=''">
- and device_id like concat('%',#{deviceId},'%')
- </if>
- </select>
- </mapper>
|