FsCourseAnswerLogsMapper.xml 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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.fs.course.mapper.FsCourseAnswerLogsMapper">
  6. <resultMap type="FsCourseAnswerLogs" id="FsCourseAnswerLogsResult">
  7. <result property="logId" column="log_id" />
  8. <result property="userId" column="user_id" />
  9. <result property="videoId" column="video_id" />
  10. <result property="isRight" column="is_right" />
  11. <result property="createTime" column="create_time" />
  12. <result property="companyId" column="company_id" />
  13. <result property="companyUserId" column="company_user_id" />
  14. <result property="qwUserId" column="qw_user_id" />
  15. <result property="courseId" column="course_id" />
  16. <result property="answer" column="answer" />
  17. <result property="questionId" column="question_id" />
  18. <result property="questionJson" column="question_json" />
  19. <result property="periodId" column="period_id" />
  20. </resultMap>
  21. <sql id="selectFsCourseAnswerLogsVo">
  22. select * from fs_course_answer_logs
  23. </sql>
  24. <select id="selectFsCourseAnswerLogsList" parameterType="FsCourseAnswerLogs" resultMap="FsCourseAnswerLogsResult">
  25. <include refid="selectFsCourseAnswerLogsVo"/>
  26. <where>
  27. <if test="userId != null "> and user_id = #{userId}</if>
  28. <if test="videoId != null "> and video_id = #{videoId}</if>
  29. <if test="isRight != null "> and is_right = #{isRight}</if>
  30. <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
  31. <if test="companyId != null "> and company_id = #{companyId}</if>
  32. <if test="qwUserId != null "> and qw_user_id = #{qwUserId}</if>
  33. </where>
  34. </select>
  35. <select id="selectFsCourseAnswerLogsByLogId" parameterType="Long" resultMap="FsCourseAnswerLogsResult">
  36. <include refid="selectFsCourseAnswerLogsVo"/>
  37. where log_id = #{logId}
  38. </select>
  39. <insert id="insertFsCourseAnswerLogs" parameterType="FsCourseAnswerLogs" useGeneratedKeys="true" keyProperty="logId">
  40. insert into fs_course_answer_logs
  41. <trim prefix="(" suffix=")" suffixOverrides=",">
  42. <if test="userId != null">user_id,</if>
  43. <if test="videoId != null">video_id,</if>
  44. <if test="isRight != null">is_right,</if>
  45. <if test="createTime != null">create_time,</if>
  46. <if test="companyId != null">company_id,</if>
  47. <if test="companyUserId != null">company_user_id,</if>
  48. <if test="qwUserId != null">qw_user_id,</if>
  49. <if test="courseId != null">course_id,</if>
  50. <if test="questionJson != null">question_json,</if>
  51. <if test="watchLogId != null">watch_log_id,</if>
  52. <if test="periodId != null">period_id,</if>
  53. </trim>
  54. <trim prefix="values (" suffix=")" suffixOverrides=",">
  55. <if test="userId != null">#{userId},</if>
  56. <if test="videoId != null">#{videoId},</if>
  57. <if test="isRight != null">#{isRight},</if>
  58. <if test="createTime != null">#{createTime},</if>
  59. <if test="companyId != null">#{companyId},</if>
  60. <if test="companyUserId != null">#{companyUserId},</if>
  61. <if test="qwUserId != null">#{qwUserId},</if>
  62. <if test="courseId != null">#{courseId},</if>
  63. <if test="questionJson != null">#{questionJson},</if>
  64. <if test="watchLogId != null">#{watchLogId},</if>
  65. <if test="periodId != null">#{periodId},</if>
  66. </trim>
  67. </insert>
  68. <update id="updateFsCourseAnswerLogs" parameterType="FsCourseAnswerLogs">
  69. update fs_course_answer_logs
  70. <trim prefix="SET" suffixOverrides=",">
  71. <if test="userId != null">user_id = #{userId},</if>
  72. <if test="videoId != null">video_id = #{videoId},</if>
  73. <if test="isRight != null">is_right = #{isRight},</if>
  74. <if test="createTime != null">create_time = #{createTime},</if>
  75. <if test="companyId != null">company_id = #{companyId},</if>
  76. <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
  77. <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
  78. <if test="courseId != null">course_id = #{courseId},</if>
  79. <if test="watchLogId != null">watch_log_id = #{watchLogId},</if>
  80. <if test="periodId != null">period_id = #{periodId},</if>
  81. </trim>
  82. where log_id = #{logId}
  83. </update>
  84. <delete id="deleteFsCourseAnswerLogsByLogId" parameterType="Long">
  85. delete from fs_course_answer_logs where log_id = #{logId}
  86. </delete>
  87. <delete id="deleteFsCourseAnswerLogsByLogIds" parameterType="String">
  88. delete from fs_course_answer_logs where log_id in
  89. <foreach item="logId" collection="array" open="(" separator="," close=")">
  90. #{logId}
  91. </foreach>
  92. </delete>
  93. <select id="selectFsCourseAnswerLogsListVONew" resultType="com.fs.course.vo.FsCourseAnswerLogsListVO">
  94. SELECT
  95. cal.*, uc.course_name AS course_name, uc.project AS project
  96. FROM
  97. fs_course_answer_logs cal
  98. INNER JOIN (
  99. SELECT
  100. cal_inner.log_id
  101. FROM
  102. fs_course_answer_logs cal_inner
  103. LEFT JOIN fs_user_course uc_inner ON cal_inner.course_id = uc_inner.course_id
  104. <where>
  105. <if test="courseId != null">
  106. cal_inner.course_id = #{courseId}
  107. </if>
  108. <if test="videoId != null and videoId != '' ">
  109. AND cal_inner.video_id = #{videoId}
  110. </if>
  111. <if test="companyUserId != null">
  112. AND cal_inner.company_user_id = #{companyUserId}
  113. </if>
  114. <if test="companyId != null">
  115. AND cal_inner.company_id = #{companyId}
  116. </if>
  117. <if test="isRight != null">
  118. AND cal_inner.is_right = #{isRight}
  119. </if>
  120. <if test="project != null">
  121. AND uc_inner.project = #{project}
  122. </if>
  123. <if test="sTime != null and eTime != null">
  124. AND cal_inner.create_time BETWEEN #{sTime} AND #{eTime}
  125. </if>
  126. <if test="userIds != null and userIds.size() > 0">
  127. and cal_inner.user_id in
  128. <foreach collection="userIds" open="(" close=")" separator="," item="userId" index="index">
  129. #{userId}
  130. </foreach>
  131. </if>
  132. <if test="watchLogId != null">
  133. AND cal_inner.watch_log_id = #{watchLogId}
  134. </if>
  135. </where>
  136. ORDER BY cal_inner.log_id DESC
  137. LIMIT ${(pageNum-1)*pageSize}, ${pageSize}
  138. ) AS paged_ids ON cal.log_id = paged_ids.log_id
  139. LEFT JOIN fs_user_course uc ON cal.course_id = uc.course_id
  140. ORDER BY
  141. cal.log_id DESC
  142. </select>
  143. <select id="selectFsCourseAnswerLogsListVONewCount" resultType="java.lang.Long">
  144. SELECT
  145. count(1)
  146. FROM
  147. fs_course_answer_logs cal
  148. INNER JOIN (
  149. SELECT
  150. cal_inner.log_id
  151. FROM
  152. fs_course_answer_logs cal_inner
  153. LEFT JOIN fs_user_course uc_inner ON cal_inner.course_id = uc_inner.course_id
  154. <where>
  155. <if test="courseId != null">
  156. cal_inner.course_id = #{courseId}
  157. </if>
  158. <if test="videoId != null and videoId != '' ">
  159. AND cal_inner.video_id = #{videoId}
  160. </if>
  161. <if test="companyUserId != null">
  162. AND cal_inner.company_user_id = #{companyUserId}
  163. </if>
  164. <if test="companyId != null">
  165. AND cal_inner.company_id = #{companyId}
  166. </if>
  167. <if test="isRight != null">
  168. AND cal_inner.is_right = #{isRight}
  169. </if>
  170. <if test="project != null">
  171. AND uc_inner.project = #{project}
  172. </if>
  173. <if test="sTime != null and eTime != null">
  174. AND cal_inner.create_time BETWEEN #{sTime} AND #{eTime}
  175. </if>
  176. <if test="userIds != null and userIds.size() > 0">
  177. and cal_inner.user_id in
  178. <foreach collection="userIds" open="(" close=")" separator="," item="userId" index="index">
  179. #{userId}
  180. </foreach>
  181. </if>
  182. <if test="watchLogId != null">
  183. AND cal_inner.watch_log_id = #{watchLogId}
  184. </if>
  185. </where>
  186. ) AS paged_ids ON cal.log_id = paged_ids.log_id
  187. </select>
  188. </mapper>