IntegralShareMapper.xml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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.IntegralShareMapper">
  4. <!-- 通用设置 -->
  5. <!-- 通用查询列 -->
  6. <sql id="Base_Column_List">
  7. share_id,cp_id, tactic_id, share_date, end_date,integral_type, flg_valid,user_id
  8. </sql>
  9. <!-- 通用查询映射结果 -->
  10. <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.mst.IntegralShare">
  11. <id column="share_id" property="shareId"/>
  12. <result column="cp_id" property="cpId"/>
  13. <result column="tactic_id" property="tacticId" typeHandler="UuidTypeHandler"/>
  14. <result column="share_date" property="shareDate" typeHandler="TimestampTypeHandler"/>
  15. <result column="end_date" property="endDate" typeHandler="TimestampTypeHandler"/>
  16. <result column="integral_type" property="integralType"/>
  17. <result column="flg_valid" property="flgValid"/>
  18. <result column="user_id" property="userId"/>
  19. </resultMap>
  20. <!-- 通用条件列 -->
  21. <sql id="Condition">
  22. <where>
  23. <if test="tacticId != null and tacticId != ''">
  24. AND tactic_id = #{tacticId}
  25. </if>
  26. <if test="shareDate != null">
  27. AND share_date = #{shareDate}
  28. </if>
  29. <if test="endDate != null">
  30. AND end_date = #{endDate}
  31. </if>
  32. <if test="flgValid != null">
  33. AND flg_valid = #{flgValid}
  34. </if>
  35. <if test="userId != null">
  36. AND user_id = #{userId}
  37. </if>
  38. </where>
  39. </sql>
  40. <!-- 通用查询列 -->
  41. <sql id="Base_Column_List_list">
  42. share_id,cp_id, tactic_id, share_date, end_date,integral_type, flg_valid,user_id
  43. </sql>
  44. <!-- 通用查询映射结果 -->
  45. <resultMap id="BaseResultMap_list" type="com.dk.mdm.model.response.mst.IntegralShareResponse">
  46. <id column="share_id" property="shareId"/>
  47. <result column="cp_id" property="cpId"/>
  48. <result column="tactic_id" property="tacticId" typeHandler="UuidTypeHandler"/>
  49. <result column="share_date" property="shareDate" typeHandler="TimestampTypeHandler"/>
  50. <result column="end_date" property="endDate" typeHandler="TimestampTypeHandler"/>
  51. <result column="integral_type" property="integralType"/>
  52. <result column="flg_valid" property="flgValid"/>
  53. <result column="user_id" property="userId"/>
  54. </resultMap>
  55. <!-- 通用条件列 -->
  56. <sql id="Condition_list">
  57. <where>
  58. <if test="shareId != null and shareId != ''">
  59. AND share_id = #{shareId}::uuid
  60. </if>
  61. <if test="cpId != null and cpId != ''">
  62. AND cp_id = #{cpId}
  63. </if>
  64. <if test="tacticId != null and tacticId != ''">
  65. AND tactic_id = #{tacticId}
  66. </if>
  67. <if test="shareDate != null">
  68. AND share_date = #{shareDate}
  69. </if>
  70. <if test="endDate != null">
  71. AND end_date = #{endDate}
  72. </if>
  73. <if test="flgValid != null">
  74. AND flg_valid = #{flgValid}
  75. </if>
  76. <if test="userId != null">
  77. AND user_id = #{userId}
  78. </if>
  79. </where>
  80. </sql>
  81. <sql id="idsForeach">
  82. <!-- 根据主键cpId批量操作 -->
  83. WHERE cp_id in
  84. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  85. #{item}
  86. </foreach>
  87. </sql>
  88. <!-- 查询表dkic_a.t_mst_integral_share,(条件查询+分页)列表 -->
  89. <select id="selectByCond" resultMap="BaseResultMap_list">
  90. SELECT
  91. <include refid="Base_Column_List_list"/>
  92. FROM dkic_a.t_mst_integral_share
  93. <include refid="Condition_list"/>
  94. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  95. limit #{end} offset #{start}
  96. </if>
  97. </select>
  98. <!-- 查询表dkic_a.t_mst_integral_share,(条件查询)个数 -->
  99. <select id="countByCond" resultType="Long">
  100. SELECT
  101. count(1)
  102. FROM dkic_a.t_mst_integral_share
  103. <include refid="Condition_list"/>
  104. </select>
  105. <!-- 根据主键锁定表dkic_a.t_mst_integral_share的一行数据 -->
  106. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  107. SELECT
  108. <include refid="Base_Column_List"/>
  109. FROM dkic_a.t_mst_integral_share
  110. WHERE cp_id = #{cpId}
  111. for update
  112. </select>
  113. <!-- 根据主键锁定表dkic_a.t_mst_integral_share的多行数据 -->
  114. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  115. SELECT
  116. <include refid="Base_Column_List"/>
  117. FROM dkic_a.t_mst_integral_share
  118. <include refid="idsForeach"/>
  119. for update
  120. </select>
  121. <insert id="insertBatch">
  122. insert into dkic_a.t_mst_integral_share
  123. (
  124. <trim suffixOverrides=",">
  125. tactic_id,
  126. share_date,
  127. end_date,
  128. </trim>
  129. )
  130. values
  131. <foreach collection="list" index="index" item="item" separator=",">
  132. (
  133. <trim suffixOverrides=",">
  134. #{item.tacticId}::uuid,
  135. #{item.shareDate},
  136. #{item.endDate},
  137. </trim>
  138. )
  139. </foreach>
  140. </insert>
  141. </mapper>