SysExamSongMapper.xml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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.SysExamSongDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.SysExamSong" id="SysExamSong">
  9. <result column="id_" property="id" />
  10. <result column="name_" property="name" />
  11. <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  12. <result column="subject_ids_" property="subjectIds" />
  13. <result column="subject_names_" property="subjectNames" />
  14. <result column="speed_" property="speed" />
  15. <result column="url_" property="url" />
  16. <result column="create_user_id_" property="createUserId" />
  17. <result column="create_user_name_" property="createUserName" />
  18. <result column="del_flag_" property="delFlag" />
  19. <result column="update_time_" property="updateTime" />
  20. <result column="create_time_" property="createTime" />
  21. </resultMap>
  22. <!-- 根据主键查询一条记录 -->
  23. <select id="get" resultMap="SysExamSong" >
  24. SELECT * FROM sys_exam_song WHERE id_ = #{id}
  25. </select>
  26. <!-- 全查询 -->
  27. <select id="findAll" resultMap="SysExamSong">
  28. SELECT * FROM sys_exam_song ORDER BY id_
  29. </select>
  30. <!-- 向数据库增加一条记录 -->
  31. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.SysExamSong" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  32. INSERT INTO sys_exam_song (name_,type_,subject_ids_,speed_,url_,create_user_id_,update_time_,create_time_)
  33. VALUES(#{name},#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{subjectIds},#{speed},#{url},#{createUserId},NOW(),NOW())
  34. </insert>
  35. <!-- 根据主键查询一条记录 -->
  36. <update id="update" parameterType="com.ym.mec.biz.dal.entity.SysExamSong">
  37. UPDATE sys_exam_song
  38. <set>
  39. <if test="delFlag != null">
  40. del_flag_ = #{delFlag},
  41. </if>
  42. <if test="createUserId != null">
  43. create_user_id_ = #{createUserId},
  44. </if>
  45. <if test="url != null and url != ''">
  46. url_ = #{url},
  47. </if>
  48. <if test="subjectIds != null and subjectIds != ''">
  49. subject_ids_ = #{subjectIds},
  50. </if>
  51. <if test="type != null">
  52. type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  53. </if>
  54. <if test="name != null and name != ''">
  55. name_ = #{name},
  56. </if>
  57. <if test="speed != null">
  58. speed_ = #{speed},
  59. </if>
  60. update_time_ = NOW()
  61. </set>
  62. WHERE id_ = #{id}
  63. </update>
  64. <!-- 根据主键删除一条记录 -->
  65. <update id="delete" >
  66. UPDATE sys_exam_song SET del_flag_ = 1 WHERE id_ = #{id}
  67. </update>
  68. <sql id="queryPageSql">
  69. <where>
  70. ses.del_flag_ = 0
  71. <if test="search != null and search != ''">
  72. AND (ses.id_ = #{search} OR ses.name_ LIKE CONCAT('%',#{search},'%'))
  73. </if>
  74. <if test="type != null and type == 'COMMON'">
  75. AND ses.type_ = #{type}
  76. </if>
  77. <if test="type != null and type == 'ALL'">
  78. <if test="createUserId != null">
  79. AND (ses.type_ = 'COMMON' OR (ses.create_user_id_ = #{createUserId} AND ses.type_ = 'PERSON'))
  80. </if>
  81. </if>
  82. <if test="type != null and type == 'PERSON'">
  83. <if test="createUserId != null">
  84. AND ses.type_ = #{type} AND ses.create_user_id_ = #{createUserId}
  85. </if>
  86. <if test="createUserId == null">
  87. AND ses.type_ = #{type}
  88. </if>
  89. </if>
  90. <if test="type == null or type == ''">
  91. <if test="createUserId != null">
  92. AND ses.create_user_id_ = #{createUserId}
  93. </if>
  94. </if>
  95. <if test="subjectId != null">
  96. AND FIND_IN_SET(#{subjectId},ses.subject_ids_)
  97. </if>
  98. </where>
  99. </sql>
  100. <!-- 分页查询 -->
  101. <select id="queryPage" resultMap="SysExamSong" parameterType="map">
  102. SELECT ses.*,GROUP_CONCAT(s.name_) subject_names_,su.real_name_ create_user_name_ FROM sys_exam_song ses
  103. LEFT JOIN sys_user su ON ses.create_user_id_ = su.id_
  104. LEFT JOIN `subject` s ON FIND_IN_SET(s.id_,ses.subject_ids_)
  105. <include refid="queryPageSql"/>
  106. GROUP BY ses.id_
  107. ORDER BY ses.id_ DESC
  108. <include refid="global.limit"/>
  109. </select>
  110. <!-- 查询当前表的总记录数 -->
  111. <select id="queryCount" resultType="int">
  112. SELECT COUNT(0) FROM sys_exam_song ses
  113. <include refid="queryPageSql"/>
  114. </select>
  115. </mapper>