MultiOwnerMapper.xml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. <mapper namespace="com.dk.mdm.mapper.sale.MultiOwnerMapper">
  4. <!-- 通用设置 -->
  5. <!-- 通用查询列 -->
  6. <sql id="Base_Column_List">
  7. multi_id, order_id, owner_type, owner_id, allocation_ratio, flg_valid, cp_id
  8. </sql>
  9. <!-- 通用查询映射结果 -->
  10. <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.sale.MultiOwner">
  11. <id column="multi_id" property="multiId"/>
  12. <result column="order_id" property="orderId" typeHandler="UuidTypeHandler"/>
  13. <result column="owner_type" property="ownerType"/>
  14. <result column="owner_id" property="ownerId" typeHandler="UuidTypeHandler"/>
  15. <result column="allocation_ratio" property="allocationRatio"/>
  16. <result column="flg_valid" property="flgValid"/>
  17. <result column="cp_id" property="cpId"/>
  18. </resultMap>
  19. <!-- 通用条件列 -->
  20. <sql id="Condition">
  21. <where>
  22. <if test="orderId != null and orderId != ''">
  23. AND order_id = #{orderId}
  24. </if>
  25. <if test="ownerType != null and ownerType != ''">
  26. AND owner_type = #{ownerType}
  27. </if>
  28. <if test="ownerId != null and ownerId != ''">
  29. AND owner_id = #{ownerId}
  30. </if>
  31. <if test="allocationRatio != null">
  32. AND allocation_ratio = #{allocationRatio}
  33. </if>
  34. <if test="flgValid != null">
  35. AND flg_valid = #{flgValid}
  36. </if>
  37. <if test="cpId != null">
  38. AND cp_id = #{cpId}
  39. </if>
  40. </where>
  41. </sql>
  42. <sql id="idsForeach">
  43. <!-- 根据主键multiId批量操作 -->
  44. WHERE multi_id in
  45. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  46. #{item}
  47. </foreach>
  48. </sql>
  49. <!-- 查询表t_psi_multi_owner,(条件查询+分页)列表 -->
  50. <select id="selectByCond" resultMap="BaseResultMap">
  51. SELECT
  52. <include refid="Base_Column_List"/>
  53. FROM dkic_b.t_psi_multi_owner
  54. <include refid="Condition"/>
  55. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  56. limit #{end} offset #{start}
  57. </if>
  58. </select>
  59. <!-- 查询表t_psi_multi_owner,(条件查询)个数 -->
  60. <select id="countByCond" resultType="Long">
  61. SELECT
  62. count(1)
  63. FROM dkic_b.t_psi_multi_owner
  64. <include refid="Condition"/>
  65. </select>
  66. <!-- 根据主键查询表t_psi_multi_owner的一行数据 -->
  67. <select id="selectById" resultMap="BaseResultMap">
  68. SELECT
  69. <include refid="Base_Column_List"/>
  70. FROM dkic_b.t_psi_multi_owner
  71. WHERE multi_id = #{id}::uuid
  72. </select>
  73. <!-- 根据主键锁定表t_psi_multi_owner的一行数据 -->
  74. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  75. SELECT
  76. <include refid="Base_Column_List"/>
  77. FROM dkic_b.t_psi_multi_owner
  78. WHERE multi_id = #{id}::uuid
  79. for update
  80. </select>
  81. <!-- 根据主键锁定表t_psi_multi_owner的多行数据 -->
  82. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  83. SELECT
  84. <include refid="Base_Column_List"/>
  85. FROM dkic_b.t_psi_multi_owner
  86. <include refid="idsForeach"/>
  87. for update
  88. </select>
  89. <insert id="insertBatch">
  90. insert into dkic_b.t_psi_multi_owner
  91. (
  92. <trim suffixOverrides=",">
  93. order_id,
  94. owner_type,
  95. owner_id,
  96. allocation_ratio,
  97. cp_id,
  98. op_app_code,
  99. </trim>
  100. )
  101. values
  102. <foreach collection="list" index="index" item="item" separator=",">
  103. (
  104. <trim suffixOverrides=",">
  105. #{item.orderId}::uuid,
  106. #{item.ownerType},
  107. #{item.ownerId}::uuid,
  108. #{item.allocationRatio},
  109. #{item.cpId},
  110. #{item.opAppCode},
  111. </trim>
  112. )
  113. </foreach>
  114. </insert>
  115. <delete id="deleteByOrderId">
  116. DELETE FROM dkic_b.t_psi_multi_owner WHERE order_id = #{orderId}::uuid
  117. </delete>
  118. </mapper>