MusicGroupSubjectPlanMapper.xml 6.4 KB

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