FsStatisPeriodWatchMapper.xml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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.fs.statis.mapper.FsStatisPeriodWatchMapper">
  4. <!-- 通用查询结果映射 -->
  5. <resultMap id="BaseResultMap" type="com.fs.statis.domain.FsStatisPeriodWatch">
  6. <id column="id" property="id" jdbcType="INTEGER" />
  7. <result column="period_id" property="periodId" jdbcType="INTEGER" />
  8. <result column="period_num" property="periodNum" jdbcType="INTEGER" />
  9. <result column="not_reg_num" property="notRegNum" jdbcType="INTEGER" />
  10. <result column="registered_num" property="registeredNum" jdbcType="INTEGER" />
  11. <result column="reg_rate" property="regRate" jdbcType="DECIMAL" />
  12. <result column="watch_completed_rate" property="watchCompletedRate" jdbcType="DECIMAL" />
  13. <result column="offline_total" property="offlineTotal" jdbcType="INTEGER" />
  14. <result column="offline_not_reg_num" property="offlineNotRegNum" jdbcType="INTEGER" />
  15. <result column="offline_not_watch_num" property="offlineNotWatchNum" jdbcType="INTEGER" />
  16. <result column="online_total" property="onlineTotal" jdbcType="INTEGER" />
  17. <result column="online_rate" property="onlineRate" jdbcType="DECIMAL" />
  18. <result column="online_watch_completed_rate" property="onlineWatchCompletedRate" jdbcType="DECIMAL" />
  19. <result column="online_watch_not_completed" property="onlineWatchNotCompleted" jdbcType="INTEGER" />
  20. <result column="online_watch_completed" property="onlineWatchCompleted" jdbcType="INTEGER" />
  21. <result column="data_date" property="dataDate" jdbcType="DATE" />
  22. </resultMap>
  23. <!-- 通用查询结果列 -->
  24. <sql id="Base_Column_List">
  25. id, period_id, period_num, not_reg_num, registered_num, reg_rate,
  26. watch_completed_rate, offline_total, offline_not_reg_num, offline_not_watch_num,
  27. online_total, online_rate, online_watch_completed_rate, online_watch_not_completed,
  28. online_watch_completed, data_date
  29. </sql>
  30. <!-- 根据主键查询数据 -->
  31. <select id="selectById" resultMap="BaseResultMap" parameterType="java.lang.Integer">
  32. SELECT
  33. <include refid="Base_Column_List" />
  34. FROM fs_statis_period_watch
  35. WHERE id = #{id,jdbcType=INTEGER}
  36. </select>
  37. <!-- 新增数据 -->
  38. <insert id="insert" parameterType="com.fs.statis.domain.FsStatisPeriodWatch">
  39. INSERT INTO fs_statis_period_watch (
  40. id, period_id, period_num, not_reg_num, registered_num, reg_rate,
  41. watch_completed_rate, offline_total, offline_not_reg_num, offline_not_watch_num,
  42. online_total, online_rate, online_watch_completed_rate, online_watch_not_completed,
  43. online_watch_completed, data_date
  44. )
  45. VALUES (
  46. #{id,jdbcType=INTEGER}, #{periodId,jdbcType=INTEGER}, #{periodNum,jdbcType=INTEGER},
  47. #{notRegNum,jdbcType=INTEGER}, #{registeredNum,jdbcType=INTEGER}, #{regRate,jdbcType=DECIMAL},
  48. #{watchCompletedRate,jdbcType=DECIMAL}, #{offlineTotal,jdbcType=INTEGER},
  49. #{offlineNotRegNum,jdbcType=INTEGER}, #{offlineNotWatchNum,jdbcType=INTEGER},
  50. #{onlineTotal,jdbcType=INTEGER}, #{onlineRate,jdbcType=DECIMAL},
  51. #{onlineWatchCompletedRate,jdbcType=DECIMAL}, #{onlineWatchNotCompleted,jdbcType=INTEGER},
  52. #{onlineWatchCompleted,jdbcType=INTEGER}, #{dataDate,jdbcType=DATE}
  53. )
  54. </insert>
  55. <!-- 根据主键更新数据 (动态SQL,只更新非null字段) -->
  56. <update id="updateById" parameterType="com.fs.statis.domain.FsStatisPeriodWatch">
  57. UPDATE fs_statis_period_watch
  58. <set>
  59. <if test="periodId != null">
  60. period_id = #{periodId,jdbcType=INTEGER},
  61. </if>
  62. <if test="periodNum != null">
  63. period_num = #{periodNum,jdbcType=INTEGER},
  64. </if>
  65. <if test="notRegNum != null">
  66. not_reg_num = #{notRegNum,jdbcType=INTEGER},
  67. </if>
  68. <if test="registeredNum != null">
  69. registered_num = #{registeredNum,jdbcType=INTEGER},
  70. </if>
  71. <if test="regRate != null">
  72. reg_rate = #{regRate,jdbcType=DECIMAL},
  73. </if>
  74. <if test="watchCompletedRate != null">
  75. watch_completed_rate = #{watchCompletedRate,jdbcType=DECIMAL},
  76. </if>
  77. <if test="offlineTotal != null">
  78. offline_total = #{offlineTotal,jdbcType=INTEGER},
  79. </if>
  80. <if test="offlineNotRegNum != null">
  81. offline_not_reg_num = #{offlineNotRegNum,jdbcType=INTEGER},
  82. </if>
  83. <if test="offlineNotWatchNum != null">
  84. offline_not_watch_num = #{offlineNotWatchNum,jdbcType=INTEGER},
  85. </if>
  86. <if test="onlineTotal != null">
  87. online_total = #{onlineTotal,jdbcType=INTEGER},
  88. </if>
  89. <if test="onlineRate != null">
  90. online_rate = #{onlineRate,jdbcType=DECIMAL},
  91. </if>
  92. <if test="onlineWatchCompletedRate != null">
  93. online_watch_completed_rate = #{onlineWatchCompletedRate,jdbcType=DECIMAL},
  94. </if>
  95. <if test="onlineWatchNotCompleted != null">
  96. online_watch_not_completed = #{onlineWatchNotCompleted,jdbcType=INTEGER},
  97. </if>
  98. <if test="onlineWatchCompleted != null">
  99. online_watch_completed = #{onlineWatchCompleted,jdbcType=INTEGER},
  100. </if>
  101. <if test="dataDate != null">
  102. data_date = #{dataDate,jdbcType=DATE},
  103. </if>
  104. </set>
  105. WHERE id = #{id,jdbcType=INTEGER}
  106. </update>
  107. <!-- 根据主键删除数据 -->
  108. <delete id="deleteById" parameterType="java.lang.Integer">
  109. DELETE FROM fs_statis_period_watch
  110. WHERE id = #{id,jdbcType=INTEGER}
  111. </delete>
  112. <!-- 查询所有数据 -->
  113. <select id="selectAll" resultMap="BaseResultMap">
  114. SELECT
  115. <include refid="Base_Column_List" />
  116. FROM fs_statis_period_watch
  117. </select>
  118. <select id="queryList" resultType="com.fs.statis.domain.FsStatisPeriodWatch">
  119. select * from fs_statis_period_watch
  120. <where>
  121. <if test="userIds != null and userIds.length > 0">
  122. AND company_user_id IN
  123. <foreach collection="userIds" open="(" close=")" separator="," item="item">
  124. ${item}
  125. </foreach>
  126. </if>
  127. <if test="periodList != null and periodList.length > 0">
  128. AND period_id IN
  129. <foreach collection="periodList" open="(" close=")" separator="," item="item">
  130. ${item}
  131. </foreach>
  132. </if>
  133. <if test="startDate != null and endDate != null">
  134. AND data_date BETWEEN #{startDate} AND #{endDate}
  135. </if>
  136. </where>
  137. </select>
  138. </mapper>