SysExamSongAccompanimentMapper.xml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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 * FROM sys_exam_song_accompaniment WHERE id_ = #{id}
  26. </select>
  27. <!-- 全查询 -->
  28. <select id="findAll" resultMap="SysExamSongAccompaniment">
  29. SELECT * FROM sys_exam_song_accompaniment ORDER BY id_
  30. </select>
  31. <!-- 向数据库增加一条记录 -->
  32. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.SysExamSongAccompaniment" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  33. INSERT INTO sys_exam_song_accompaniment (exam_song_id_,subject_id_,mp3_url_,xml_url_,speed_,create_time_,update_time_)
  34. VALUES(#{examSongId},#{subjectId},#{mp3Url},#{xmlUrl},#{speed},NOW(),NOW())
  35. </insert>
  36. <insert id="batchInsert">
  37. INSERT INTO sys_exam_song_accompaniment (exam_song_id_,subject_id_,mp3_url_,xml_url_,speed_,create_time_,update_time_)
  38. VALUES
  39. <foreach collection="sysExamSongAccompaniments" item="item" separator=",">
  40. (#{sysExamSongId},#{item.subjectId},#{item.mp3Url},#{item.xmlUrl},#{item.speed},NOW(),NOW())
  41. </foreach>
  42. </insert>
  43. <!-- 根据主键查询一条记录 -->
  44. <update id="update" parameterType="com.ym.mec.biz.dal.entity.SysExamSongAccompaniment">
  45. UPDATE sys_exam_song_accompaniment <set>
  46. <if test="subjectId != null">
  47. subject_id_ = #{subjectId},
  48. </if>
  49. <if test="speed != null">
  50. speed_ = #{speed},
  51. </if>
  52. <if test="xmlUrl != null">
  53. xml_url_ = #{xmlUrl},
  54. </if>
  55. <if test="examSongId != null">
  56. exam_song_id_ = #{examSongId},
  57. </if>
  58. <if test="mp3Url != null">
  59. mp3_url_ = #{mp3Url},
  60. </if>
  61. update_time_ = NOW()
  62. </set> WHERE id_ = #{id}
  63. </update>
  64. <!-- 根据主键删除一条记录 -->
  65. <update id="delete" >
  66. UPDATE sys_exam_song_accompaniment SET del_flag_ = 1,update_time_ = NOW() WHERE id_ = #{id}
  67. </update>
  68. <!-- 根据主键删除一条记录 -->
  69. <update id="deleteBySongId" >
  70. UPDATE sys_exam_song_accompaniment SET del_flag_ = 1,update_time_ = NOW() WHERE exam_song_id_ = #{examSongId}
  71. </update>
  72. <update id="batchUpdate">
  73. <foreach collection="sysExamSongAccompaniment" item="item" separator=";">
  74. UPDATE sys_exam_song_accompaniment
  75. <set>
  76. <if test="item.speed != null">
  77. speed_ = #{item.speed},
  78. </if>
  79. <if test="item.subjectId != null">
  80. subject_id_ = #{item.subjectId},
  81. </if>
  82. <if test="item.xmlUrl != null">
  83. xml_url_ = #{item.xmlUrl},
  84. </if>
  85. <if test="item.examSongId != null">
  86. exam_song_id_ = #{item.examSongId},
  87. </if>
  88. <if test="item.mp3Url != null">
  89. mp3_url_ = #{item.mp3Url},
  90. </if>
  91. update_time_ = NOW()
  92. </set> WHERE id_ = #{item.id}
  93. </foreach>
  94. </update>
  95. <update id="batchDel">
  96. UPDATE sys_exam_song_accompaniment SET del_flag_ = 1,update_time_ = NOW() WHERE id_ IN
  97. <foreach collection="delExamSongAccompanimentIds" item="item" open="(" close=")" separator=",">
  98. #{item}
  99. </foreach>
  100. </update>
  101. <!-- 分页查询 -->
  102. <select id="queryPage" resultMap="SysExamSongAccompaniment" parameterType="map">
  103. SELECT sesa.*,s.name_ subject_name_
  104. FROM sys_exam_song_accompaniment sesa
  105. LEFT JOIN `subject` s ON s.id_ = sesa.subject_id_
  106. <where>
  107. sesa.del_flag_ = 0
  108. <if test="subjectId != null">
  109. AND sesa.subject_id_ = #{subjectId}
  110. </if>
  111. <if test="sysExamSongId != null">
  112. AND sesa.exam_song_id_ = #{sysExamSongId}
  113. </if>
  114. </where>
  115. ORDER BY sesa.id_ DESC
  116. <include refid="global.limit"/>
  117. </select>
  118. <!-- 查询当前表的总记录数 -->
  119. <select id="queryCount" resultType="int">
  120. SELECT COUNT(*) FROM sys_exam_song_accompaniment
  121. </select>
  122. <select id="findSubjectByExamId" resultType="java.lang.Integer">
  123. SELECT subject_id_ FROM sys_exam_song_accompaniment
  124. <where>
  125. del_flag_ = 0
  126. <if test="sysExamSongId != null">
  127. AND exam_song_id_ = #{sysExamSongId}
  128. </if>
  129. <if test="examSongAccIds != null and examSongAccIds.size > 0">
  130. AND id_ NOT IN
  131. <foreach collection="examSongAccIds" open="(" close=")" item="item" separator=",">
  132. #{item}
  133. </foreach>
  134. </if>
  135. </where>
  136. </select>
  137. <select id="queryAccPage" resultMap="SysExamSongAccompaniment">
  138. SELECT sesa.*,ses.name_,ses.type_,ses.url_ FROM sys_exam_song_accompaniment sesa
  139. LEFT JOIN sys_exam_song ses ON ses.id_ = sesa.exam_song_id_
  140. <include refid="queryPageSql"/>
  141. <include refid="global.limit"/>
  142. </select>
  143. <select id="findAccCount" resultType="java.lang.Integer">
  144. SELECT COUNT(DISTINCT sesa.id_) FROM sys_exam_song_accompaniment sesa
  145. LEFT JOIN sys_exam_song ses ON ses.id_ = sesa.exam_song_id_
  146. <include refid="queryPageSql"/>
  147. </select>
  148. <sql id="queryPageSql">
  149. <where>
  150. sesa.del_flag_ = 0
  151. <if test="search != null and search != ''">
  152. AND (sesa.id_ = #{search} OR ses.name_ LIKE CONCAT('%',#{search},'%'))
  153. </if>
  154. <if test="subjectId != null">
  155. AND sesa.subject_id_ = #{subjectId}
  156. </if>
  157. <if test="type != null and type == 'COMMON'">
  158. AND ses.type_ = #{type}
  159. </if>
  160. <if test="type != null and type == 'ALL'">
  161. <if test="createUserId != null">
  162. AND (ses.type_ = 'COMMON' OR (ses.create_user_id_ = #{createUserId} AND ses.type_ = 'PERSON'))
  163. </if>
  164. </if>
  165. <if test="type != null and type == 'PERSON'">
  166. <if test="createUserId != null">
  167. AND ses.type_ = #{type} AND ses.create_user_id_ = #{createUserId}
  168. </if>
  169. <if test="createUserId == null">
  170. AND ses.type_ = #{type}
  171. </if>
  172. </if>
  173. <if test="type == null or type == ''">
  174. <if test="createUserId != null">
  175. AND ses.create_user_id_ = #{createUserId}
  176. </if>
  177. </if>
  178. </where>
  179. </sql>
  180. </mapper>