FsUserCoursePeriodMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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.FsUserCoursePeriodMapper">
  6. <resultMap type="FsUserCoursePeriod" id="FsUserCoursePeriodResult">
  7. <result property="periodId" column="period_id" />
  8. <result property="periodName" column="period_name" />
  9. <result property="companyId" column="company_id" />
  10. <result property="trainingCampId" column="training_camp_id" />
  11. <result property="createTime" column="create_time" />
  12. <result property="updateTime" column="update_time" />
  13. <result property="courseStyle" column="course_style" />
  14. <result property="liveRoomStyle" column="live_room_style" />
  15. <result property="redPacketGrantMethod" column="red_packet_grant_method" />
  16. <result property="periodType" column="period_type" />
  17. <result property="periodStartingTime" column="period_starting_time" />
  18. <result property="periodEndTime" column="period_end_time" />
  19. <result property="maxViewNum" column="max_view_num" />
  20. <result property="courseLogo" column="course_logo" />
  21. <result property="openCommentStatus" column="open_comment_status" />
  22. </resultMap>
  23. <sql id="selectFsUserCoursePeriodVo">
  24. select * from fs_user_course_period
  25. </sql>
  26. <select id="selectFsUserCoursePeriodList" parameterType="FsUserCoursePeriod" resultMap="FsUserCoursePeriodResult">
  27. <include refid="selectFsUserCoursePeriodVo"/>
  28. <where>
  29. <if test="periodName != null and periodName != ''"> and period_name like concat('%', #{periodName}, '%')</if>
  30. <if test="companyId != null "> and FIND_IN_SET (#{companyId}, company_id ) > 0</if>
  31. <if test="trainingCampId != null "> and training_camp_id = #{trainingCampId}</if>
  32. <if test="courseStyle != null and courseStyle != ''"> and course_style = #{courseStyle}</if>
  33. <if test="liveRoomStyle != null and liveRoomStyle != ''"> and live_room_style = #{liveRoomStyle}</if>
  34. <if test="redPacketGrantMethod != null "> and red_packet_grant_method = #{redPacketGrantMethod}</if>
  35. <if test="periodType != null "> and period_type = #{periodType}</if>
  36. <if test="periodStartingTime != null "> and period_starting_time = #{periodStartingTime}</if>
  37. <if test="periodEndTime != null "> and period_end_time = #{periodEndTime}</if>
  38. </where>
  39. </select>
  40. <select id="selectFsUserCoursePeriodPage" parameterType="FsUserCoursePeriod" resultType="FsUserCoursePeriodVO">
  41. SELECT
  42. fs_user_course_period.period_id,
  43. fs_user_course_period.period_name,
  44. fs_user_course_period.company_id,
  45. fs_user_course_period.training_camp_id,
  46. fs_user_course_period.create_time,
  47. fs_user_course_period.update_time,
  48. fs_user_course_period.period_status,
  49. fs_user_course_period.max_view_num,
  50. course_style,
  51. live_room_style,
  52. red_packet_grant_method,
  53. period_type,
  54. period_end_time,
  55. period_starting_time,
  56. fctc.training_camp_name AS trainingCampName,
  57. GROUP_CONCAT( company.company_name ) AS companyName
  58. FROM
  59. fs_user_course_period
  60. left join fs_user_course_training_camp fctc on fctc.training_camp_id = fs_user_course_period.training_camp_id
  61. left join company on FIND_IN_SET(company.company_id, fs_user_course_period.company_id) > 0
  62. <where>
  63. <if test="trainingCampId != null"> and fs_user_course_period.training_camp_id = #{trainingCampId}</if>
  64. <if test="periodName != null and periodName != ''"> and period_name like concat('%', #{periodName}, '%')</if>
  65. <if test="companyIdList != null and companyIdList.size() > 0 ">
  66. and fs_user_course_period.company_id in
  67. <foreach item="companyId" index="index" collection="companyIdList"
  68. open="(" separator="," close=")">
  69. #{companyId}
  70. </foreach>
  71. </if>
  72. <if test="periodStartingTime != null "> and period_starting_time &gt;= #{periodStartingTime}</if>
  73. <if test="periodEndTime != null "> and period_end_time &lt;= #{periodEndTime}</if>
  74. </where>
  75. group by fs_user_course_period.period_id
  76. order by create_time desc
  77. </select>
  78. <select id="selectFsUserCoursePeriodById" parameterType="Long" resultMap="FsUserCoursePeriodResult">
  79. <include refid="selectFsUserCoursePeriodVo"/>
  80. where period_id = #{periodId}
  81. </select>
  82. <insert id="insertFsUserCoursePeriod" parameterType="FsUserCoursePeriod" useGeneratedKeys="true" keyProperty="periodId">
  83. insert into fs_user_course_period
  84. <trim prefix="(" suffix=")" suffixOverrides=",">
  85. <if test="periodId != null">period_id,</if>
  86. <if test="periodName != null">period_name,</if>
  87. <if test="companyId != null">company_id,</if>
  88. <if test="trainingCampId != null">training_camp_id,</if>
  89. <if test="createTime != null">create_time,</if>
  90. <if test="updateTime != null">update_time,</if>
  91. <if test="courseStyle != null">course_style,</if>
  92. <if test="liveRoomStyle != null">live_room_style,</if>
  93. <if test="redPacketGrantMethod != null">red_packet_grant_method,</if>
  94. <if test="periodType != null">period_type,</if>
  95. <if test="periodStartingTime != null">period_starting_time,</if>
  96. <if test="periodEndTime != null">period_end_time,</if>
  97. <if test="periodStatus != null">period_status,</if>
  98. <if test="viewStartTime != null">view_start_time,</if>
  99. <if test="viewEndTime != null">view_end_time,</if>
  100. <if test="lastJoinTime != null">last_join_time,</if>
  101. <if test="maxViewNum != null">max_view_num,</if>
  102. <if test="courseLogo != null">course_logo,</if>
  103. <if test="openCommentStatus != null">open_comment_status,</if>
  104. </trim>
  105. <trim prefix="values (" suffix=")" suffixOverrides=",">
  106. <if test="periodId != null">#{periodId},</if>
  107. <if test="periodName != null">#{periodName},</if>
  108. <if test="companyId != null">#{companyId},</if>
  109. <if test="trainingCampId != null">#{trainingCampId},</if>
  110. <if test="createTime != null">#{createTime},</if>
  111. <if test="updateTime != null">#{updateTime},</if>
  112. <if test="courseStyle != null">#{courseStyle},</if>
  113. <if test="liveRoomStyle != null">#{liveRoomStyle},</if>
  114. <if test="redPacketGrantMethod != null">#{redPacketGrantMethod},</if>
  115. <if test="periodType != null">#{periodType},</if>
  116. <if test="periodStartingTime != null">#{periodStartingTime},</if>
  117. <if test="periodEndTime != null">#{periodEndTime},</if>
  118. <if test="periodStatus != null">#{periodStatus},</if>
  119. <if test="viewStartTime != null">#{viewStartTime},</if>
  120. <if test="viewEndTime != null">#{viewEndTime},</if>
  121. <if test="lastJoinTime != null">#{lastJoinTime},</if>
  122. <if test="maxViewNum != null">#{maxViewNum},</if>
  123. <if test="courseLogo != null">#{courseLogo},</if>
  124. <if test="openCommentStatus != null">#{openCommentStatus},</if>
  125. </trim>
  126. </insert>
  127. <update id="updateFsUserCoursePeriod" parameterType="FsUserCoursePeriod">
  128. update fs_user_course_period
  129. <trim prefix="SET" suffixOverrides=",">
  130. <if test="periodName != null">period_name = #{periodName},</if>
  131. <if test="companyId != null">company_id = #{companyId},</if>
  132. <if test="trainingCampId != null">training_camp_id = #{trainingCampId},</if>
  133. <if test="createTime != null">create_time = #{createTime},</if>
  134. <if test="updateTime != null">update_time = #{updateTime},</if>
  135. <if test="courseStyle != null">course_style = #{courseStyle},</if>
  136. <if test="liveRoomStyle != null">live_room_style = #{liveRoomStyle},</if>
  137. <if test="redPacketGrantMethod != null">red_packet_grant_method = #{redPacketGrantMethod},</if>
  138. <if test="periodType != null">period_type = #{periodType},</if>
  139. <if test="periodStartingTime != null">period_starting_time = #{periodStartingTime},</if>
  140. <if test="periodEndTime != null">period_end_time = #{periodEndTime},</if>
  141. <if test="periodStatus != null">period_status = #{periodStatus},</if>
  142. <if test="viewStartTime != null">view_start_time = #{viewStartTime},</if>
  143. <if test="viewEndTime != null">view_end_time = #{viewEndTime},</if>
  144. <if test="lastJoinTime != null">last_join_time = #{lastJoinTime},</if>
  145. <if test="maxViewNum != null">max_view_num = #{maxViewNum},</if>
  146. <if test="courseLogo != null and courseLogo !=''">course_logo = #{courseLogo},</if>
  147. <if test="openCommentStatus != null">open_comment_status = #{openCommentStatus},</if>
  148. </trim>
  149. where period_id = #{periodId}
  150. </update>
  151. <delete id="deleteFsUserCoursePeriodById" parameterType="Long">
  152. delete from fs_user_course_period where period_id = #{periodId}
  153. </delete>
  154. <delete id="deleteFsUserCoursePeriodByIds" parameterType="String">
  155. delete from fs_user_course_period where period_id in
  156. <foreach item="periodId" collection="array" open="(" separator="," close=")">
  157. #{periodId}
  158. </foreach>
  159. </delete>
  160. <select id="selectCompanyByPeriodVideo" resultType="com.fs.course.param.CompanyRedPacketParam">
  161. SELECT
  162. company.company_id,
  163. company.company_name,
  164. ifnull ( fvrp.red_packet_money, 0 ) AS amount
  165. FROM
  166. company
  167. LEFT JOIN fs_user_course_video_red_package fvrp ON fvrp.company_id = company.company_id
  168. AND fvrp.period_id = #{periodId}
  169. <if test="videoId != null and videoId!='' ">
  170. and fvrp.video_id = #{videoId}
  171. </if>
  172. WHERE
  173. company.company_id IN (
  174. SELECT
  175. company.company_id
  176. FROM
  177. company
  178. LEFT JOIN fs_user_course_period fcp ON FIND_IN_SET ( company.company_id, fcp.company_id ) > 0
  179. WHERE
  180. fcp.period_id = #{periodId}
  181. )
  182. </select>
  183. <select id="selectCompanyByPeriod" resultType="com.fs.course.param.CompanyRedPacketParam">
  184. SELECT
  185. company.company_id,
  186. company.company_name
  187. FROM
  188. company
  189. LEFT JOIN fs_user_course_period fcp ON FIND_IN_SET ( company.company_id, fcp.company_id ) > 0
  190. where fcp.period_id = #{periodId}
  191. </select>
  192. <select id="selectPeriodRedPacket" resultType="com.fs.course.vo.PeriodRedPacketVO">
  193. SELECT
  194. DISTINCT a.*,
  195. c.course_name,
  196. cv.title videoName,
  197. ifnull ( fvrp.red_packet_money, 0 ) AS amount
  198. FROM
  199. fs_user_course_period_days a
  200. LEFT JOIN fs_user_course_video cv ON a.video_id = cv.video_id
  201. LEFT JOIN fs_user_course c ON c.course_id = cv.course_id
  202. LEFT JOIN fs_user_course_video_red_package fvrp ON fvrp.period_id = a.period_id
  203. AND fvrp.video_id = a.video_id
  204. AND fvrp.period_id = #{periodId}
  205. AND fvrp.company_id = #{companyId}
  206. AND fvrp.data_type = 2
  207. WHERE
  208. a.video_id IN (
  209. SELECT
  210. a.video_id
  211. FROM
  212. fs_user_course_period_days a
  213. LEFT JOIN fs_user_course_video cv ON a.video_id = cv.video_id
  214. LEFT JOIN fs_user_course c ON c.course_id = cv.course_id
  215. WHERE
  216. a.period_id = #{periodId}
  217. )
  218. and a.period_id = #{periodId}
  219. </select>
  220. <select id="selectFsUserCoursePeriodsByIds" resultType="FsUserCoursePeriod">
  221. select * from fs_user_course_period
  222. where period_id in
  223. <foreach collection="periodIds" item="item" open="(" separator="," close=")">
  224. #{item}
  225. </foreach>
  226. </select>
  227. <select id="countPeriodByCampIds" resultType="java.lang.Integer">
  228. select count(ucp.period_id)
  229. from fs_user_course_period ucp
  230. inner join fs_user_course_training_camp uctc on uctc.training_camp_id = ucp.training_camp_id
  231. where uctc.training_camp_id in
  232. <foreach collection="params.ids" item="id" open="(" separator="," close=")">
  233. #{id}
  234. </foreach>
  235. <![CDATA[
  236. and ((ucp.period_starting_time <= #{params.date}
  237. and ucp.period_end_time >= #{params.date}
  238. ) or ucp.period_end_time < #{params.date})
  239. ]]>
  240. </select>
  241. <select id="selectPeriodListByTrainingCampIds" resultType="FsUserCoursePeriod">
  242. select * from fs_user_course_period
  243. where training_camp_id in
  244. <foreach collection="trainingCampIds" item="item" open="(" separator="," close=")">
  245. #{item}
  246. </foreach>
  247. </select>
  248. </mapper>