<?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.oa.mapper.CmcPartnerMapper">

    <resultMap type="CmcPartner" id="CmcPartnerResult">
        <result property="partnerId"    column="partner_id"    />
        <result property="partnerName"    column="partner_name"    />
        <result property="contactPerson"    column="contact_person"    />
        <result property="telephone"    column="telephone"    />
        <result property="qualification"    column="qualification"    />
        <result property="inWorker"    column="in_worker"    />
        <result property="outWorker"    column="out_worker"    />
        <result property="equipment"    column="equipment"    />
        <result property="strength"    column="strength"    />
        <result property="fulfill"    column="fulfill"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectCmcPartnerVo">
        select partner_id, partner_name, contact_person, telephone, qualification, in_worker, out_worker, equipment, strength, fulfill, remark from cmc_partner
    </sql>

    <select id="selectCmcPartnerList" parameterType="CmcPartner" resultMap="CmcPartnerResult">
        <include refid="selectCmcPartnerVo"/>
        <where>
            <if test="partnerName != null  and partnerName != ''"> and partner_name like concat('%', #{partnerName}, '%')</if>
            <if test="contactPerson != null  and contactPerson != ''"> and contact_person = #{contactPerson}</if>
            <if test="telephone != null  and telephone != ''"> and telephone = #{telephone}</if>
            <if test="qualification != null  and qualification != ''"> and qualification = #{qualification}</if>
            <if test="inWorker != null "> and in_worker = #{inWorker}</if>
            <if test="outWorker != null "> and out_worker = #{outWorker}</if>
            <if test="equipment != null  and equipment != ''"> and equipment = #{equipment}</if>
            <if test="strength != null  and strength != ''"> and strength = #{strength}</if>
            <if test="fulfill != null  and fulfill != ''"> and fulfill = #{fulfill}</if>
        </where>
        order by partner_id + 0 asc
    </select>

    <select id="selectCmcPartnerByPartnerId" parameterType="String" resultMap="CmcPartnerResult">
        <include refid="selectCmcPartnerVo"/>
        where partner_id = #{partnerId}
    </select>

    <insert id="insertCmcPartner" parameterType="CmcPartner">
        insert into cmc_partner
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="partnerId != null">partner_id,</if>
            <if test="partnerName != null">partner_name,</if>
            <if test="contactPerson != null">contact_person,</if>
            <if test="telephone != null">telephone,</if>
            <if test="qualification != null">qualification,</if>
            <if test="inWorker != null">in_worker,</if>
            <if test="outWorker != null">out_worker,</if>
            <if test="equipment != null">equipment,</if>
            <if test="strength != null">strength,</if>
            <if test="fulfill != null">fulfill,</if>
            <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="partnerId != null">#{partnerId},</if>
            <if test="partnerName != null">#{partnerName},</if>
            <if test="contactPerson != null">#{contactPerson},</if>
            <if test="telephone != null">#{telephone},</if>
            <if test="qualification != null">#{qualification},</if>
            <if test="inWorker != null">#{inWorker},</if>
            <if test="outWorker != null">#{outWorker},</if>
            <if test="equipment != null">#{equipment},</if>
            <if test="strength != null">#{strength},</if>
            <if test="fulfill != null">#{fulfill},</if>
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>

    <update id="updateCmcPartner" parameterType="CmcPartner">
        update cmc_partner
        <trim prefix="SET" suffixOverrides=",">
            <if test="partnerName != null">partner_name = #{partnerName},</if>
            <if test="contactPerson != null">contact_person = #{contactPerson},</if>
            <if test="telephone != null">telephone = #{telephone},</if>
            <if test="qualification != null">qualification = #{qualification},</if>
            <if test="inWorker != null">in_worker = #{inWorker},</if>
            <if test="outWorker != null">out_worker = #{outWorker},</if>
            <if test="equipment != null">equipment = #{equipment},</if>
            <if test="strength != null">strength = #{strength},</if>
            <if test="fulfill != null">fulfill = #{fulfill},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where partner_id = #{partnerId}
    </update>

    <delete id="deleteCmcPartnerByPartnerId" parameterType="String">
        delete from cmc_partner where partner_id = #{partnerId}
    </delete>

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