<?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.younike.system.mapper.MerchantInfoMapper">
    
    <resultMap type="MerchantInfo" id="MerchantInfoResult">
        <result property="merchantId"    column="merchant_id"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="loginIp"    column="login_ip"    />
        <result property="loginDate"    column="login_date"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="column1"    column="column1"    />
        <result property="column2"    column="column2"    />
        <result property="column3"    column="column3"    />
        <result property="businessNum"    column="business_num"    />
        <result property="businessImg"    column="business_img"    />
        <result property="businessLicenseImg"    column="business_license_img"    />
        <result property="legalPersonNo"    column="legal_person_no"    />
        <result property="legalPersonFrontImg"    column="legal_person_front_img"    />
        <result property="legalPersonBackImg"    column="legal_person_back_img"    />
    </resultMap>

    <sql id="selectMerchantInfoVo">
        select merchant_id, del_flag, login_ip, login_date, create_by, create_time, update_by, update_time, column1, column2, column3, business_num, business_img, business_license_img, legal_person_no, legal_person_front_img, legal_person_back_img from merchant_info
    </sql>

    <select id="selectMerchantInfoList" parameterType="MerchantInfo" resultMap="MerchantInfoResult">
        <include refid="selectMerchantInfoVo"/>
        <where>  
            <if test="loginIp != null  and loginIp != ''"> and login_ip = #{loginIp}</if>
            <if test="loginDate != null "> and login_date = #{loginDate}</if>
            <if test="column1 != null  and column1 != ''"> and column1 = #{column1}</if>
            <if test="column2 != null  and column2 != ''"> and column2 = #{column2}</if>
            <if test="column3 != null  and column3 != ''"> and column3 = #{column3}</if>
            <if test="businessNum != null  and businessNum != ''"> and business_num = #{businessNum}</if>
            <if test="businessImg != null  and businessImg != ''"> and business_img = #{businessImg}</if>
            <if test="businessLicenseImg != null  and businessLicenseImg != ''"> and business_license_img = #{businessLicenseImg}</if>
            <if test="legalPersonNo != null  and legalPersonNo != ''"> and legal_person_no = #{legalPersonNo}</if>
            <if test="legalPersonFrontImg != null  and legalPersonFrontImg != ''"> and legal_person_front_img = #{legalPersonFrontImg}</if>
            <if test="legalPersonBackImg != null  and legalPersonBackImg != ''"> and legal_person_back_img = #{legalPersonBackImg}</if>
        </where>
    </select>
    
    <select id="selectMerchantInfoByMerchantId" parameterType="Long" resultMap="MerchantInfoResult">
        <include refid="selectMerchantInfoVo"/>
        where merchant_id = #{merchantId}
    </select>
        
    <insert id="insertMerchantInfo" parameterType="MerchantInfo" useGeneratedKeys="true" keyProperty="merchantId">
        insert into merchant_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="merchantId != null">merchant_id,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="loginIp != null">login_ip,</if>
            <if test="loginDate != null">login_date,</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>
            <if test="column1 != null">column1,</if>
            <if test="column2 != null">column2,</if>
            <if test="column3 != null">column3,</if>
            <if test="businessNum != null">business_num,</if>
            <if test="businessImg != null">business_img,</if>
            <if test="businessLicenseImg != null">business_license_img,</if>
            <if test="legalPersonNo != null">legal_person_no,</if>
            <if test="legalPersonFrontImg != null">legal_person_front_img,</if>
            <if test="legalPersonBackImg != null">legal_person_back_img,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="merchantId != null">#{merchantId},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="loginIp != null">#{loginIp},</if>
            <if test="loginDate != null">#{loginDate},</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>
            <if test="column1 != null">#{column1},</if>
            <if test="column2 != null">#{column2},</if>
            <if test="column3 != null">#{column3},</if>
            <if test="businessNum != null">#{businessNum},</if>
            <if test="businessImg != null">#{businessImg},</if>
            <if test="businessLicenseImg != null">#{businessLicenseImg},</if>
            <if test="legalPersonNo != null">#{legalPersonNo},</if>
            <if test="legalPersonFrontImg != null">#{legalPersonFrontImg},</if>
            <if test="legalPersonBackImg != null">#{legalPersonBackImg},</if>
         </trim>
    </insert>

    <update id="updateMerchantInfo" parameterType="MerchantInfo">
        update merchant_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="loginIp != null">login_ip = #{loginIp},</if>
            <if test="loginDate != null">login_date = #{loginDate},</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>
            <if test="column1 != null">column1 = #{column1},</if>
            <if test="column2 != null">column2 = #{column2},</if>
            <if test="column3 != null">column3 = #{column3},</if>
            <if test="businessNum != null">business_num = #{businessNum},</if>
            <if test="businessImg != null">business_img = #{businessImg},</if>
            <if test="businessLicenseImg != null">business_license_img = #{businessLicenseImg},</if>
            <if test="legalPersonNo != null">legal_person_no = #{legalPersonNo},</if>
            <if test="legalPersonFrontImg != null">legal_person_front_img = #{legalPersonFrontImg},</if>
            <if test="legalPersonBackImg != null">legal_person_back_img = #{legalPersonBackImg},</if>
        </trim>
        where merchant_id = #{merchantId}
    </update>

    <delete id="deleteMerchantInfoByMerchantId" parameterType="Long">
        delete from merchant_info where merchant_id = #{merchantId}
    </delete>

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