| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- <?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.IntegralShareMapper">
- <!-- 通用设置 -->
- <!-- 通用查询列 -->
- <sql id="Base_Column_List">
- share_id, cp_id, user_id, tactic_id, share_date, end_date, flg_valid,integral_type
- </sql>
- <!-- 通用查询列Response -->
- <sql id="Base_Column_List_Response">
- tmis.share_id, tmis.cp_id, tmis.user_id, tmis.tactic_id, tmis.share_date, tmis.end_date, tmis.flg_valid,tmis.integral_type
- </sql>
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.dk.oauth.model.pojo.integral.IntegralShare">
- <id column="share_id" property="shareId" typeHandler="UuidTypeHandler"/>
- <result column="cp_id" property="cpId"/>
- <result column="user_id" property="userId" typeHandler="UuidTypeHandler"/>
- <result column="tactic_id" property="tacticId" typeHandler="UuidTypeHandler"/>
- <result column="share_date" property="shareDate" typeHandler="TimestampTypeHandler"/>
- <result column="end_date" property="endDate" typeHandler="TimestampTypeHandler"/>
- <result column="flg_valid" property="flgValid"/>
- <result column="integral_type" property="integralType"/>
- </resultMap>
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMapResponse" type="com.dk.oauth.model.response.integral.IntegralShareResponse">
- <id column="share_id" property="shareId" typeHandler="UuidTypeHandler"/>
- <result column="cp_id" property="cpId"/>
- <result column="user_id" property="userId" typeHandler="UuidTypeHandler"/>
- <result column="tactic_id" property="tacticId" typeHandler="UuidTypeHandler"/>
- <result column="share_date" property="shareDate" typeHandler="TimestampTypeHandler"/>
- <result column="end_date" property="endDate" typeHandler="TimestampTypeHandler"/>
- <result column="flg_valid" property="flgValid"/>
- <result column="cp_name" property="cpName"/>
- <result column="integral_type" property="integralType"/>
- <result column="integral_type_name" property="integralTypeName"/>
- <result column="number_of_shares" property="numberOfShares"/>
- </resultMap>
- <!-- 通用条件列 -->
- <sql id="Condition">
- <where>
- <if test="cpId != null and cpId != ''">
- AND tmis.cp_id = #{cpId}
- </if>
- <if test="tacticId != null and tacticId != ''">
- AND tmis.tactic_id = #{tacticId}::uuid
- </if>
- <if test="userId != null and userId != ''">
- AND tmis.user_id = #{userId}::uuid
- </if>
- <if test="shareDate != null">
- AND tmis.share_date = #{shareDate}
- </if>
- <if test="endDate != null">
- AND tmis.end_date = #{endDate}
- </if>
- <if test="flgValid != null">
- AND tmis.flg_valid = #{flgValid}
- </if>
- <if test="shareDateFlag != null and shareDateFlag ">
- AND tmis.share_date >= NOW() - INTERVAL '1 DAY'
- </if>
- <if test="integralType != null and integralType != ''">
- AND tmis.integral_type = #{integralType}
- </if>
- </where>
- </sql>
- <sql id="idsForeach">
- <!-- 根据主键cpId批量操作 -->
- WHERE share_id in
- <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </sql>
- <!-- 查询表dkic_a.t_mst_integral_share,(条件查询+分页)列表 -->
- <select id="selectByCond" resultMap="BaseResultMapResponse">
- SELECT
- <include refid="Base_Column_List_Response"/>
- ,tac.cp_name
- ,sys.f_get_name_i18n(tdk.kind_name_i18n,#{i18n}) as integral_type_name
- FROM dkic_a.t_mst_integral_share tmis
- left join dkic_a.t_a_company tac on tac.cp_id = tmis.cp_id
- LEFT JOIN sys.t_data_kind tdk ON tmis.integral_type = tdk.kind_code
- <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_integral_share,(条件查询)个数 -->
- <select id="countByCond" resultType="Long">
- SELECT
- count(1)
- FROM dkic_a.t_mst_integral_share tmis
- left join dkic_a.t_a_company tac on tac.cp_id = tmis.cp_id
- LEFT JOIN sys.t_data_kind tdk ON tmis.integral_type = tdk.kind_code
- <include refid="Condition"/>
- </select>
- <!-- 根据主键查询表dkic_a.t_mst_integral_share的一行数据 -->
- <select id="selectById" resultMap="BaseResultMapResponse">
- SELECT
- <include refid="Base_Column_List_Response"/>
- ,tac.cp_name
- ,sys.f_get_name_i18n(tdk.kind_name_i18n,#{i18n}) as integral_type_name
- FROM dkic_a.t_mst_integral_share tmis
- left join dkic_a.t_a_company tac on tac.cp_id = tmis.cp_id
- LEFT JOIN sys.t_data_kind tdk ON tmis.integral_type = tdk.kind_code
- WHERE share_id = #{id}::uuid
- </select>
- <!-- 根据主键锁定表dkic_a.t_mst_integral_share的一行数据 -->
- <select id="selectByIdForUpdate" resultMap="BaseResultMap">
- SELECT
- <include refid="Base_Column_List"/>
- FROM dkic_a.t_mst_integral_share
- WHERE share_id = #{shareId}::uuid
- for update
- </select>
- <!-- 根据主键锁定表dkic_a.t_mst_integral_share的多行数据 -->
- <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
- SELECT
- <include refid="Base_Column_List"/>
- FROM dkic_a.t_mst_integral_share
- <include refid="idsForeach"/>
- for update
- </select>
- <insert id="insertBatch">
- insert into dkic_a.t_mst_integral_share
- (
- <trim suffixOverrides=",">
- tactic_id,
- share_date,
- end_date,
- user_id,
- cp_id,
- integral_type,
- </trim>
- )
- values
- <foreach collection="list" index="index" item="item" separator=",">
- (
- <trim suffixOverrides=",">
- #{item.tacticId}::uuid,
- #{item.shareDate},
- #{item.endDate},
- #{item.userId}::uuid,
- #{item.cpId},
- #{item.integralType},
- </trim>
- )
- </foreach>
- </insert>
- <!-- 查询历史记录(条件查询+分页)列表 -->
- <select id="selectHistoryRecordByCond" resultMap="BaseResultMapResponse">
- SELECT
- <include refid="Base_Column_List_Response"/>
- ,tac.cp_name
- ,sys.f_get_name_i18n(tdk.kind_name_i18n,#{i18n}) as integral_type_name
- ,(select count(1) from dkic_a.t_mst_integral_item tmii where tmii.cp_id = tmis.cp_id) as number_of_shares
- FROM dkic_a.t_mst_integral_share tmis
- left join dkic_a.t_a_company tac on tac.cp_id = tmis.cp_id
- LEFT JOIN sys.t_data_kind tdk ON tmis.integral_type = tdk.kind_code
- <include refid="Condition"/>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- </mapper>
|