ExamSubjectSongMapper.xml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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.keao.edu.user.dao.ExamSubjectSongDao">
  8. <resultMap type="com.keao.edu.user.entity.ExamSubjectSong" id="ExamSubjectSong">
  9. <result column="id_" property="id" />
  10. <result column="examination_basic_id_" property="examinationBasicId" />
  11. <result column="exam_subject_id_" property="examSubjectId" />
  12. <result column="level_" property="level" />
  13. <result column="practice_num_" property="practiceNum" />
  14. <result column="practice_song_id_list_" property="practiceSongIdList" />
  15. <result column="perform_num_" property="performNum" />
  16. <result column="perform_song_id_list_" property="performSongIdList" />
  17. <result column="registration_fee_" property="registrationFee" />
  18. <result column="create_time_" property="createTime" />
  19. <result column="update_time_" property="updateTime" />
  20. <result column="tenant_id_" property="tenantId" />
  21. <association property="subject" columnPrefix="sub_" resultMap="com.keao.edu.user.dao.SubjectDao.Subject" />
  22. </resultMap>
  23. <!-- 根据主键查询一条记录 -->
  24. <select id="get" resultMap="ExamSubjectSong" >
  25. SELECT * FROM exam_subject_song WHERE id_ = #{id}
  26. </select>
  27. <!-- 全查询 -->
  28. <select id="findAll" resultMap="ExamSubjectSong">
  29. SELECT * FROM exam_subject_song ORDER BY id_
  30. </select>
  31. <!-- 向数据库增加一条记录 -->
  32. <insert id="insert" parameterType="com.keao.edu.user.entity.ExamSubjectSong" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  33. INSERT INTO exam_subject_song (examination_basic_id_,exam_subject_id_,level_,practice_num_,practice_song_id_list_,perform_num_,perform_song_id_list_,registration_fee_,create_time_,update_time_,tenant_id_)
  34. VALUES (#{examinationBasicId},#{examSubjectId},#{level},#{practiceNum},#{practiceSongIdList},#{performNum},#{performSongIdList},#{registrationFee},NOW(),NOW(),#{tenantId})
  35. </insert>
  36. <insert id="batchInsert" parameterType="com.keao.edu.user.entity.ExamSubjectSong" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  37. INSERT INTO exam_subject_song (examination_basic_id_,exam_subject_id_,level_,practice_num_,practice_song_id_list_,perform_num_,perform_song_id_list_,registration_fee_,create_time_,update_time_,tenant_id_)
  38. VALUES
  39. <foreach collection="examSubjectSongs" item="examSubjectSong" separator=",">
  40. (#{examSubjectSong.examinationBasicId},#{examSubjectSong.examSubjectId},#{examSubjectSong.level},#{examSubjectSong.practiceNum},#{examSubjectSong.practiceSongIdList},#{examSubjectSong.performNum},#{examSubjectSong.performSongIdList},#{examSubjectSong.registrationFee},NOW(),NOW(),#{examSubjectSong.tenantId})
  41. </foreach>
  42. </insert>
  43. <!-- 根据主键查询一条记录 -->
  44. <update id="update" parameterType="com.keao.edu.user.entity.ExamSubjectSong">
  45. UPDATE exam_subject_song
  46. <set>
  47. <if test="examinationBasicId != null">
  48. examination_basic_id_ = #{examinationBasicId},
  49. </if>
  50. <if test="performNum != null">
  51. perform_num_ = #{performNum},
  52. </if>
  53. <if test="id != null">
  54. id_ = #{id},
  55. </if>
  56. <if test="practiceSongIdList != null">
  57. practice_song_id_list_ = #{practiceSongIdList},
  58. </if>
  59. <if test="practiceNum != null">
  60. practice_num_ = #{practiceNum},
  61. </if>
  62. <if test="tenantId != null">
  63. tenant_id_ = #{tenantId},
  64. </if>
  65. <if test="examSubjectId != null">
  66. exam_subject_id_ = #{examSubjectId},
  67. </if>
  68. <if test="performSongIdList != null">
  69. perform_song_id_list_ = #{performSongIdList},
  70. </if>
  71. <if test="registrationFee != null">
  72. registration_fee_ = #{registrationFee},
  73. </if>
  74. <if test="updateTime != null">
  75. update_time_ = #{updateTime},
  76. </if>
  77. <if test="level != null">
  78. level_ = #{level},
  79. </if>
  80. <if test="createTime != null">
  81. create_time_ = #{createTime},
  82. </if>
  83. </set> WHERE id_ = #{id}
  84. </update>
  85. <!-- 根据主键删除一条记录 -->
  86. <delete id="delete" >
  87. DELETE FROM exam_subject_song WHERE id_ = #{id}
  88. </delete>
  89. <sql id="queryCondition">
  90. <where>
  91. ess.tenant_id_ = #{tenantId}
  92. <if test="examId!=null">
  93. AND ess.examination_basic_id_ = #{examId}
  94. </if>
  95. <if test="level!=null">
  96. AND ess.level_=#{level}
  97. </if>
  98. <if test="search!=null">
  99. AND (ess.exam_subject_id_=#{search} OR s.name_ LIKE CONCAT(#{search}, '%'))
  100. </if>
  101. </where>
  102. </sql>
  103. <!-- 分页查询 -->
  104. <select id="queryPage" resultMap="ExamSubjectSong" parameterType="map">
  105. SELECT
  106. ess.*,
  107. s.id_ sub_id_, s.name_ sub_name_
  108. FROM exam_subject_song ess
  109. LEFT JOIN subject s ON ess.exam_subject_id_=s.id_
  110. <include refid="queryCondition"/>
  111. ORDER BY ess.id_
  112. <include refid="global.limit"/>
  113. </select>
  114. <!-- 查询当前表的总记录数 -->
  115. <select id="queryCount" resultType="int">
  116. SELECT COUNT(*) FROM exam_subject_song ess
  117. LEFT JOIN subject s ON ess.exam_subject_id_=s.id_
  118. <include refid="queryCondition"/>
  119. </select>
  120. <select id="findByExam" resultMap="ExamSubjectSong">
  121. SELECT * FROM exam_subject_song WHERE examination_basic_id_=#{examId}
  122. </select>
  123. <select id="getExamSubjectSong" resultType="com.keao.edu.user.entity.ExamSubjectSong">
  124. SELECT * FROM exam_subject_song WHERE examination_basic_id_=#{examinationBasicId} AND exam_subject_id_ = #{examSubjectId} AND level_ = #{level}
  125. </select>
  126. <select id="getExamSubjectLevels" resultMap="ExamSubjectSong">
  127. SELECT * FROM exam_subject_song WHERE examination_basic_id_=#{examinationBasicId} AND exam_subject_id_ = #{examSubjectId} ORDER BY level_ ASC
  128. </select>
  129. </mapper>