OrganizationCourseUnitPriceSettingsMapper.xml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. <mapper namespace="com.ym.mec.biz.dal.dao.OrganizationCourseUnitPriceSettingsDao">
  5. <resultMap type="com.ym.mec.biz.dal.entity.OrganizationCourseUnitPriceSettings" id="OrganizationCourseUnitPriceSettings">
  6. <result column="id_" property="id" />
  7. <result column="organ_id_" property="organId" />
  8. <result column="course_type_" property="courseType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler" />
  9. <result column="charge_type_id_" property="chargeTypeId" />
  10. <result column="unit_price_" property="unitPrice" />
  11. <result column="create_time_" property="createTime" />
  12. <result column="update_time_" property="updateTime" />
  13. <result column="organ_name_" property="organ.name" />
  14. <result column="charge_type_name_" property="chargeType.name" />
  15. </resultMap>
  16. <!-- 根据主键查询一条记录 -->
  17. <select id="get" resultMap="OrganizationCourseUnitPriceSettings">
  18. SELECT * FROM organization_course_unit_price_settings WHERE id_ = #{id}
  19. </select>
  20. <!-- 全查询 -->
  21. <select id="findAll" resultMap="OrganizationCourseUnitPriceSettings">
  22. SELECT * FROM organization_course_unit_price_settings ORDER BY id_
  23. </select>
  24. <!-- 向数据库增加一条记录 -->
  25. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.OrganizationCourseUnitPriceSettings" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  26. <!-- <selectKey resultClass="int" keyProperty="id" > SELECT SEQ_WSDEFINITION_ID.nextval
  27. AS ID FROM DUAL </selectKey> -->
  28. INSERT INTO organization_course_unit_price_settings
  29. (id_,organ_id_,course_type_,charge_type_id_,unit_price_,create_time_,update_time_)
  30. VALUES(#{id},#{organId},#{courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{chargeTypeId},#{unitPrice},now(),now())
  31. </insert>
  32. <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  33. INSERT INTO organization_course_unit_price_settings
  34. (id_,organ_id_,course_type_,charge_type_id_,unit_price_,create_time_,update_time_)
  35. VALUES
  36. <foreach collection="list" item="item" separator=",">
  37. (#{item.id},#{item.organId},#{item.courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{item.chargeTypeId},#{item.unitPrice},now(),now())
  38. </foreach>
  39. </insert>
  40. <!-- 根据主键查询一条记录 -->
  41. <update id="update" parameterType="com.ym.mec.biz.dal.entity.OrganizationCourseUnitPriceSettings">
  42. UPDATE organization_course_unit_price_settings
  43. <set>
  44. <if test="organId != null">
  45. organ_id_ = #{organId},
  46. </if>
  47. <if test="id != null">
  48. id_ = #{id},
  49. </if>
  50. <if test="updateTime != null">
  51. update_time_ = #{updateTime},
  52. </if>
  53. <if test="courseType != null">
  54. course_type_ = #{courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  55. </if>
  56. <if test="chargeTypeId != null">
  57. charge_type_id_ = #{chargeTypeId},
  58. </if>
  59. <if test="unitPrice != null">
  60. unit_price_ = #{unitPrice},
  61. </if>
  62. <if test="createTime != null">
  63. create_time_ = #{createTime},
  64. </if>
  65. </set>
  66. WHERE id_ = #{id}
  67. </update>
  68. <!-- 根据主键删除一条记录 -->
  69. <delete id="delete">
  70. DELETE FROM organization_course_unit_price_settings WHERE id_ = #{id}
  71. </delete>
  72. <!-- 分页查询 -->
  73. <select id="queryPage" resultMap="OrganizationCourseUnitPriceSettings" parameterType="map">
  74. SELECT ups.*,o.name_ organ_name_ ,ct.name_ charge_type_name_ FROM organization_course_unit_price_settings ups left join organization o on ups.organ_id_ = o.id_
  75. left join charge_type ct on ct.id_ = ups.charge_type_id_
  76. <where>
  77. <if test="organId != null">
  78. and ups.organ_id_ = #{organId}
  79. </if>
  80. <if test="courseScheduleType != null">
  81. and ups.course_type_ = #{courseScheduleType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  82. </if>
  83. <if test="chargeTypeId != null">
  84. and ups.charge_type_id_ = #{chargeTypeId}
  85. </if>
  86. </where>
  87. ORDER BY ups.id_ desc
  88. <include refid="global.limit" />
  89. </select>
  90. <!-- 查询当前表的总记录数 -->
  91. <select id="queryCount" resultType="int">
  92. SELECT COUNT(ups.id_) FROM organization_course_unit_price_settings ups
  93. <where>
  94. <if test="organId != null">
  95. and ups.organ_id_ = #{organId}
  96. </if>
  97. <if test="courseScheduleType != null">
  98. and ups.course_type_ = #{courseScheduleType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  99. </if>
  100. <if test="chargeTypeId != null">
  101. and ups.charge_type_id_ = #{chargeTypeId}
  102. </if>
  103. </where>
  104. </select>
  105. <select id="queryByOrganIdAndCourseTypeAndChargeType" resultMap="OrganizationCourseUnitPriceSettings" parameterType="map">
  106. SELECT * FROM organization_course_unit_price_settings WHERE organ_id_ = #{organId} and course_type_ = #{courseScheduleType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  107. and charge_type_id_ = #{chargeTypeId}
  108. </select>
  109. <select id="queryMapByOrganIdAndChargeTypeId" resultType="java.util.Map">
  110. SELECT course_type_ 'key',MAX(unit_price_)'value' FROM organization_course_unit_price_settings
  111. WHERE organ_id_ = #{organId} AND charge_type_id_ = #{chargeTypeId}
  112. GROUP BY course_type_
  113. </select>
  114. </mapper>