MultiOwnerMapper.xml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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, op_create_time, op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user
  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. <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
  19. <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
  20. <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
  21. <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
  22. <result column="op_app_code" property="opAppCode"/>
  23. <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
  24. <result column="op_db_user" property="opDbUser"/>
  25. </resultMap>
  26. <!-- 通用条件列 -->
  27. <sql id="Condition">
  28. <where>
  29. <if test="orderId != null and orderId != ''">
  30. AND order_id = #{orderId}
  31. </if>
  32. <if test="ownerType != null and ownerType != ''">
  33. AND owner_type = #{ownerType}
  34. </if>
  35. <if test="ownerId != null and ownerId != ''">
  36. AND owner_id = #{ownerId}
  37. </if>
  38. <if test="allocationRatio != null">
  39. AND allocation_ratio = #{allocationRatio}
  40. </if>
  41. <if test="flgValid != null">
  42. AND flg_valid = #{flgValid}
  43. </if>
  44. <if test="cpId != null">
  45. AND cp_id = #{cpId}
  46. </if>
  47. <if test="opCreateTime != null">
  48. AND op_create_time = #{opCreateTime}
  49. </if>
  50. <if test="opCreateUserId != null and opCreateUserId != ''">
  51. AND op_create_user_id = #{opCreateUserId}
  52. </if>
  53. <if test="opUpdateTime != null">
  54. AND op_update_time = #{opUpdateTime}
  55. </if>
  56. <if test="opUpdateUserId != null and opUpdateUserId != ''">
  57. AND op_update_user_id = #{opUpdateUserId}
  58. </if>
  59. <if test="opAppCode != null and opAppCode != ''">
  60. AND op_app_code = #{opAppCode}
  61. </if>
  62. <if test="opTimestamp != null">
  63. AND op_timestamp = #{opTimestamp}
  64. </if>
  65. <if test="opDbUser != null and opDbUser != ''">
  66. AND op_db_user = #{opDbUser}
  67. </if>
  68. </where>
  69. </sql>
  70. <sql id="idsForeach">
  71. <!-- 根据主键multiId批量操作 -->
  72. WHERE multi_id in
  73. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  74. #{item}
  75. </foreach>
  76. </sql>
  77. <!-- 查询表t_psi_multi_owner,(条件查询+分页)列表 -->
  78. <select id="selectByCond" resultMap="BaseResultMap">
  79. SELECT
  80. <include refid="Base_Column_List"/>
  81. FROM t_psi_multi_owner
  82. <include refid="Condition"/>
  83. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  84. limit #{end} offset #{start}
  85. </if>
  86. </select>
  87. <!-- 查询表t_psi_multi_owner,(条件查询)个数 -->
  88. <select id="countByCond" resultType="Long">
  89. SELECT
  90. count(1)
  91. FROM t_psi_multi_owner
  92. <include refid="Condition"/>
  93. </select>
  94. <!-- 根据主键查询表t_psi_multi_owner的一行数据 -->
  95. <select id="selectById" resultMap="BaseResultMap">
  96. SELECT
  97. <include refid="Base_Column_List"/>
  98. FROM t_psi_multi_owner
  99. WHERE multi_id = #{multiId}::uuid
  100. </select>
  101. <!-- 根据主键锁定表t_psi_multi_owner的一行数据 -->
  102. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  103. SELECT
  104. <include refid="Base_Column_List"/>
  105. FROM t_psi_multi_owner
  106. WHERE multi_id = #{id}::uuid
  107. for update
  108. </select>
  109. <!-- 根据主键锁定表t_psi_multi_owner的多行数据 -->
  110. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  111. SELECT
  112. <include refid="Base_Column_List"/>
  113. FROM t_psi_multi_owner
  114. <include refid="idsForeach"/>
  115. for update
  116. </select>
  117. <insert id="insertBatch">
  118. insert into t_psi_multi_owner
  119. (
  120. <trim suffixOverrides=",">
  121. order_id,
  122. owner_type,
  123. owner_id,
  124. allocation_ratio,
  125. cp_id,
  126. op_app_code,
  127. </trim>
  128. )
  129. values
  130. <foreach collection="list" index="index" item="item" separator=",">
  131. (
  132. <trim suffixOverrides=",">
  133. #{item.orderId}::uuid,
  134. #{item.ownerType},
  135. #{item.ownerId}::uuid,
  136. #{item.allocationRatio},
  137. #{item.cpId},
  138. #{item.opAppCode},
  139. </trim>
  140. )
  141. </foreach>
  142. </insert>
  143. </mapper>