CameraUserMapper.xml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.zcxk.facilities.dao.CameraUserMapper">
  4. <!-- 结果集 -->
  5. <resultMap type="com.zcxk.facilities.entity.CameraUser" id="CameraUserMap">
  6. <result property="id" column="id" jdbcType="INTEGER"/>
  7. <result property="userId" column="user_id" jdbcType="INTEGER"/>
  8. <result property="cameraId" column="camera_id" jdbcType="INTEGER"/>
  9. <result property="dateCreate" column="date_create" jdbcType="TIMESTAMP"/>
  10. <result property="dateUpdate" column="date_update" jdbcType="TIMESTAMP"/>
  11. <result property="createBy" column="create_by" jdbcType="VARCHAR"/>
  12. <result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
  13. <result property="status" column="status" jdbcType="INTEGER"/>
  14. <result property="siteId" column="site_id" jdbcType="INTEGER"/>
  15. </resultMap>
  16. <!-- 基本字段 -->
  17. <sql id="Base_Column_List">
  18. id, user_id, camera_id, date_create, date_update, create_by, update_by, status, site_id </sql>
  19. <!-- 查询单个 -->
  20. <select id="selectById" resultMap="CameraUserMap">
  21. select
  22. <include refid="Base_Column_List"/>
  23. from sc_camera_user
  24. where id = #{id}
  25. </select>
  26. <!-- 查询全部 -->
  27. <select id="selectAll" resultMap="CameraUserMap">
  28. select
  29. <include refid="Base_Column_List"/>
  30. from sc_camera_user
  31. </select>
  32. <!--通过实体作为筛选条件查询-->
  33. <select id="selectList" resultType="com.zcxk.facilities.entity.CameraUser">
  34. select
  35. a.id,b.channel_no,
  36. a.camera_id,c.monitor_point_name,b.monitor_point_id,b.pic_url,
  37. IFNULL(b.date_update, b.date_create) date_update,d.monitor_scene_name
  38. from sc_camera_user a join sc_camera b on a.camera_id=b.id join sc_monitor_point c
  39. on b.monitor_point_id=c.id join sc_monitor_scene d on b.monitor_scene_id=d.id
  40. <where>
  41. a.status=1 and b.status=1 and c.status=1
  42. <if test="id != null">
  43. and id = #{id}
  44. </if>
  45. <if test="userId != null">
  46. and user_id = #{userId}
  47. </if>
  48. <if test="cameraId != null">
  49. and camera_id = #{cameraId}
  50. </if>
  51. <if test="dateCreate != null">
  52. and date_create = #{dateCreate}
  53. </if>
  54. <if test="dateUpdate != null">
  55. and date_update = #{dateUpdate}
  56. </if>
  57. <if test="createBy != null and createBy != ''">
  58. and create_by = #{createBy}
  59. </if>
  60. <if test="updateBy != null and updateBy != ''">
  61. and update_by = #{updateBy}
  62. </if>
  63. <if test="status != null">
  64. and status = #{status}
  65. </if>
  66. <if test="siteId != null">
  67. and site_id = #{siteId}
  68. </if>
  69. </where>
  70. </select>
  71. <!-- 新增所有列 -->
  72. <insert id="insert" keyProperty="id" useGeneratedKeys="true">
  73. insert into sc_camera_user(id, user_id, camera_id, date_create, date_update, create_by, update_by, status,
  74. site_id)
  75. values (#{id}, #{userId}, #{cameraId}, #{dateCreate}, #{dateUpdate}, #{createBy}, #{updateBy}, #{status},
  76. #{siteId})
  77. </insert>
  78. <!-- 批量新增 -->
  79. <insert id="batchInsert">
  80. insert into sc_camera_user(id, user_id, camera_id, date_create, date_update, create_by, update_by, status,
  81. site_id)
  82. values
  83. <foreach collection="cameraUsers" item="item" index="index" separator=",">
  84. (
  85. #{item.id}, #{item.userId}, #{item.cameraId}, #{item.dateCreate}, #{item.dateUpdate}, #{item.createBy},
  86. #{item.updateBy}, #{item.status}, #{item.siteId} )
  87. </foreach>
  88. </insert>
  89. <!-- 通过主键修改数据 -->
  90. <update id="update">
  91. update sc_camera_user
  92. <set>
  93. <if test="userId != null">
  94. user_id = #{userId},
  95. </if>
  96. <if test="cameraId != null">
  97. camera_id = #{cameraId},
  98. </if>
  99. <if test="dateCreate != null">
  100. date_create = #{dateCreate},
  101. </if>
  102. <if test="dateUpdate != null">
  103. date_update = #{dateUpdate},
  104. </if>
  105. <if test="createBy != null and createBy != ''">
  106. create_by = #{createBy},
  107. </if>
  108. <if test="updateBy != null and updateBy != ''">
  109. update_by = #{updateBy},
  110. </if>
  111. <if test="status != null">
  112. status = #{status},
  113. </if>
  114. <if test="siteId != null">
  115. site_id = #{siteId},
  116. </if>
  117. </set>
  118. where id = #{id}
  119. </update>
  120. <!--通过主键删除-->
  121. <delete id="deleteById">
  122. delete
  123. from sc_camera_user
  124. where id = #{id}
  125. </delete>
  126. <!-- 总数 -->
  127. <select id="count" resultType="int">
  128. select count(*)
  129. from sc_camera_user
  130. </select>
  131. </mapper>