SysExamSongAccompanimentMapper.xml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <!--
  4. 这个文件是自动生成的。
  5. 不要修改此文件。所有改动将在下次重新自动生成时丢失。
  6. -->
  7. <mapper namespace="com.ym.mec.biz.dal.dao.SysExamSongAccompanimentDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.SysExamSongAccompaniment" id="SysExamSongAccompaniment">
  9. <result column="id_" property="id" />
  10. <result column="exam_song_id_" property="examSongId" />
  11. <result column="subject_id_" property="subjectId" />
  12. <result column="subject_name_" property="subjectName" />
  13. <result column="mp3_url_" property="mp3Url" />
  14. <result column="xml_url_" property="xmlUrl" />
  15. <result column="name_" property="examSongName" />
  16. <result column="type_" property="type" />
  17. <result column="url_" property="url" />
  18. <result column="del_flag_" property="delFlag" />
  19. <result column="speed_" property="speed" />
  20. <result column="create_time_" property="createTime" />
  21. <result column="update_time_" property="updateTime" />
  22. </resultMap>
  23. <!-- 根据主键查询一条记录 -->
  24. <select id="get" resultMap="SysExamSongAccompaniment" >
  25. SELECT sesa.*,ses.name_,ses.type_,ses.url_
  26. FROM sys_exam_song_accompaniment sesa
  27. LEFT JOIN sys_exam_song ses ON ses.id_ = sesa.exam_song_id_
  28. WHERE sesa.id_ = #{id}
  29. </select>
  30. <!-- 全查询 -->
  31. <select id="findAll" resultMap="SysExamSongAccompaniment">
  32. SELECT * FROM sys_exam_song_accompaniment ORDER BY id_
  33. </select>
  34. <!-- 向数据库增加一条记录 -->
  35. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.SysExamSongAccompaniment" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  36. INSERT INTO sys_exam_song_accompaniment (exam_song_id_,subject_id_,mp3_url_,xml_url_,speed_,create_time_,update_time_)
  37. VALUES(#{examSongId},#{subjectId},#{mp3Url},#{xmlUrl},#{speed},NOW(),NOW())
  38. </insert>
  39. <insert id="batchInsert">
  40. INSERT INTO sys_exam_song_accompaniment (exam_song_id_,subject_id_,mp3_url_,xml_url_,speed_,create_time_,update_time_)
  41. VALUES
  42. <foreach collection="sysExamSongAccompaniments" item="item" separator=",">
  43. (#{sysExamSongId},#{item.subjectId},#{item.mp3Url},#{item.xmlUrl},#{item.speed},NOW(),NOW())
  44. </foreach>
  45. </insert>
  46. <!-- 根据主键查询一条记录 -->
  47. <update id="update" parameterType="com.ym.mec.biz.dal.entity.SysExamSongAccompaniment">
  48. UPDATE sys_exam_song_accompaniment <set>
  49. <if test="subjectId != null">
  50. subject_id_ = #{subjectId},
  51. </if>
  52. <if test="speed != null">
  53. speed_ = #{speed},
  54. </if>
  55. <if test="xmlUrl != null">
  56. xml_url_ = #{xmlUrl},
  57. </if>
  58. <if test="examSongId != null">
  59. exam_song_id_ = #{examSongId},
  60. </if>
  61. <if test="mp3Url != null">
  62. mp3_url_ = #{mp3Url},
  63. </if>
  64. update_time_ = NOW()
  65. </set> WHERE id_ = #{id}
  66. </update>
  67. <!-- 根据主键删除一条记录 -->
  68. <update id="delete" >
  69. UPDATE sys_exam_song_accompaniment SET del_flag_ = 1,update_time_ = NOW() WHERE id_ = #{id}
  70. </update>
  71. <!-- 根据主键删除一条记录 -->
  72. <update id="deleteBySongId" >
  73. UPDATE sys_exam_song_accompaniment SET del_flag_ = 1,update_time_ = NOW() WHERE exam_song_id_ = #{examSongId}
  74. </update>
  75. <update id="batchUpdate">
  76. <foreach collection="sysExamSongAccompaniment" item="item" separator=";">
  77. UPDATE sys_exam_song_accompaniment
  78. <set>
  79. <if test="item.speed != null">
  80. speed_ = #{item.speed},
  81. </if>
  82. <if test="item.subjectId != null">
  83. subject_id_ = #{item.subjectId},
  84. </if>
  85. <if test="item.xmlUrl != null">
  86. xml_url_ = #{item.xmlUrl},
  87. </if>
  88. <if test="item.examSongId != null">
  89. exam_song_id_ = #{item.examSongId},
  90. </if>
  91. <if test="item.mp3Url != null">
  92. mp3_url_ = #{item.mp3Url},
  93. </if>
  94. update_time_ = NOW()
  95. </set> WHERE id_ = #{item.id}
  96. </foreach>
  97. </update>
  98. <update id="batchDel">
  99. UPDATE sys_exam_song_accompaniment SET del_flag_ = 1,update_time_ = NOW() WHERE id_ IN
  100. <foreach collection="delExamSongAccompanimentIds" item="item" open="(" close=")" separator=",">
  101. #{item}
  102. </foreach>
  103. </update>
  104. <!-- 分页查询 -->
  105. <select id="queryPage" resultMap="SysExamSongAccompaniment" parameterType="map">
  106. SELECT sesa.*,s.name_ subject_name_
  107. FROM sys_exam_song_accompaniment sesa
  108. LEFT JOIN `subject` s ON s.id_ = sesa.subject_id_
  109. <where>
  110. sesa.del_flag_ = 0
  111. <if test="subjectId != null">
  112. AND sesa.subject_id_ = #{subjectId}
  113. </if>
  114. <if test="sysExamSongId != null">
  115. AND sesa.exam_song_id_ = #{sysExamSongId}
  116. </if>
  117. </where>
  118. ORDER BY sesa.id_ DESC
  119. <include refid="global.limit"/>
  120. </select>
  121. <!-- 查询当前表的总记录数 -->
  122. <select id="queryCount" resultType="int">
  123. SELECT COUNT(*) FROM sys_exam_song_accompaniment
  124. </select>
  125. <select id="findSubjectByExamId" resultType="java.lang.Integer">
  126. SELECT subject_id_ FROM sys_exam_song_accompaniment
  127. <where>
  128. del_flag_ = 0
  129. <if test="sysExamSongId != null">
  130. AND exam_song_id_ = #{sysExamSongId}
  131. </if>
  132. <if test="examSongAccIds != null and examSongAccIds.size > 0">
  133. AND id_ NOT IN
  134. <foreach collection="examSongAccIds" open="(" close=")" item="item" separator=",">
  135. #{item}
  136. </foreach>
  137. </if>
  138. </where>
  139. </select>
  140. <select id="queryAccPage" resultMap="SysExamSongAccompaniment">
  141. SELECT sesa.*,ses.name_,ses.type_,ses.url_,s.name_ subject_name_
  142. FROM sys_exam_song_accompaniment sesa
  143. LEFT JOIN sys_exam_song ses ON ses.id_ = sesa.exam_song_id_
  144. LEFT JOIN subject s ON s.id_ = sesa.subject_id_
  145. <include refid="queryPageSql"/>
  146. </select>
  147. <select id="findAccCount" resultType="java.lang.Integer">
  148. SELECT COUNT(DISTINCT sesa.id_) FROM sys_exam_song_accompaniment sesa
  149. LEFT JOIN sys_exam_song ses ON ses.id_ = sesa.exam_song_id_
  150. <include refid="queryPageSql"/>
  151. </select>
  152. <sql id="queryPageSql">
  153. <where>
  154. sesa.del_flag_ = 0
  155. <if test="search != null and search != ''">
  156. AND (sesa.id_ = #{search} OR ses.name_ LIKE CONCAT('%',#{search},'%'))
  157. </if>
  158. <if test="sysExamSongId != null">
  159. AND sesa.exam_song_id_ = #{sysExamSongId}
  160. </if>
  161. <if test="subjectId != null">
  162. AND sesa.subject_id_ = #{subjectId}
  163. </if>
  164. <if test="type != null and type == 'COMMON'">
  165. AND ses.type_ = #{type}
  166. </if>
  167. <if test="type != null and type == 'ALL'">
  168. <if test="createUserId != null">
  169. AND (ses.type_ = 'COMMON' OR (ses.create_user_id_ = #{createUserId} AND ses.type_ = 'PERSON'))
  170. </if>
  171. </if>
  172. <if test="type != null and type == 'PERSON'">
  173. <if test="createUserId != null">
  174. AND ses.type_ = #{type} AND ses.create_user_id_ = #{createUserId}
  175. </if>
  176. <if test="createUserId == null">
  177. AND ses.type_ = #{type}
  178. </if>
  179. </if>
  180. <if test="type == null or type == ''">
  181. <if test="createUserId != null">
  182. AND ses.create_user_id_ = #{createUserId}
  183. </if>
  184. </if>
  185. </where>
  186. </sql>
  187. </mapper>