123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- <?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.zcxk.facilities.dao.CameraUserMapper">
- <!-- 结果集 -->
- <resultMap type="com.zcxk.facilities.entity.CameraUser" id="CameraUserMap">
- <result property="id" column="id" jdbcType="INTEGER"/>
- <result property="userId" column="user_id" jdbcType="INTEGER"/>
- <result property="cameraId" column="camera_id" jdbcType="INTEGER"/>
- <result property="dateCreate" column="date_create" jdbcType="TIMESTAMP"/>
- <result property="dateUpdate" column="date_update" jdbcType="TIMESTAMP"/>
- <result property="createBy" column="create_by" jdbcType="VARCHAR"/>
- <result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
- <result property="status" column="status" jdbcType="INTEGER"/>
- <result property="siteId" column="site_id" jdbcType="INTEGER"/>
- </resultMap>
- <!-- 基本字段 -->
- <sql id="Base_Column_List">
- id, user_id, camera_id, date_create, date_update, create_by, update_by, status, site_id </sql>
- <!-- 查询单个 -->
- <select id="selectById" resultMap="CameraUserMap">
- select
- <include refid="Base_Column_List"/>
- from sc_camera_user
- where id = #{id}
- </select>
- <!-- 查询全部 -->
- <select id="selectAll" resultMap="CameraUserMap">
- select
- <include refid="Base_Column_List"/>
- from sc_camera_user
- </select>
- <!--通过实体作为筛选条件查询-->
- <select id="selectList" resultType="com.zcxk.facilities.entity.CameraUser">
- select
- a.id,b.channel_no,
- a.camera_id,c.monitor_point_name,b.monitor_point_id,b.pic_url,
- IFNULL(b.date_update, b.date_create) date_update,d.monitor_scene_name
- from sc_camera_user a join sc_camera b on a.camera_id=b.id join sc_monitor_point c
- on b.monitor_point_id=c.id join sc_monitor_scene d on b.monitor_scene_id=d.id
- <where>
- a.status=1 and b.status=1 and c.status=1
- <if test="id != null">
- and id = #{id}
- </if>
- <if test="userId != null">
- and user_id = #{userId}
- </if>
- <if test="cameraId != null">
- and camera_id = #{cameraId}
- </if>
- <if test="dateCreate != null">
- and date_create = #{dateCreate}
- </if>
- <if test="dateUpdate != null">
- and date_update = #{dateUpdate}
- </if>
- <if test="createBy != null and createBy != ''">
- and create_by = #{createBy}
- </if>
- <if test="updateBy != null and updateBy != ''">
- and update_by = #{updateBy}
- </if>
- <if test="status != null">
- and status = #{status}
- </if>
- <if test="siteId != null">
- and site_id = #{siteId}
- </if>
- </where>
- </select>
- <!-- 新增所有列 -->
- <insert id="insert" keyProperty="id" useGeneratedKeys="true">
- insert into sc_camera_user(id, user_id, camera_id, date_create, date_update, create_by, update_by, status,
- site_id)
- values (#{id}, #{userId}, #{cameraId}, #{dateCreate}, #{dateUpdate}, #{createBy}, #{updateBy}, #{status},
- #{siteId})
- </insert>
- <!-- 批量新增 -->
- <insert id="batchInsert">
- insert into sc_camera_user(id, user_id, camera_id, date_create, date_update, create_by, update_by, status,
- site_id)
- values
- <foreach collection="cameraUsers" item="item" index="index" separator=",">
- (
- #{item.id}, #{item.userId}, #{item.cameraId}, #{item.dateCreate}, #{item.dateUpdate}, #{item.createBy},
- #{item.updateBy}, #{item.status}, #{item.siteId} )
- </foreach>
- </insert>
- <!-- 通过主键修改数据 -->
- <update id="update">
- update sc_camera_user
- <set>
- <if test="userId != null">
- user_id = #{userId},
- </if>
- <if test="cameraId != null">
- camera_id = #{cameraId},
- </if>
- <if test="dateCreate != null">
- date_create = #{dateCreate},
- </if>
- <if test="dateUpdate != null">
- date_update = #{dateUpdate},
- </if>
- <if test="createBy != null and createBy != ''">
- create_by = #{createBy},
- </if>
- <if test="updateBy != null and updateBy != ''">
- update_by = #{updateBy},
- </if>
- <if test="status != null">
- status = #{status},
- </if>
- <if test="siteId != null">
- site_id = #{siteId},
- </if>
- </set>
- where id = #{id}
- </update>
- <!--通过主键删除-->
- <delete id="deleteById">
- delete
- from sc_camera_user
- where id = #{id}
- </delete>
- <!-- 总数 -->
- <select id="count" resultType="int">
- select count(*)
- from sc_camera_user
- </select>
- </mapper>
|