IntegralShareMapper.xml 5.1 KB

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