ExamSongMapper.xml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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.ExamSongDao">
  8. <resultMap type="com.keao.edu.user.entity.ExamSong" id="ExamSong">
  9. <result column="id_" property="id" />
  10. <result column="song_name_" property="songName" />
  11. <result column="song_author_" property="songAuthor" />
  12. <result column="subject_list_" property="subjectList" />
  13. <result column="subject_names_" property="subjectNames" />
  14. <result column="level_list_" property="levelList" />
  15. <result column="type_" property="type" typeHandler="com.keao.edu.common.dal.CustomEnumTypeHandler"/>
  16. <result column="file_url_list_" property="fileUrlList" />
  17. <result column="create_time_" property="createTime" />
  18. <result column="update_time_" property="updateTime" />
  19. <result column="tenant_id_" property="tenantId" />
  20. </resultMap>
  21. <!-- 根据主键查询一条记录 -->
  22. <select id="get" resultMap="ExamSong" >
  23. SELECT * FROM exam_song WHERE id_ = #{id}
  24. </select>
  25. <!-- 全查询 -->
  26. <select id="findAll" resultMap="ExamSong">
  27. SELECT * FROM exam_song WHERE tenant_id_ = #{tenantId} ORDER BY id_
  28. </select>
  29. <!-- 向数据库增加一条记录 -->
  30. <insert id="insert" parameterType="com.keao.edu.user.entity.ExamSong" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  31. INSERT INTO exam_song (id_,song_name_,song_author_,subject_list_,level_list_,type_,file_url_list_,create_time_,update_time_,tenant_id_)
  32. VALUES(#{id},#{songName},#{songAuthor},#{subjectList},#{levelList},#{type, typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{fileUrlList},NOW(),NOW(),#{tenantId})
  33. </insert>
  34. <!-- 根据主键查询一条记录 -->
  35. <update id="update" parameterType="com.keao.edu.user.entity.ExamSong">
  36. UPDATE exam_song
  37. <set>
  38. <if test="levelList != null">
  39. level_list_ = #{levelList},
  40. </if>
  41. <if test="subjectList != null">
  42. subject_list_ = #{subjectList},
  43. </if>
  44. <if test="fileUrlList != null">
  45. file_url_list_ = #{fileUrlList},
  46. </if>
  47. <if test="songAuthor != null">
  48. song_author_ = #{songAuthor},
  49. </if>
  50. <if test="type != null">
  51. type_ = #{type, typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  52. </if>
  53. <if test="songName != null">
  54. song_name_ = #{songName},
  55. </if>
  56. <if test="delFlag != null">
  57. del_flag_ = #{delFlag}
  58. </if>
  59. <if test="tenantId">
  60. tenant_id_ = #{tenantId},
  61. </if>
  62. update_time_ = NOW()
  63. </set> WHERE id_ = #{id}
  64. </update>
  65. <!-- 根据主键删除一条记录 -->
  66. <update id="delete" >
  67. UPDATE exam_song SET del_flag_=1 WHERE id_ = #{id}
  68. </update>
  69. <sql id="queryCondition">
  70. <where>
  71. es.del_flag_=0 AND es.tenant_id_ = #{tenantId}
  72. <if test="subjectList!=null">
  73. AND FIND_IN_SET(#{subjectList}, es.subject_list_)
  74. </if>
  75. <if test="search!=null">
  76. AND (es.id_=#{search} OR es.song_name_ LIKE CONCAT('%', #{search}, '%'))
  77. </if>
  78. </where>
  79. </sql>
  80. <!-- 分页查询 -->
  81. <select id="queryPage" resultMap="ExamSong" parameterType="map">
  82. SELECT es.*,GROUP_CONCAT(s.name_) subject_names_ FROM exam_song es
  83. LEFT JOIN subject s ON FIND_IN_SET(s.id_, es.subject_list_)
  84. <include refid="queryCondition"/>
  85. GROUP BY es.id_
  86. ORDER BY id_
  87. <include refid="global.limit"/>
  88. </select>
  89. <!-- 查询当前表的总记录数 -->
  90. <select id="queryCount" resultType="int">
  91. SELECT COUNT(*) FROM exam_song es
  92. <include refid="queryCondition"/>
  93. </select>
  94. <select id="getExamSongs" resultMap="ExamSong">
  95. SELECT * FROM exam_song WHERE FIND_IN_SET(id_,#{ids})
  96. </select>
  97. <select id="getWithSubject" resultMap="ExamSong">
  98. SELECT * FROM exam_song WHERE FIND_IN_SET(#{subjectId}, subject_list_)
  99. </select>
  100. <select id="getWithLevelAndType" resultMap="ExamSong">
  101. SELECT * FROM exam_song
  102. WHERE tenant_id_=#{tenantId}
  103. AND level_list_=#{level}
  104. AND type_=#{songType, typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler}
  105. </select>
  106. <select id="countSongPage" resultType="java.lang.Integer">
  107. </select>
  108. <select id="querySongPage" resultMap="ExamSong">
  109. </select>
  110. <select id="getWithIds" resultMap="ExamSong">
  111. SELECT * FROM exam_song WHERE id_ IN
  112. <foreach collection="ids" item="id" separator="," open="(" close=")">
  113. #{id}
  114. </foreach>
  115. </select>
  116. </mapper>