| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.dk.oauth.mapper.integral.CouponSendMapper">
- <!-- 通用设置 -->
- <!-- 通用查询列 -->
- <sql id="Base_Column_List">
- cp_id, coupon_id, send_date, end_date, user_num, flg_valid
- </sql>
- <!-- 通用查询列Response -->
- <sql id="Base_Column_List_Response">
- tmcs.cp_id, tmcs.coupon_id, tmcs.send_date, tmcs.end_date, tmcs.user_num, tmcs.flg_valid
- </sql>
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.dk.oauth.model.pojo.integral.CouponSend">
- <id column="cp_id" property="cpId" typeHandler="UuidTypeHandler"/>
- <result column="coupon_id" property="couponId" typeHandler="UuidTypeHandler"/>
- <result column="send_date" property="sendDate" typeHandler="TimestampTypeHandler"/>
- <result column="end_date" property="endDate" typeHandler="TimestampTypeHandler"/>
- <result column="user_num" property="userNum"/>
- <result column="flg_valid" property="flgValid"/>
- </resultMap>
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMapResponse" type="com.dk.oauth.model.response.integral.CouponSendResponse">
- <id column="cp_id" property="cpId" typeHandler="UuidTypeHandler"/>
- <result column="coupon_id" property="couponId" typeHandler="UuidTypeHandler"/>
- <result column="send_date" property="sendDate" typeHandler="TimestampTypeHandler"/>
- <result column="end_date" property="endDate" typeHandler="TimestampTypeHandler"/>
- <result column="user_num" property="userNum"/>
- <result column="flg_valid" property="flgValid"/>
- <result column="cp_name" property="cpName"/>
- <result column="coupon_name" property="couponName"/>
- </resultMap>
- <!-- 通用条件列 -->
- <sql id="Condition">
- <where>
- <if test="couponId != null and couponId != ''">
- AND tmcs.coupon_id = #{couponId}
- </if>
- <if test="sendDate != null">
- AND tmcs.send_date = #{sendDate}
- </if>
- <if test="endDate != null">
- AND tmcs.end_date = #{endDate}
- </if>
- <if test="userNum != null">
- AND tmcs.user_num = #{userNum}
- </if>
- <if test="flgValid != null">
- AND tmcs.flg_valid = #{flgValid}
- </if>
- <if test="cpName != null and cpName != ''">
- AND tac.cp_name LIKE concat('%',my_ex.likequery(#{cpName}),'%')
- </if>
- <if test="couponName != null and couponName != ''">
- AND tmc.coupon_name LIKE concat('%',my_ex.likequery(#{couponName}),'%')
- </if>
- </where>
- </sql>
- <sql id="idsForeach">
- <!-- 根据主键cpId批量操作 -->
- WHERE cp_id in
- <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </sql>
- <!-- 查询表dkic_a.t_mst_coupon_send,(条件查询+分页)列表 -->
- <select id="selectByCond" resultMap="BaseResultMapResponse">
- SELECT
- <include refid="Base_Column_List_Response"/>
- ,tac.cp_name
- ,tmc.coupon_name
- FROM dkic_a.t_mst_coupon_send tmcs
- left join dkic_a.t_a_company tac on tac.cp_id = tmcs.cp_id
- left join dkic_a.t_mst_coupon tmc on tmc.coupon_id = tmcs.coupon_id
- <include refid="Condition"/>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询表dkic_a.t_mst_coupon_send,(条件查询)个数 -->
- <select id="countByCond" resultType="Long">
- SELECT
- count(1)
- FROM dkic_a.t_mst_coupon_send
- <include refid="Condition"/>
- </select>
- <!-- 根据主键查询表dkic_a.t_mst_coupon_send的一行数据 -->
- <select id="selectById" resultMap="BaseResultMapResponse">
- SELECT
- <include refid="Base_Column_List_Response"/>
- ,tac.cp_name
- ,tmc.coupon_name
- FROM dkic_a.t_mst_coupon_send
- left join dkic_a.t_a_company tac on tac.cp_id = tmcs.cp_id
- left join dkic_a.t_mst_coupon tmc on tmc.coupon_id = tmcs.coupon_id
- WHERE cp_id = #{id}::uuid
- </select>
- <!-- 根据主键锁定表dkic_a.t_mst_coupon_send的一行数据 -->
- <select id="selectByIdForUpdate" resultMap="BaseResultMap">
- SELECT
- <include refid="Base_Column_List"/>
- FROM dkic_a.t_mst_coupon_send
- WHERE cp_id = #{cpId}::uuid
- for update
- </select>
- <!-- 根据主键锁定表dkic_a.t_mst_coupon_send的多行数据 -->
- <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
- SELECT
- <include refid="Base_Column_List"/>
- FROM dkic_a.t_mst_coupon_send
- <include refid="idsForeach"/>
- for update
- </select>
- <insert id="insertBatch">
- insert into dkic_a.t_mst_coupon_send
- (
- <trim suffixOverrides=",">
- coupon_id,
- send_date,
- end_date,
- user_num,
- </trim>
- )
- values
- <foreach collection="list" index="index" item="item" separator=",">
- (
- <trim suffixOverrides=",">
- #{item.couponId}::uuid,
- #{item.sendDate},
- #{item.endDate},
- #{item.userNum},
- </trim>
- )
- </foreach>
- </insert>
- </mapper>
|