ExamAgencyRelationMapper.xml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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.keao.edu.user.dao.ExamAgencyRelationDao">
  8. <resultMap type="com.keao.edu.user.entity.ExamAgencyRelation" id="ExamAgencyRelation">
  9. <result column="id_" property="id" />
  10. <result column="examination_basic_id_" property="examinationBasicId" />
  11. <result column="agency_id_" property="agencyId" />
  12. <result column="settlement_type_" property="settlementType" typeHandler="com.keao.edu.common.dal.CustomEnumTypeHandler" />
  13. <result column="share_profit_amount_" property="shareProfitAmount" />
  14. <result column="total_registration_student_num_" property="totalRegistrationStudentNum"/>
  15. <result column="total_payment_amount_" property="totalPaymentAmount"/>
  16. <result column="url_" property="url" />
  17. <result column="send_url_flag_" property="sendUrlFlag" typeHandler="com.keao.edu.common.dal.CustomEnumTypeHandler" />
  18. <result column="create_time_" property="createTime" />
  19. <result column="update_time_" property="updateTime" />
  20. <result column="tenant_id_" property="tenantId" />
  21. </resultMap>
  22. <resultMap id="ExamAgencyRelationExtraDto" type="com.keao.edu.user.dto.ExamAgencyRelationExtraDto" extends="ExamAgencyRelation">
  23. <result column="agency_name_" property="agencyName"/>
  24. </resultMap>
  25. <!-- 根据主键查询一条记录 -->
  26. <select id="get" resultMap="ExamAgencyRelation" >
  27. SELECT * FROM exam_agency_relation WHERE id_ = #{id}
  28. </select>
  29. <!-- 全查询 -->
  30. <select id="findAll" resultMap="ExamAgencyRelation">
  31. SELECT * FROM exam_agency_relation WHERE tenant_id_#{tenantId} ORDER BY id_
  32. </select>
  33. <!-- 向数据库增加一条记录 -->
  34. <insert id="insert" parameterType="com.keao.edu.user.entity.ExamAgencyRelation" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  35. INSERT INTO exam_agency_relation (examination_basic_id_,agency_id_,settlement_type_,share_profit_amount_,total_registration_student_num_,total_payment_amount_,url_,send_url_flag_,create_time_,update_time_,tenant_id_)
  36. VALUES(#{examinationBasicId},#{agencyId},#{settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{shareProfitAmount},#{totalRegistrationStudentNum},#{totalPaymentAmount},#{url},#{sendUrlFlag,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},NOW(),NOW(),#{tenantId})
  37. </insert>
  38. <insert id="batchInsert" parameterType="com.keao.edu.user.entity.ExamAgencyRelation" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  39. INSERT INTO exam_agency_relation (examination_basic_id_,agency_id_,settlement_type_,share_profit_amount_,total_registration_student_num_,total_payment_amount_,url_,send_url_flag_,create_time_,update_time_,tenant_id_)
  40. VALUES
  41. <foreach collection="examAgencyRelations" item="examAgencyRelation" separator=",">
  42. (#{examAgencyRelation.examinationBasicId},#{examAgencyRelation.agencyId},#{examAgencyRelation.settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{examAgencyRelation.shareProfitAmount},#{examAgencyRelation.totalRegistrationStudentNum},#{examAgencyRelation.totalPaymentAmount},#{examAgencyRelation.url},#{examAgencyRelation.sendUrlFlag,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},NOW(),NOW(),#{examAgencyRelation.tenantId})
  43. </foreach>
  44. </insert>
  45. <!-- 根据主键查询一条记录 -->
  46. <update id="update" parameterType="com.keao.edu.user.entity.ExamAgencyRelation">
  47. UPDATE exam_agency_relation
  48. <set>
  49. <if test="examinationBasicId != null">
  50. examination_basic_id_ = #{examinationBasicId},
  51. </if>
  52. <if test="id != null">
  53. id_ = #{id},
  54. </if>
  55. <if test="sendUrlFlag != null">
  56. send_url_flag_ = #{sendUrlFlag,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  57. </if>
  58. <if test="url != null">
  59. url_ = #{url},
  60. </if>
  61. <if test="tenantId != null">
  62. tenant_id_ = #{tenantId},
  63. </if>
  64. <if test="updateTime != null">
  65. update_time_ = #{updateTime},
  66. </if>
  67. <if test="shareProfitAmount != null">
  68. share_profit_amount_ = #{shareProfitAmount},
  69. </if>
  70. <if test="totalRegistrationStudentNum != null">
  71. total_registration_student_num_ = #{totalRegistrationStudentNum},
  72. </if>
  73. <if test="totalPaymentAmount != null">
  74. total_payment_amount_ = #{totalPaymentAmount},
  75. </if>
  76. <if test="agencyId != null">
  77. agency_id_ = #{agencyId},
  78. </if>
  79. <if test="settlementType != null">
  80. settlement_type_ = #{settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  81. </if>
  82. <if test="createTime != null">
  83. create_time_ = #{createTime},
  84. </if>
  85. </set> WHERE id_ = #{id}
  86. </update>
  87. <update id="batchUpdateSendUrlFlag">
  88. UPDATE exam_agency_relation SET send_url_flag_=#{sendUrlFlag,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler}
  89. WHERE examination_basic_id_=#{examId} AND agency_id_ IN
  90. <foreach collection="agencyIds" item="agencyId" separator="," open="(" close=")">
  91. #{agencyId}
  92. </foreach>
  93. </update>
  94. <!-- 根据主键删除一条记录 -->
  95. <delete id="delete" >
  96. DELETE FROM exam_agency_relation WHERE id_ = #{id}
  97. </delete>
  98. <sql id="queryCondition">
  99. <where>
  100. ear.tenant_id_=#{tenantId}
  101. <if test="settlementType!=null">
  102. AND ear.settlement_type_=#{settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler}
  103. </if>
  104. <if test="search!=null">
  105. AND (ear.agency_id_=#{agencyId} OR a.name_ LIKE CONCAT(#{search}, '%'))
  106. </if>
  107. </where>
  108. </sql>
  109. <!-- 分页查询 -->
  110. <select id="queryPage" resultMap="ExamAgencyRelationExtraDto" parameterType="map">
  111. SELECT
  112. ear.*,
  113. a.name_ agency_name_
  114. FROM agency a
  115. LEFT JOIN exam_agency_relation ear ON ear.agency_id_=a.id_
  116. <if test="examId!=null">
  117. AND ear.examination_basic_id_=#{examId}
  118. </if>
  119. <include refid="queryCondition"/>
  120. ORDER BY id_ <include refid="global.limit"/>
  121. </select>
  122. <!-- 查询当前表的总记录数 -->
  123. <select id="queryCount" resultType="int">
  124. SELECT COUNT(*) FROM agency a
  125. LEFT JOIN exam_agency_relation ear ON ear.agency_id_=a.id_
  126. <if test="examId!=null">
  127. AND ear.examination_basic_id_=#{examId}
  128. </if>
  129. <include refid="queryCondition"/>
  130. </select>
  131. <select id="getWithExam" resultMap="ExamAgencyRelation">
  132. SELECT * FROM exam_agency_relation WHERE examination_basic_id_=#{examId}
  133. </select>
  134. <select id="getAgencyIdsWithExam" resultType="int">
  135. SELECT agency_id_ FROM exam_agency_relation WHERE examination_basic_id_=#{examId} FOR UPDATE
  136. </select>
  137. </mapper>