SettingPaymentMethodMapper.xml 6.53 KB
<?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.diligrp.etrade.admin.dao.SettingPaymentMethodMapper">

    <resultMap id="BaseResultMap" type="com.diligrp.etrade.admin.model.SettingPaymentMethod">
            <id property="id" column="id" jdbcType="BIGINT"/>
            <result property="marketId" column="market_id" jdbcType="BIGINT"/>
            <result property="methodCode" column="method_code" jdbcType="BIGINT"/>
            <result property="createdTime" column="created_time" jdbcType="TIMESTAMP"/>
            <result property="modifiedTime" column="modified_time" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        id,market_id,method_code,
        created_time,modified_time
    </sql>

    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from setting_payment_method
        where  id = #{id,jdbcType=BIGINT} 
    </select>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete from setting_payment_method
        where  id = #{id,jdbcType=BIGINT} 
    </delete>
    <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.diligrp.etrade.admin.model.SettingPaymentMethod" useGeneratedKeys="true">
        insert into setting_payment_method
        ( id,market_id,method_code
        ,created_time,modified_time)
        values (#{id,jdbcType=BIGINT},#{marketId,jdbcType=BIGINT},#{methodCode,jdbcType=BIGINT}
        ,#{createdTime,jdbcType=TIMESTAMP},#{modifiedTime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.diligrp.etrade.admin.model.SettingPaymentMethod" useGeneratedKeys="true">
        insert into setting_payment_method
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="id != null">id,</if>
                <if test="marketId != null">market_id,</if>
                <if test="methodCode != null">method_code,</if>
                <if test="createdTime != null">created_time,</if>
                <if test="modifiedTime != null">modified_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="id != null">#{id,jdbcType=BIGINT},</if>
                <if test="marketId != null">#{marketId,jdbcType=BIGINT},</if>
                <if test="methodCode != null">#{methodCode,jdbcType=BIGINT},</if>
                <if test="createdTime != null">#{createdTime,jdbcType=TIMESTAMP},</if>
                <if test="modifiedTime != null">#{modifiedTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.diligrp.etrade.admin.model.SettingPaymentMethod">
        update setting_payment_method
        <set>
                <if test="marketId != null">
                    market_id = #{marketId,jdbcType=BIGINT},
                </if>
                <if test="methodCode != null">
                    method_code = #{methodCode,jdbcType=BIGINT},
                </if>
                <if test="createdTime != null">
                    created_time = #{createdTime,jdbcType=TIMESTAMP},
                </if>
                <if test="modifiedTime != null">
                    modified_time = #{modifiedTime,jdbcType=TIMESTAMP},
                </if>
        </set>
        where   id = #{id,jdbcType=BIGINT} 
    </update>
    <update id="updateByPrimaryKey" parameterType="com.diligrp.etrade.admin.model.SettingPaymentMethod">
        update setting_payment_method
        set 
            market_id =  #{marketId,jdbcType=BIGINT},
            method_code =  #{methodCode,jdbcType=BIGINT},
            created_time =  #{createdTime,jdbcType=TIMESTAMP},
            modified_time =  #{modifiedTime,jdbcType=TIMESTAMP}
        where   id = #{id,jdbcType=BIGINT} 
    </update>

    <select id="selectAllType" resultType="com.diligrp.etrade.admin.domain.SettingPaymentMethodDto">
        select spmt.code methodCode,
               spmt.name methodName,
               spmc.code classificationCode,
               spmc.name classificationName
        from setting_payment_method_type spmt
                 left join setting_payment_method_classification spmc on
            spmt.classification_code = spmc.code;
    </select>

    <select id="selectTypeByMarketId" resultType="com.diligrp.etrade.admin.domain.SettingPaymentMethodDto">
        select spmt.code methodCode,
               spmt.name methodName,
               spm.market_id marketId,
               spmc.name classificationName,
               spmc.code classificationCode
        from setting_payment_method_type spmt
                 inner join setting_payment_method_classification spmc on spmt.classification_code = spmc.code
                 inner join setting_payment_method spm on spmt.code = spm.method_code
        where 1 = 1
        <if test="marketId != null">
           and market_id = #{marketId,jdbcType=BIGINT}
        </if>
    </select>
    <select id="selectTypeByMarketIds" resultType="com.diligrp.etrade.admin.domain.SettingPaymentMethodDto">
        select spmt.code methodCode,
        spmt.name methodName,
        spm.market_id marketId,
        spmc.name classificationName,
        spmc.code classificationCode
        from setting_payment_method_type spmt
        inner join setting_payment_method_classification spmc on spmt.classification_code = spmc.code
        inner join setting_payment_method spm on spmt.code = spm.method_code
        where 1 = 1
        <if test="marketIds != null and marketIds.size()>0">
            and spm.market_id in
            <foreach collection="marketIds" open="(" separator="," close=")" item="marketId">
                #{marketId}
            </foreach>
        </if>
    </select>
    <!-- 批量新增数据 -->
    <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
        insert into setting_payment_method(market_id,method_code)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.marketId},#{entity.methodCode})
        </foreach>
    </insert>

    <delete id="deleteBy" parameterType="java.lang.Long">
        delete from setting_payment_method
        where 1 = 1
        <if test="marketId != null">
            and market_id = #{marketId,jdbcType=BIGINT}
        </if>
        <if test="methodCode != null">
            and method_code = #{methodCode,jdbcType=BIGINT}
        </if>
    </delete>
</mapper>