OrganizationCourseUnitPriceSettingsMapper.xml 5.5 KB

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