MusicGroupSubjectPlanMapper.xml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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.MusicGroupSubjectPlanDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.MusicGroupSubjectPlan" id="MusicGroupSubjectPlan">
  9. <result column="id_" property="id"/>
  10. <result column="music_group_id_" property="musicGroupId"/>
  11. <result column="subject_id_" property="subjectId"/>
  12. <result column="expected_student_num_" property="expectedStudentNum"/>
  13. <result column="apply_student_num_" property="applyStudentNum"/>
  14. <result column="paid_student_num_" property="paidStudentNum"/>
  15. <result column="paid_zero_num_" property="paidZeroNum"/>
  16. <result column="fee_" property="fee"/>
  17. <result column="kit_group_purchase_type_" property="kitGroupPurchaseType"
  18. typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  19. <result column="deposit_fee_" property="depositFee"/>
  20. <result column="create_time_" property="createTime"/>
  21. <result column="update_time_" property="updateTime"/>
  22. <result column="version" property="version"/>
  23. <result column="sub_name_" property="subName"/>
  24. </resultMap>
  25. <!-- 根据主键查询一条记录 -->
  26. <select id="get" resultMap="MusicGroupSubjectPlan">
  27. SELECT * FROM music_group_subject_plan WHERE id_ = #{id}
  28. </select>
  29. <!-- 全查询 -->
  30. <select id="findAll" resultMap="MusicGroupSubjectPlan">
  31. SELECT *
  32. FROM music_group_subject_plan
  33. ORDER BY id_
  34. </select>
  35. <!-- 向数据库增加一条记录 -->
  36. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupSubjectPlan" useGeneratedKeys="true"
  37. keyColumn="id" keyProperty="id">
  38. INSERT INTO music_group_subject_plan
  39. (id_,music_group_id_,subject_id_,expected_student_num_,apply_student_num_,fee_,kit_group_purchase_type_,deposit_fee_,create_time_,update_time_)
  40. VALUES(#{id},#{musicGroupId},#{subjectId},#{expectedStudentNum},#{applyStudentNum},#{fee},#{kitGroupPurchaseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{depositFee},now(),now())
  41. </insert>
  42. <insert id="batchAdd">
  43. INSERT INTO music_group_subject_plan
  44. (music_group_id_,subject_id_,expected_student_num_,fee_,kit_group_purchase_type_,deposit_fee_,create_time_,update_time_)
  45. VALUES
  46. <foreach collection="subjectPlans" item="item" separator=",">
  47. (#{musicGroupId},#{item.subjectId},#{item.expectedStudentNum},#{item.fee},#{item.kitGroupPurchaseType},
  48. #{item.depositFee},now(),now())
  49. </foreach>
  50. </insert>
  51. <!-- 根据主键查询一条记录 -->
  52. <update id="update" parameterType="com.ym.mec.biz.dal.entity.MusicGroupSubjectPlan">
  53. UPDATE music_group_subject_plan
  54. <set>
  55. <if test="musicGroupId != null">
  56. music_group_id_ = #{musicGroupId},
  57. </if>
  58. <if test="subjectId != null">
  59. subject_id_ = #{subjectId},
  60. </if>
  61. <if test="expectedStudentNum != null">
  62. expected_student_num_ = #{expectedStudentNum},
  63. </if>
  64. <if test="applyStudentNum != null">
  65. apply_student_num_ = #{applyStudentNum},
  66. </if>
  67. <if test="fee != null">
  68. fee_ = #{fee},
  69. </if>
  70. <if test="kitGroupPurchaseType != null">
  71. kit_group_purchase_type_ =
  72. #{kitGroupPurchaseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  73. </if>
  74. <if test="depositFee != null">
  75. deposit_fee_ = #{depositFee},
  76. </if>
  77. <if test="paidStudentNum != null">
  78. paid_student_num_ = #{paidStudentNum},
  79. </if>
  80. <if test="paidZeroNum != null">
  81. paid_zero_num_ = #{paidZeroNum},
  82. </if>
  83. <if test="updateTime != null">
  84. update_time_ = NOW(),
  85. </if>
  86. <if test="version != null">
  87. version = version+1,
  88. </if>
  89. </set>
  90. WHERE id_ = #{id} AND version =#{version}
  91. </update>
  92. <update id="updateExpectedStudentNum">
  93. UPDATE music_group_subject_plan SET expected_student_num_ = #{expectedStudentNum},update_time_ = now() WHERE id_ = #{musicGroupSubjectPlanId}
  94. </update>
  95. <update id="batchUpdateFee" parameterType="java.util.List">
  96. <foreach collection="plans" item="item" index="index" open="" close="" separator=";">
  97. UPDATE music_group_subject_plan
  98. <set>
  99. fee_ = #{item.fee},update_time_ = now()
  100. </set>
  101. <where>
  102. id_ = #{item.id}
  103. </where>
  104. </foreach>
  105. </update>
  106. <!-- 根据主键删除一条记录 -->
  107. <delete id="delete">
  108. DELETE FROM music_group_subject_plan WHERE id_ = #{id}
  109. </delete>
  110. <delete id="delByMusicGroupId">
  111. DELETE FROM music_group_subject_plan WHERE music_group_id_=#{musicGroupId}
  112. </delete>
  113. <!-- 分页查询 -->
  114. <select id="queryPage" resultMap="MusicGroupSubjectPlan" parameterType="map">
  115. SELECT * FROM music_group_subject_plan ORDER BY id_
  116. <include refid="global.limit"/>
  117. </select>
  118. <!-- 查询当前表的总记录数 -->
  119. <select id="queryCount" resultType="int">
  120. SELECT COUNT(*)
  121. FROM music_group_subject_plan
  122. </select>
  123. <!-- 查询乐团科目计划表 -->
  124. <select id="getMusicSubjectClassPlan" resultMap="MusicGroupSubjectPlan">
  125. SELECT sp.*, sb.name_ sub_name_
  126. FROM music_group_subject_plan sp
  127. LEFT JOIN subject sb ON sb.id_ = sp.subject_id_
  128. WHERE sp.music_group_id_=#{musicGroupId}
  129. </select>
  130. <select id="getMusicOneSubjectClassPlan" resultMap="MusicGroupSubjectPlan">
  131. SELECT sp.*, sb.name_
  132. FROM music_group_subject_plan sp
  133. LEFT JOIN subject sb ON sb.id_ = sp.subject_id_
  134. WHERE sp.music_group_id_=#{musicGroupId} AND sp.subject_id_=#{subjectId}
  135. </select>
  136. <select id="findSubjectPlan" resultMap="MusicGroupSubjectPlan">
  137. SELECT * FROM music_group_subject_plan WHERE music_group_id_ = #{musicGroupId} AND subject_id_ = #{subjectId} LIMIT 1
  138. </select>
  139. <select id="findSubjectMap" resultType="java.util.Map">
  140. SELECT subject_id_ 'key',kit_group_purchase_type_ 'value' FROM music_group_subject_plan mgsp
  141. WHERE mgsp.music_group_id_ = #{musicGroupId} AND subject_id_ IN
  142. <foreach collection="subjectIds" open="(" close=")" item="item" separator=",">
  143. #{item}
  144. </foreach>
  145. </select>
  146. </mapper>