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