FsUserCoursePeriodDaysMapper.xml 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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.FsUserCoursePeriodDaysMapper">
  6. <resultMap type="FsUserCoursePeriodDays" id="FsUserCoursePeriodDaysResult">
  7. <result property="id" column="id" />
  8. <result property="periodId" column="period_id" />
  9. <result property="lesson" column="lesson" />
  10. <result property="startDateTime" column="start_date_time" />
  11. <result property="endDateTime" column="end_date_time" />
  12. <result property="courseId" column="course_id" />
  13. <result property="videoId" column="video_id" />
  14. <result property="money" column="money" />
  15. <result property="status" column="status" />
  16. <result property="createTime" column="create_time" />
  17. <result property="createBy" column="create_by" />
  18. <result property="updateBy" column="update_by" />
  19. <result property="updateTime" column="update_time" />
  20. <result property="remark" column="remark" />
  21. </resultMap>
  22. <sql id="selectFsUserCoursePeriodDaysVo">
  23. select * from fs_user_course_period_days
  24. </sql>
  25. <select id="selectFsUserCoursePeriodDaysList" parameterType="FsUserCoursePeriodDays" resultType="FsUserCoursePeriodDays">
  26. select a.*,b.course_name,c.title videoName from fs_user_course_period_days a
  27. inner join fs_user_course b on a.course_id = b.course_id
  28. inner join fs_user_course_video c on a.video_id = c.video_id
  29. <where>
  30. and a.del_flag ='0'
  31. <if test="periodId != null "> and period_id = #{periodId}</if>
  32. <if test="courseId != null "> and a.course_id = #{courseId}</if>
  33. <if test="videoId != null "> and a.video_id = #{videoId}</if>
  34. <if test="maxDate != null "> and a.day_date &lt;= #{maxDate}</if>
  35. <if test="videoIds != null and videoIds.size > 0">
  36. and a.video_id in
  37. <foreach collection="videoIds" open="(" close=")" separator="," item="videoId">
  38. #{videoId}
  39. </foreach>
  40. </if>
  41. </where>
  42. order by a.day_date
  43. </select>
  44. <select id="selectFsUserCoursePeriodDaysById" parameterType="Long" resultMap="FsUserCoursePeriodDaysResult">
  45. <include refid="selectFsUserCoursePeriodDaysVo"/>
  46. where id = #{id}
  47. </select>
  48. <insert id="insertFsUserCoursePeriodDays" parameterType="FsUserCoursePeriodDays" useGeneratedKeys="true" keyProperty="id">
  49. insert into fs_user_course_period_days
  50. <trim prefix="(" suffix=")" suffixOverrides=",">
  51. <if test="periodId != null">period_id,</if>
  52. <if test="lesson != null">lesson,</if>
  53. <if test="startTime != null">start_time,</if>
  54. <if test="endTime != null">end_time,</if>
  55. <if test="courseId != null">course_id,</if>
  56. <if test="videoId != null">video_id,</if>
  57. <if test="money != null">money,</if>
  58. <if test="status != null">status,</if>
  59. <if test="createTime != null">create_time,</if>
  60. <if test="createBy != null">create_by,</if>
  61. <if test="updateBy != null">update_by,</if>
  62. <if test="updateTime != null">update_time,</if>
  63. <if test="remark != null">remark,</if>
  64. </trim>
  65. <trim prefix="values (" suffix=")" suffixOverrides=",">
  66. <if test="periodId != null">#{periodId},</if>
  67. <if test="lesson != null">#{lesson},</if>
  68. <if test="startTime != null">#{startTime},</if>
  69. <if test="endTime != null">#{endTime},</if>
  70. <if test="courseId != null">#{courseId},</if>
  71. <if test="videoId != null">#{videoId},</if>
  72. <if test="money != null">#{money},</if>
  73. <if test="status != null">#{status},</if>
  74. <if test="createTime != null">#{createTime},</if>
  75. <if test="createBy != null">#{createBy},</if>
  76. <if test="updateBy != null">#{updateBy},</if>
  77. <if test="updateTime != null">#{updateTime},</if>
  78. <if test="remark != null">#{remark},</if>
  79. </trim>
  80. </insert>
  81. <update id="updateFsUserCoursePeriodDays" parameterType="FsUserCoursePeriodDays">
  82. update fs_user_course_period_days
  83. <trim prefix="SET" suffixOverrides=",">
  84. <if test="periodId != null">period_id = #{periodId},</if>
  85. <if test="lesson != null">lesson = #{lesson},</if>
  86. <if test="startDateTime != null">start_date_time = #{startDateTime},</if>
  87. <if test="endDateTime != null">end_date_time = #{endDateTime},</if>
  88. <if test="lastJoinTime != null">last_join_time = #{lastJoinTime},</if>
  89. <if test="dayDate != null">day_date = #{dayDate},</if>
  90. <if test="startTime != null">start_time = #{startTime},</if>
  91. <if test="endTime != null">end_time = #{endTime},</if>
  92. <if test="courseId != null">course_id = #{courseId},</if>
  93. <if test="videoId != null">video_id = #{videoId},</if>
  94. <if test="money != null">money = #{money},</if>
  95. <if test="status != null">status = #{status},</if>
  96. <if test="createTime != null">create_time = #{createTime},</if>
  97. <if test="createBy != null">create_by = #{createBy},</if>
  98. <if test="updateBy != null">update_by = #{updateBy},</if>
  99. <if test="updateTime != null">update_time = #{updateTime},</if>
  100. <if test="remark != null">remark = #{remark},</if>
  101. </trim>
  102. where id = #{id}
  103. </update>
  104. <delete id="deleteFsUserCoursePeriodDaysById" parameterType="Long">
  105. delete from fs_user_course_period_days where id = #{id}
  106. </delete>
  107. <delete id="deleteFsUserCoursePeriodDaysByIds" parameterType="String">
  108. delete from fs_user_course_period_days where id in
  109. <foreach item="id" collection="array" open="(" separator="," close=")">
  110. #{id}
  111. </foreach>
  112. </delete>
  113. <select id="selectCourseVideoList" resultType="FsUserCoursePeriodDays">
  114. select * from fs_user_course_period_days where del_flag ='0' and period_id in
  115. <foreach collection="periodIds" item="item" open="(" separator="," close=")">
  116. #{item}
  117. </foreach>
  118. </select>
  119. <select id="selectPeriodListByMap" resultType="com.fs.his.vo.OptionsVO">
  120. select
  121. ucp.period_id dictValue,
  122. ucp.period_name dictLabel
  123. from fs_user_course_period ucp
  124. <where>
  125. and ucp.del_flag ='0'
  126. <if test="params.name != null and params.name != ''">
  127. and ucp.period_name like concat('%', #{params.name}, '%')
  128. </if>
  129. <if test="params.campId != null">
  130. and ucp.training_camp_id = #{params.campId}
  131. </if>
  132. </where>
  133. </select>
  134. <update id="batchUpdateCoursePeriodDays" parameterType="java.util.List">
  135. update fs_user_course_period_days
  136. <trim prefix="set" suffixOverrides=",">
  137. day_date =
  138. <foreach collection="list" item="item" open="case" close=" end,">
  139. <if test="item.dayDate != null">
  140. when id=#{item.id} then #{item.dayDate}
  141. </if>
  142. </foreach>
  143. start_date_time =
  144. <foreach collection="list" item="item" open="case" close=" end,">
  145. <if test="item.startDateTime != null">
  146. when id=#{item.id} then #{item.startDateTime}
  147. </if>
  148. </foreach>
  149. end_date_time =
  150. <foreach collection="list" item="item" open="case" close=" end,">
  151. <if test="item.endDateTime != null">
  152. when id=#{item.id} then #{item.endDateTime}
  153. </if>
  154. </foreach>
  155. last_join_time =
  156. <foreach collection="list" item="item" open="case" close=" end,">
  157. <if test="item.lastJoinTime != null">
  158. when id=#{item.id} then #{item.lastJoinTime}
  159. </if>
  160. </foreach>
  161. lesson =
  162. <foreach collection="list" item="item" open="case" close=" end,">
  163. <if test="item.lesson != null">
  164. when id=#{item.id} then #{item.lesson}
  165. </if>
  166. </foreach>
  167. </trim>
  168. where id in
  169. <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
  170. #{item.id}
  171. </foreach>
  172. </update>
  173. <update id="startPeriodCourse">
  174. <![CDATA[
  175. update fs_user_course_period_days ucpd
  176. set ucpd.status = 1, ucpd.update_time = #{now}
  177. where ucpd.status = 0 and ucpd.start_date_time <= #{now}
  178. ]]>
  179. </update>
  180. <update id="endPeriodCourse">
  181. update fs_user_course_period_days ucpd
  182. set ucpd.status = 2, ucpd.update_time = #{now}
  183. <![CDATA[
  184. where ucpd.status = 1 and ucpd.end_date_time < #{now}
  185. ]]>
  186. </update>
  187. </mapper>