<?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="io.renren.dao.ConsumeTenantMapper">

    <resultMap type="ConsumeTenant" id="ConsumeTenantResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="type"    column="type"    />
        <result property="zfbAppId"    column="zfb_app_id"    />
        <result property="zfbSysServiceProviderId"    column="zfb_sys_service_provider_id"    />
        <result property="zfbRsaPrivateKey"    column="zfb_rsa_private_key"    />
        <result property="zfbStop"    column="zfb_stop"    />
        <result property="zfbMode"    column="zfb_mode"    />
        <result property="wxAppid"    column="wx_appid"    />
        <result property="wxMchId"    column="wx_mch_id"    />
        <result property="wxSubMchId"    column="wx_sub_mch_id"    />
        <result property="wxKey"    column="wx_key"    />
        <result property="wxStop"    column="wx_stop"    />
        <result property="wxMode"    column="wx_mode"    />
        <result property="paramId"    column="param_id"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectConsumeTenantVo">
        select id, name, type, zfb_app_id, zfb_sys_service_provider_id, zfb_rsa_private_key, zfb_stop, zfb_mode, wx_appid, wx_mch_id, wx_sub_mch_id, wx_key, wx_stop, wx_mode, param_id, create_by, create_time, update_by, update_time from consume_tenant
    </sql>

    <select id="selectConsumeTenantList" parameterType="ConsumeTenant" resultMap="ConsumeTenantResult">
        <include refid="selectConsumeTenantVo"/>
        <where>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
        </where>
    </select>

    <select id="selectConsumeTenantById" parameterType="Long" resultMap="ConsumeTenantResult">
        <include refid="selectConsumeTenantVo"/>
        where id = #{id}
    </select>

    <insert id="insertConsumeTenant" parameterType="ConsumeTenant" useGeneratedKeys="true" keyProperty="id">
        insert into consume_tenant
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">name,</if>
            <if test="type != null">type,</if>
            <if test="zfbAppId != null">zfb_app_id,</if>
            <if test="zfbSysServiceProviderId != null">zfb_sys_service_provider_id,</if>
            <if test="zfbRsaPrivateKey != null">zfb_rsa_private_key,</if>
            <if test="zfbStop != null">zfb_stop,</if>
            <if test="zfbMode != null">zfb_mode,</if>
            <if test="wxAppid != null">wx_appid,</if>
            <if test="wxMchId != null">wx_mch_id,</if>
            <if test="wxSubMchId != null">wx_sub_mch_id,</if>
            <if test="wxKey != null">wx_key,</if>
            <if test="wxStop != null">wx_stop,</if>
            <if test="wxMode != null">wx_mode,</if>
            <if test="paramId != null">param_id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null">#{name},</if>
            <if test="type != null">#{type},</if>
            <if test="zfbAppId != null">#{zfbAppId},</if>
            <if test="zfbSysServiceProviderId != null">#{zfbSysServiceProviderId},</if>
            <if test="zfbRsaPrivateKey != null">#{zfbRsaPrivateKey},</if>
            <if test="zfbStop != null">#{zfbStop},</if>
            <if test="zfbMode != null">#{zfbMode},</if>
            <if test="wxAppid != null">#{wxAppid},</if>
            <if test="wxMchId != null">#{wxMchId},</if>
            <if test="wxSubMchId != null">#{wxSubMchId},</if>
            <if test="wxKey != null">#{wxKey},</if>
            <if test="wxStop != null">#{wxStop},</if>
            <if test="wxMode != null">#{wxMode},</if>
            <if test="paramId != null">#{paramId},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateConsumeTenant" parameterType="ConsumeTenant">
        update consume_tenant
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="type != null">type = #{type},</if>
            <if test="zfbAppId != null">zfb_app_id = #{zfbAppId},</if>
            <if test="zfbSysServiceProviderId != null">zfb_sys_service_provider_id = #{zfbSysServiceProviderId},</if>
            <if test="zfbRsaPrivateKey != null">zfb_rsa_private_key = #{zfbRsaPrivateKey},</if>
            <if test="zfbStop != null">zfb_stop = #{zfbStop},</if>
            <if test="zfbMode != null">zfb_mode = #{zfbMode},</if>
            <if test="wxAppid != null">wx_appid = #{wxAppid},</if>
            <if test="wxMchId != null">wx_mch_id = #{wxMchId},</if>
            <if test="wxSubMchId != null">wx_sub_mch_id = #{wxSubMchId},</if>
            <if test="wxKey != null">wx_key = #{wxKey},</if>
            <if test="wxStop != null">wx_stop = #{wxStop},</if>
            <if test="wxMode != null">wx_mode = #{wxMode},</if>
            <if test="paramId != null">param_id = #{paramId},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteConsumeTenantById" parameterType="Long">
        delete from consume_tenant where id = #{id}
    </delete>

    <delete id="deleteConsumeTenantByIds" parameterType="String">
        delete from consume_tenant where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
