CustomerVideoWatchesMapper.xml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruoyi.mingxue.mapper.CustomerVideoWatchesMapper">
  6. <resultMap type="CustomerVideoWatches" id="CustomerVideoWatchesResult">
  7. <result property="id" column="id" />
  8. <result property="customerCode" column="customerCode" />
  9. <result property="type" column="type" />
  10. <result property="sectionId" column="section_id" />
  11. <result property="duration" column="duration" />
  12. <result property="percent" column="percent" />
  13. <result property="course" column="course" />
  14. <result property="title" column="title" />
  15. <result property="pict" column="pict" />
  16. <result property="comment" column="comment" />
  17. <result property="time" column="time" />
  18. <result property="type" column="type" />
  19. </resultMap>
  20. <sql id="selectCustomerVideoWatchesVo">
  21. select id, customerCode, section_id, duration, percent, course, title, pict, comment, time ,type from b_customer_video_watches
  22. </sql>
  23. <select id="selectCustomerVideoWatchesList" parameterType="CustomerVideoWatches" resultMap="CustomerVideoWatchesResult">
  24. <include refid="selectCustomerVideoWatchesVo"/>
  25. <where>
  26. <if test="customerCode != null and customerCode != ''"> and customerCode = #{customerCode}</if>
  27. <if test="sectionId != null and sectionId != ''"> and section_id = #{sectionId}</if>
  28. <if test="type != null"> and type = #{type}</if>
  29. <if test="duration != null "> and duration = #{duration}</if>
  30. <if test="percent != null "> and percent = #{percent}</if>
  31. <if test="course != null and course != ''"> and course = #{course}</if>
  32. <if test="title != null and title != ''"> and title = #{title}</if>
  33. <if test="pict != null and pict != ''"> and pict = #{pict}</if>
  34. <if test="comment != null and comment != ''"> and comment = #{comment}</if>
  35. <if test="time != null "> and time = #{time}</if>
  36. </where>
  37. </select>
  38. <select id="selectCustomerVideoWatchesById" parameterType="Long" resultMap="CustomerVideoWatchesResult">
  39. <include refid="selectCustomerVideoWatchesVo"/>
  40. where id = #{id}
  41. </select>
  42. <insert id="insertCustomerVideoWatches" parameterType="CustomerVideoWatches" useGeneratedKeys="true" keyProperty="id">
  43. insert into b_customer_video_watches
  44. <trim prefix="(" suffix=")" suffixOverrides=",">
  45. <if test="customerCode != null and customerCode != ''">customerCode,</if>
  46. <if test="sectionId != null and sectionId != ''">section_id,</if>
  47. <if test="duration != null">duration,</if>
  48. <if test="percent != null">percent,</if>
  49. <if test="course != null">course,</if>
  50. <if test="title != null">title,</if>
  51. <if test="pict != null">pict,</if>
  52. <if test="comment != null">comment,</if>
  53. <if test="time != null">time,</if>
  54. <if test="type != null">type,</if>
  55. </trim>
  56. <trim prefix="values (" suffix=")" suffixOverrides=",">
  57. <if test="customerCode != null and customerCode != ''">#{customerCode},</if>
  58. <if test="sectionId != null and sectionId != ''">#{sectionId},</if>
  59. <if test="duration != null">#{duration},</if>
  60. <if test="percent != null">#{percent},</if>
  61. <if test="course != null">#{course},</if>
  62. <if test="title != null">#{title},</if>
  63. <if test="pict != null">#{pict},</if>
  64. <if test="comment != null">#{comment},</if>
  65. <if test="time != null">#{time},</if>
  66. <if test="type != null">#{type},</if>
  67. </trim>
  68. </insert>
  69. <update id="updateCustomerVideoWatches" parameterType="CustomerVideoWatches">
  70. update b_customer_video_watches
  71. <trim prefix="SET" suffixOverrides=",">
  72. <if test="customerCode != null and customerCode != ''">customerCode = #{customerCode},</if>
  73. <if test="sectionId != null and sectionId != ''">section_id = #{sectionId},</if>
  74. <if test="duration != null">duration = #{duration},</if>
  75. <if test="percent != null">percent = #{percent},</if>
  76. <if test="course != null">course = #{course},</if>
  77. <if test="title != null">title = #{title},</if>
  78. <if test="pict != null">pict = #{pict},</if>
  79. <if test="comment != null">comment = #{comment},</if>
  80. <if test="time != null">time = #{time},</if>
  81. <if test="type != null">type = #{type},</if>
  82. </trim>
  83. where id = #{id}
  84. </update>
  85. <delete id="deleteCustomerVideoWatchesById" parameterType="Long">
  86. delete from b_customer_video_watches where id = #{id}
  87. </delete>
  88. <delete id="deleteCustomerVideoWatchesByIds" parameterType="String">
  89. delete from b_customer_video_watches where id in
  90. <foreach item="id" collection="array" open="(" separator="," close=")">
  91. #{id}
  92. </foreach>
  93. </delete>
  94. <select id="countVideoWatchCount" parameterType="String" resultType="Integer">
  95. select count(section_id) from b_customer_video_watches
  96. where percent>=90 and customerCode=#{customerCode}
  97. </select>
  98. <select id="countVideoWatchDuration" parameterType="String" resultType="Integer">
  99. select ifnull(sum(duration),0) from b_customer_video_watches
  100. where percent>=90 and customerCode=#{customerCode}
  101. </select>
  102. <select id="countDurationByDate" parameterType="java.util.HashMap" resultMap="CustomerVideoWatchesResult">
  103. select DATE_FORMAT(time, '%Y-%m-%d') day, sum(duration) count from b_customer_video_watches
  104. where customerCode=#{customerCode}
  105. and DATE_FORMAT(time, '%Y-%m-%d') >= #{start}
  106. and #{end} >= DATE_FORMAT(time, '%Y-%m-%d')
  107. group by DATE_FORMAT(time, '%Y-%m-%d')
  108. </select>
  109. <select id="countDurationByDateAndSubject" parameterType="java.util.HashMap" resultMap="CustomerVideoWatchesResult">
  110. select course, sum(duration) count from b_customer_video_watches
  111. where percent>=90 and customerCode=#{customerCode}
  112. and DATE_FORMAT(time, '%Y-%m-%d') >= #{start}
  113. and #{end} >= DATE_FORMAT(time, '%Y-%m-%d')
  114. group by course
  115. </select>
  116. <select id="selectByDate" parameterType="java.util.HashMap" resultMap="CustomerVideoWatchesResult">
  117. select * from b_customer_video_watches
  118. where percent>=90 and customerCode=#{customerCode}
  119. and DATE_FORMAT(time, '%Y-%m-%d') >= #{start}
  120. and #{end} >= DATE_FORMAT(time, '%Y-%m-%d')
  121. order by time desc
  122. </select>
  123. <select id="selectTodayBySection" parameterType="java.util.HashMap" resultMap="CustomerVideoWatchesResult">
  124. select * from b_customer_video_watches
  125. where customerCode=#{customerCode}
  126. and to_days(time) = to_days(now())
  127. and section_id = #{sectionId}
  128. and type = #{type}
  129. </select>
  130. </mapper>