<?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.ruoyi.ibs.list.mapper.SocialSecurityMapper">
    
    <resultMap type="SocialSecurity" id="SocialSecurityResult">
        <result property="id"    column="id"    />
        <result property="custIdc"    column="cust_idc"    />
        <result property="paymentStatus"    column="payment_status"    />
        <result property="unitType"    column="unit_type"    />
        <result property="belongBusi"    column="belong_busi"    />
        <result property="economicType"    column="economic_type"    />
        <result property="qualityLabel"    column="quality_label"    />
        <result property="paymentBaseRank"    column="payment_base_rank"    />
        <result property="paymentCountRank"    column="payment_count_rank"    />
        <result property="paymentType"    column="payment_type"    />
        <result property="insuranceStatus"    column="insurance_status"    />
        <result property="recentTwoYearsCount"    column="recent_two_years_count"    />
        <result property="recentOneYearsCount"    column="recent_one_years_count"    />
        <result property="paymentBase"    column="payment_base"    />
        <result property="blackList"    column="black_list"    />
        <result property="labourArbitration"    column="labour_arbitration"    />
        <result property="receivePensionBenefits"    column="receive_pension_benefits"    />
        <result property="receiveUnemploymentBenefits"    column="receive_unemployment_benefits"    />
    </resultMap>

    <sql id="selectSocialSecurityVo">
        select id, cust_idc, payment_status, unit_type, belong_busi, economic_type, quality_label, payment_base_rank, payment_count_rank, payment_type, insurance_status, recent_two_years_count, recent_one_years_count, payment_base, black_list, labour_arbitration, receive_pension_benefits, receive_unemployment_benefits from social_security
    </sql>

    <select id="selectSocialSecurityList" parameterType="SocialSecurity" resultMap="SocialSecurityResult">
        <include refid="selectSocialSecurityVo"/>
        <where>  
            <if test="custIdc != null  and custIdc != ''"> and cust_idc = #{custIdc}</if>
            <if test="paymentStatus != null  and paymentStatus != ''"> and payment_status = #{paymentStatus}</if>
            <if test="unitType != null  and unitType != ''"> and unit_type = #{unitType}</if>
            <if test="belongBusi != null  and belongBusi != ''"> and belong_busi = #{belongBusi}</if>
            <if test="economicType != null  and economicType != ''"> and economic_type = #{economicType}</if>
            <if test="qualityLabel != null  and qualityLabel != ''"> and quality_label = #{qualityLabel}</if>
            <if test="paymentBaseRank != null  and paymentBaseRank != ''"> and payment_base_rank = #{paymentBaseRank}</if>
            <if test="paymentCountRank != null  and paymentCountRank != ''"> and payment_count_rank = #{paymentCountRank}</if>
            <if test="paymentType != null  and paymentType != ''"> and payment_type = #{paymentType}</if>
            <if test="insuranceStatus != null  and insuranceStatus != ''"> and insurance_status = #{insuranceStatus}</if>
            <if test="recentTwoYearsCount != null  and recentTwoYearsCount != ''"> and recent_two_years_count = #{recentTwoYearsCount}</if>
            <if test="recentOneYearsCount != null  and recentOneYearsCount != ''"> and recent_one_years_count = #{recentOneYearsCount}</if>
            <if test="paymentBase != null  and paymentBase != ''"> and payment_base = #{paymentBase}</if>
            <if test="blackList != null  and blackList != ''"> and black_list = #{blackList}</if>
            <if test="labourArbitration != null  and labourArbitration != ''"> and labour_arbitration = #{labourArbitration}</if>
            <if test="receivePensionBenefits != null  and receivePensionBenefits != ''"> and receive_pension_benefits = #{receivePensionBenefits}</if>
            <if test="receiveUnemploymentBenefits != null  and receiveUnemploymentBenefits != ''"> and receive_unemployment_benefits = #{receiveUnemploymentBenefits}</if>
        </where>
    </select>
    
    <select id="selectSocialSecurityById" parameterType="Long" resultMap="SocialSecurityResult">
        <include refid="selectSocialSecurityVo"/>
        where id = #{id}
    </select>

    <insert id="insertSocialSecurity" parameterType="SocialSecurity" useGeneratedKeys="true" keyProperty="id">
        insert into social_security
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="custIdc != null">cust_idc,</if>
            <if test="paymentStatus != null">payment_status,</if>
            <if test="unitType != null">unit_type,</if>
            <if test="belongBusi != null">belong_busi,</if>
            <if test="economicType != null">economic_type,</if>
            <if test="qualityLabel != null">quality_label,</if>
            <if test="paymentBaseRank != null">payment_base_rank,</if>
            <if test="paymentCountRank != null">payment_count_rank,</if>
            <if test="paymentType != null">payment_type,</if>
            <if test="insuranceStatus != null">insurance_status,</if>
            <if test="recentTwoYearsCount != null">recent_two_years_count,</if>
            <if test="recentOneYearsCount != null">recent_one_years_count,</if>
            <if test="paymentBase != null">payment_base,</if>
            <if test="blackList != null">black_list,</if>
            <if test="labourArbitration != null">labour_arbitration,</if>
            <if test="receivePensionBenefits != null">receive_pension_benefits,</if>
            <if test="receiveUnemploymentBenefits != null">receive_unemployment_benefits,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="custIdc != null">#{custIdc},</if>
            <if test="paymentStatus != null">#{paymentStatus},</if>
            <if test="unitType != null">#{unitType},</if>
            <if test="belongBusi != null">#{belongBusi},</if>
            <if test="economicType != null">#{economicType},</if>
            <if test="qualityLabel != null">#{qualityLabel},</if>
            <if test="paymentBaseRank != null">#{paymentBaseRank},</if>
            <if test="paymentCountRank != null">#{paymentCountRank},</if>
            <if test="paymentType != null">#{paymentType},</if>
            <if test="insuranceStatus != null">#{insuranceStatus},</if>
            <if test="recentTwoYearsCount != null">#{recentTwoYearsCount},</if>
            <if test="recentOneYearsCount != null">#{recentOneYearsCount},</if>
            <if test="paymentBase != null">#{paymentBase},</if>
            <if test="blackList != null">#{blackList},</if>
            <if test="labourArbitration != null">#{labourArbitration},</if>
            <if test="receivePensionBenefits != null">#{receivePensionBenefits},</if>
            <if test="receiveUnemploymentBenefits != null">#{receiveUnemploymentBenefits},</if>
         </trim>
    </insert>

    <update id="updateSocialSecurity" parameterType="SocialSecurity">
        update social_security
        <trim prefix="SET" suffixOverrides=",">
            <if test="custIdc != null">cust_idc = #{custIdc},</if>
            <if test="paymentStatus != null">payment_status = #{paymentStatus},</if>
            <if test="unitType != null">unit_type = #{unitType},</if>
            <if test="belongBusi != null">belong_busi = #{belongBusi},</if>
            <if test="economicType != null">economic_type = #{economicType},</if>
            <if test="qualityLabel != null">quality_label = #{qualityLabel},</if>
            <if test="paymentBaseRank != null">payment_base_rank = #{paymentBaseRank},</if>
            <if test="paymentCountRank != null">payment_count_rank = #{paymentCountRank},</if>
            <if test="paymentType != null">payment_type = #{paymentType},</if>
            <if test="insuranceStatus != null">insurance_status = #{insuranceStatus},</if>
            <if test="recentTwoYearsCount != null">recent_two_years_count = #{recentTwoYearsCount},</if>
            <if test="recentOneYearsCount != null">recent_one_years_count = #{recentOneYearsCount},</if>
            <if test="paymentBase != null">payment_base = #{paymentBase},</if>
            <if test="blackList != null">black_list = #{blackList},</if>
            <if test="labourArbitration != null">labour_arbitration = #{labourArbitration},</if>
            <if test="receivePensionBenefits != null">receive_pension_benefits = #{receivePensionBenefits},</if>
            <if test="receiveUnemploymentBenefits != null">receive_unemployment_benefits = #{receiveUnemploymentBenefits},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSocialSecurityById" parameterType="Long">
        delete from social_security where id = #{id}
    </delete>

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