FsCourseRewardVideoRelationMapper.xml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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.FsCourseRewardVideoRelationMapper">
  6. <resultMap type="FsCourseRewardVideoRelation" id="FsCourseRewardVideoRelationResult">
  7. <result property="id" column="id" />
  8. <result property="rewardId" column="reward_id" />
  9. <result property="videoSectionId" column="video_section_id" />
  10. <result property="mark" column="mark" />
  11. <result property="createId" column="create_id" />
  12. <result property="createTime" column="create_time" />
  13. <result property="updateId" column="update_id" />
  14. <result property="updateTime" column="update_time" />
  15. <result property="companyId" column="company_id" />
  16. </resultMap>
  17. <sql id="selectFsCourseRewardVideoRelationVo">
  18. select id, reward_id, company_id,video_section_id, mark, create_id, create_time, update_id, update_time from fs_course_reward_video_relation
  19. </sql>
  20. <select id="selectFsCourseRewardVideoRelationList" parameterType="FsCourseRewardVideoRelation" resultMap="FsCourseRewardVideoRelationResult">
  21. <include refid="selectFsCourseRewardVideoRelationVo"/>
  22. <where>
  23. <if test="rewardId != null and rewardId != ''"> and reward_id = #{rewardId}</if>
  24. <if test="videoSectionId != null and videoSectionId != ''"> and video_section_id = #{videoSectionId}</if>
  25. <if test="mark != null "> and mark = #{mark}</if>
  26. <if test="createId != null "> and create_id = #{createId}</if>
  27. <if test="updateId != null "> and update_id = #{updateId}</if>
  28. </where>
  29. </select>
  30. <select id="selectFsCourseRewardVideoRelationById" parameterType="String" resultMap="FsCourseRewardVideoRelationResult">
  31. <include refid="selectFsCourseRewardVideoRelationVo"/>
  32. where id = #{id}
  33. </select>
  34. <select id="getRewardIdByCompanyIdAndVideoIdAndType" resultType="java.lang.Long">
  35. select cr.id
  36. from fs_course_reward_video_relation crvr
  37. inner join fs_course_reward cr on cr.id = crvr.reward_id and cr.reward_type = #{type}
  38. where crvr.company_id = #{companyId} and crvr.video_section_id = #{videoId} and cr.status = 1
  39. limit 1
  40. </select>
  41. <select id="getRewardByCompanyIdAndVideoIdAndType" resultType="com.fs.course.domain.FsCourseReward">
  42. select cr.*
  43. from fs_course_reward cr
  44. inner join fs_course_reward_video_relation crvr on cr.id = crvr.reward_id
  45. where crvr.company_id = #{companyId} and crvr.video_section_id = #{videoId} and cr.reward_type = #{type} and cr.status = 1
  46. limit 1
  47. </select>
  48. <insert id="insertFsCourseRewardVideoRelation" parameterType="FsCourseRewardVideoRelation" useGeneratedKeys="true" keyProperty="id">
  49. insert into fs_course_reward_video_relation
  50. <trim prefix="(" suffix=")" suffixOverrides=",">
  51. <if test="rewardId != null and rewardId != ''">reward_id,</if>
  52. <if test="videoSectionId != null and videoSectionId != ''">video_section_id,</if>
  53. <if test="mark != null">mark,</if>
  54. <if test="createId != null">create_id,</if>
  55. <if test="createTime != null">create_time,</if>
  56. <if test="updateId != null">update_id,</if>
  57. <if test="updateTime != null">update_time,</if>
  58. <if test="companyId != null">company_id,</if>
  59. </trim>
  60. <trim prefix="values (" suffix=")" suffixOverrides=",">
  61. <if test="rewardId != null and rewardId != ''">#{rewardId},</if>
  62. <if test="videoSectionId != null and videoSectionId != ''">#{videoSectionId},</if>
  63. <if test="mark != null">#{mark},</if>
  64. <if test="createId != null">#{createId},</if>
  65. <if test="createTime != null">#{createTime},</if>
  66. <if test="updateId != null">#{updateId},</if>
  67. <if test="updateTime != null">#{updateTime},</if>
  68. <if test="companyId != null">#{companyId},</if>
  69. </trim>
  70. </insert>
  71. <update id="updateFsCourseRewardVideoRelation" parameterType="FsCourseRewardVideoRelation">
  72. update fs_course_reward_video_relation
  73. <trim prefix="SET" suffixOverrides=",">
  74. <if test="rewardId != null and rewardId != ''">reward_id = #{rewardId},</if>
  75. <if test="videoSectionId != null and videoSectionId != ''">video_section_id = #{videoSectionId},</if>
  76. <if test="mark != null">mark = #{mark},</if>
  77. <if test="createId != null">create_id = #{createId},</if>
  78. <if test="createTime != null">create_time = #{createTime},</if>
  79. <if test="updateId != null">update_id = #{updateId},</if>
  80. <if test="updateTime != null">update_time = #{updateTime},</if>
  81. <if test="companyId != null">company_id = #{companyId},</if>
  82. </trim>
  83. where id = #{id}
  84. </update>
  85. <delete id="deleteFsCourseRewardVideoRelationById" parameterType="String">
  86. delete from fs_course_reward_video_relation where id = #{id}
  87. </delete>
  88. <delete id="deleteFsCourseRewardVideoRelationByIds" parameterType="String">
  89. delete from fs_course_reward_video_relation where id in
  90. <foreach item="id" collection="array" open="(" separator="," close=")">
  91. #{id}
  92. </foreach>
  93. </delete>
  94. <delete id="deleteByTypes">
  95. delete crvr from fs_course_reward_video_relation crvr
  96. inner join fs_course_reward cr on cr.id = crvr.reward_id
  97. where crvr.video_section_id = #{videoId} and crvr.company_id = #{companyId}
  98. and cr.reward_type in
  99. <foreach item="type" collection="types" open="(" separator="," close=")">
  100. #{type}
  101. </foreach>
  102. </delete>
  103. <select id="selectFsCourseRewardVideoRelationListByType" resultMap="FsCourseRewardVideoRelationResult">
  104. select crvr.id, crvr.reward_id, crvr.company_id,crvr.video_section_id, crvr.mark, crvr.create_id, crvr.create_time, crvr.update_id, crvr.update_time
  105. from fs_course_reward_video_relation crvr
  106. inner join fs_course_reward cr on cr.id = crvr.reward_id
  107. <where>
  108. <if test="rewardId != null and rewardId != ''"> and crvr.reward_id = #{rewardId}</if>
  109. <if test="type != null and type != ''"> and cr.reward_type = #{type}</if>
  110. <if test="videoSectionId != null and videoSectionId != ''"> and video_section_id = #{videoSectionId}</if>
  111. <if test="mark != null "> and crvr.mark = #{mark}</if>
  112. <if test="companyId != null ">and crvr.company_id = #{companyId}</if>
  113. <if test="createId != null "> and crvr.create_id = #{createId}</if>
  114. <if test="updateId != null "> and crvr.update_id = #{updateId}</if>
  115. </where>
  116. </select>
  117. <select id="selectByCompanyIdAndVideoIdAndRewardId" resultType="com.fs.course.domain.FsCourseRewardVideoRelation">
  118. select
  119. *
  120. from fs_course_reward_video_relation
  121. where company_id = #{companyId} and video_section_id = #{videoId} and reward_id = #{rewardId}
  122. </select>
  123. </mapper>