SaleChannelMapper.xml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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.mst.SaleChannelMapper">
  4. <!-- 通用设置 -->
  5. <!-- 通用查询列 -->
  6. <sql id="Base_Column_List">
  7. channel_id, channel_code, channel_name, sys_code, display_no, remarks, 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.mst.SaleChannel">
  11. <id column="channel_id" property="channelId"/>
  12. <result column="channel_code" property="channelCode"/>
  13. <result column="channel_name" property="channelName"/>
  14. <result column="sys_code" property="sysCode"/>
  15. <result column="display_no" property="displayNo"/>
  16. <result column="remarks" property="remarks"/>
  17. <result column="flg_valid" property="flgValid"/>
  18. <result column="cp_id" property="cpId"/>
  19. <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
  20. <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
  21. <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
  22. <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
  23. <result column="op_app_code" property="opAppCode"/>
  24. <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
  25. <result column="op_db_user" property="opDbUser"/>
  26. </resultMap>
  27. <resultMap id="BaseResultMapResponse" type="com.dk.mdm.model.response.mst.SaleChannelResponse">
  28. <id column="channel_id" property="channelId"/>
  29. <result column="channel_code" property="channelCode"/>
  30. <result column="channel_name" property="channelName"/>
  31. <result column="sys_code" property="sysCode"/>
  32. <result column="display_no" property="displayNo"/>
  33. <result column="remarks" property="remarks"/>
  34. <result column="flg_valid" property="flgValid"/>
  35. <result column="cp_id" property="cpId"/>
  36. </resultMap>
  37. <!-- 通用条件列 -->
  38. <sql id="Condition">
  39. <where>
  40. <if test="channelCode != null and channelCode != ''">
  41. AND channel_code = #{channelCode}
  42. </if>
  43. <if test="channelName != null and channelName != ''">
  44. AND channel_name = #{channelName}
  45. </if>
  46. <if test="sysCode != null and sysCode != ''">
  47. AND sys_code = #{sysCode}
  48. </if>
  49. <if test="displayNo != null">
  50. AND display_no = #{displayNo}
  51. </if>
  52. <if test="remarks != null and remarks != ''">
  53. AND remarks = #{remarks}
  54. </if>
  55. <if test="flgValid != null">
  56. AND flg_valid = #{flgValid}
  57. </if>
  58. <if test="cpId != null">
  59. AND cp_id = #{cpId}
  60. </if>
  61. <if test="opCreateTime != null">
  62. AND op_create_time = #{opCreateTime}
  63. </if>
  64. <if test="opCreateUserId != null and opCreateUserId != ''">
  65. AND op_create_user_id = #{opCreateUserId}
  66. </if>
  67. <if test="opUpdateTime != null">
  68. AND op_update_time = #{opUpdateTime}
  69. </if>
  70. <if test="opUpdateUserId != null and opUpdateUserId != ''">
  71. AND op_update_user_id = #{opUpdateUserId}
  72. </if>
  73. <if test="opAppCode != null and opAppCode != ''">
  74. AND op_app_code = #{opAppCode}
  75. </if>
  76. <if test="opTimestamp != null">
  77. AND op_timestamp = #{opTimestamp}
  78. </if>
  79. <if test="opDbUser != null and opDbUser != ''">
  80. AND op_db_user = #{opDbUser}
  81. </if>
  82. </where>
  83. </sql>
  84. <sql id="idsForeach">
  85. <!-- 根据主键channelId批量操作 -->
  86. WHERE channel_id in
  87. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  88. #{item}
  89. </foreach>
  90. </sql>
  91. <!-- 查询表t_mst_sale_channel,(条件查询+分页)列表 -->
  92. <select id="selectByCond" resultMap="BaseResultMapResponse">
  93. SELECT
  94. <include refid="Base_Column_List"/>
  95. FROM dkic_b.t_mst_sale_channel
  96. <include refid="Condition"/>
  97. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  98. limit #{end} offset #{start}
  99. </if>
  100. </select>
  101. <!-- 查询表t_mst_sale_channel,(条件查询)个数 -->
  102. <select id="countByCond" resultType="Long">
  103. SELECT
  104. count(1)
  105. FROM dkic_b.t_mst_sale_channel
  106. <include refid="Condition"/>
  107. </select>
  108. <!-- 根据主键查询表t_mst_sale_channel的一行数据 -->
  109. <select id="selectById" resultMap="BaseResultMap">
  110. SELECT
  111. <include refid="Base_Column_List"/>
  112. FROM dkic_b.t_mst_sale_channel
  113. WHERE channel_id = #{channelId}::uuid
  114. </select>
  115. <!-- 根据主键锁定表t_mst_sale_channel的一行数据 -->
  116. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  117. SELECT
  118. <include refid="Base_Column_List"/>
  119. FROM dkic_b.t_mst_sale_channel
  120. WHERE channel_id = #{channelId}
  121. for update
  122. </select>
  123. <!-- 根据主键锁定表t_mst_sale_channel的多行数据 -->
  124. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  125. SELECT
  126. <include refid="Base_Column_List"/>
  127. FROM dkic_b.t_mst_sale_channel
  128. <include refid="idsForeach"/>
  129. for update
  130. </select>
  131. <insert id="insertBatch">
  132. insert into dkic_b.t_mst_sale_channel
  133. (
  134. <trim suffixOverrides=",">
  135. channel_code,
  136. channel_name,
  137. sys_code,
  138. display_no,
  139. remarks,
  140. cp_id,
  141. op_app_code,
  142. </trim>
  143. )
  144. values
  145. <foreach collection="list" index="index" item="item" separator=",">
  146. (
  147. <trim suffixOverrides=",">
  148. #{item.channelCode},
  149. #{item.channelName},
  150. #{item.sysCode},
  151. #{item.displayNo},
  152. #{item.remarks},
  153. #{item.cpId},
  154. #{item.opAppCode},
  155. </trim>
  156. )
  157. </foreach>
  158. </insert>
  159. <select id="selectDisplayNo" resultType="Integer">
  160. SELECT MAX(display_no) + 1 FROM dkic_b.t_mst_sale_channel
  161. <include refid="Condition"/>
  162. </select>
  163. </mapper>