<?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.cool.store.mapper.JoinIntentionMapper">
    <resultMap id="BaseResultMap" type="com.cool.store.entity.MemberQuestionDO">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="audit_id" property="auditId" jdbcType="BIGINT"/>
        <result column="partner_id" property="partnerId" jdbcType="VARCHAR"/>
        <result column="line_id" property="lineId" jdbcType="BIGINT"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
        <result column="career_status" property="careerStatus" jdbcType="TINYINT"/>
        <result column="education_level" property="educationLevel" jdbcType="TINYINT"/>
        <result column="annual_income" property="annualIncome" jdbcType="VARCHAR"/>
        <result column="has_partner" property="hasPartner" jdbcType="TINYINT"/>
        <result column="join_type" property="joinType" jdbcType="TINYINT"/>
        <result column="capital_source" property="capitalSource" jdbcType="TINYINT"/>
        <result column="business_mode" property="businessMode" jdbcType="TINYINT"/>
        <result column="join_experience" property="joinExperience" jdbcType="TINYINT"/>
        <result column="fruit_industry_experience" property="fruitIndustryExperience" jdbcType="TINYINT"/>
        <result column="store_condition" property="storeCondition" jdbcType="VARCHAR"/>
        <result column="payback_period" property="paybackPeriod" jdbcType="VARCHAR"/>
        <result column="follows_management_standard" property="followsManagementStandard" jdbcType="TINYINT"/>
        <result column="can_training" property="canTraining" jdbcType="TINYINT"/>
        <result column="deleted" property="deleted" jdbcType="TINYINT"/>
    </resultMap>

    <sql id="Base_Column_List">
        id,
        audit_id,
        partner_id,
        line_id,
        join_type,
        create_time,
        update_time,
        career_status,
        education_level,
        annual_income,
        has_partner,
        capital_source,
        business_mode,
        join_experience,
        fruit_industry_experience,
        store_condition,
        payback_period,
        follows_management_standard,
        can_training,
        deleted
  </sql>
    <insert id="insertOrUpdate" parameterType="com.cool.store.entity.MemberQuestionDO" useGeneratedKeys="true"
            keyProperty="id">
        INSERT INTO xfsg_member_question_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="request.auditId != null">audit_id,</if>
            <if test="request.partnerId != null">partner_id,</if>
            <if test="request.lineId != null">line_id,</if>
            <if test="request.careerStatus != null">career_status,</if>
            <if test="request.joinType != null">join_type,</if>
            <if test="request.educationLevel != null">education_level,</if>
            <if test="request.annualIncome != null">annual_income,</if>
            <if test="request.hasPartner != null">has_partner,</if>
            <if test="request.capitalSource != null">capital_source,</if>
            <if test="request.businessMode != null">business_mode,</if>
            <if test="request.joinExperience != null">join_experience,</if>
            <if test="request.fruitIndustryExperience != null">fruit_industry_experience,</if>
            <if test="request.storeCondition != null">store_condition,</if>
            <if test="request.paybackPeriod != null">payback_period,</if>
            <if test="request.followsManagementStandard != null">follows_management_standard,</if>
            <if test="request.canTraining != null">can_training,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="request.auditId != null">#{request.auditId},</if>
            <if test="request.partnerId != null">#{request.partnerId},</if>
            <if test="request.lineId != null">#{request.lineId},</if>
            <if test="request.careerStatus != null">#{request.careerStatus},</if>
            <if test="request.joinType != null">#{request.joinType},</if>
            <if test="request.educationLevel != null">#{request.educationLevel},</if>
            <if test="request.annualIncome != null">#{request.annualIncome},</if>
            <if test="request.hasPartner != null">#{request.hasPartner},</if>
            <if test="request.capitalSource != null">#{request.capitalSource},</if>
            <if test="request.businessMode != null">#{request.businessMode},</if>
            <if test="request.joinExperience != null">#{request.joinExperience},</if>
            <if test="request.fruitIndustryExperience != null">#{request.fruitIndustryExperience},</if>
            <if test="request.storeCondition != null">#{request.storeCondition},</if>
            <if test="request.paybackPeriod != null">#{request.paybackPeriod},</if>
            <if test="request.followsManagementStandard != null">#{request.followsManagementStandard},</if>
            <if test="request.canTraining != null">#{request.canTraining},</if>
        </trim>
        ON DUPLICATE KEY UPDATE
        <trim suffixOverrides=",">
            <if test="request.auditId != null">audit_id = #{request.auditId},</if>
            <if test="request.partnerId != null">partner_id = #{request.partnerId},</if>
            <if test="request.careerStatus != null">career_status = #{request.careerStatus},</if>
            <if test="request.joinType != null">join_type = #{request.joinType},</if>
            <if test="request.educationLevel != null">education_level = #{request.educationLevel},</if>
            <if test="request.annualIncome != null">annual_income = #{request.annualIncome},</if>
            <if test="request.hasPartner != null">has_partner = #{request.hasPartner},</if>
            <if test="request.capitalSource != null">capital_source = #{request.capitalSource},</if>
            <if test="request.businessMode != null">business_mode = #{request.businessMode},</if>
            <if test="request.joinExperience != null">join_experience = #{request.joinExperience},</if>
            <if test="request.fruitIndustryExperience != null">fruit_industry_experience = #{request.fruitIndustryExperience},</if>
            <if test="request.storeCondition != null">store_condition = #{request.storeCondition},</if>
            <if test="request.paybackPeriod != null">payback_period = #{request.paybackPeriod},</if>
            <if test="request.followsManagementStandard != null">follows_management_standard = #{request.followsManagementStandard},</if>
            <if test="request.canTraining != null">can_training = #{request.canTraining},</if>
        </trim>
    </insert>
    <update id="updateAuditIdByLineId">
        update xfsg_member_question_info
        set audit_id = #{auditId}
        where line_id = #{lineId}
    </update>

    <select id="getByLineId" resultType="com.cool.store.entity.MemberQuestionDO">
        select
        <include refid="Base_Column_List"/>
        from xfsg_member_question_info
        where line_id = #{lineId}
        and deleted = 0
    </select>

    <select id="getByLineIds" resultType="com.cool.store.entity.MemberQuestionDO">
        select
        <include refid="Base_Column_List"/>
        from xfsg_member_question_info
        where deleted = 0
        <if test="lineIds !=null and lineIds.size>0">
            <foreach collection="lineIds" item="lineId" open="and line_id in (" close=")" separator=",">
                #{lineId}
            </foreach>
        </if>
    </select>


</mapper>