<?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.CmcPartyAMapper">
    
    <resultMap type="CmcPartyA" id="CmcPartyAResult">
        <result property="partyAId"    column="party_a_id"    />
        <result property="partyAName"    column="party_a_name"    />
    </resultMap>

    <sql id="selectCmcPartyAVo">
        select party_a_id, party_a_name from cmc_party_a
    </sql>

    <select id="selectCmcPartyAList" parameterType="CmcPartyA" resultMap="CmcPartyAResult">
        <include refid="selectCmcPartyAVo"/>
        <where>  
            <if test="partyAName != null  and partyAName != ''"> and party_a_name like concat('%', #{partyAName}, '%')</if>
        </where>
        order by party_a_id + 0 asc
    </select>
    
    <select id="selectCmcPartyAByPartyAId" parameterType="String" resultMap="CmcPartyAResult">
        <include refid="selectCmcPartyAVo"/>
        where party_a_id = #{partyAId}
    </select>
        
    <insert id="insertCmcPartyA" parameterType="CmcPartyA">
        insert into cmc_party_a
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="partyAId != null">party_a_id,</if>
            <if test="partyAName != null">party_a_name,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="partyAId != null">#{partyAId},</if>
            <if test="partyAName != null">#{partyAName},</if>
         </trim>
    </insert>

    <update id="updateCmcPartyA" parameterType="CmcPartyA">
        update cmc_party_a
        <trim prefix="SET" suffixOverrides=",">
            <if test="partyAName != null">party_a_name = #{partyAName},</if>
        </trim>
        where party_a_id = #{partyAId}
    </update>

    <delete id="deleteCmcPartyAByPartyAId" parameterType="String">
        delete from cmc_party_a where party_a_id = #{partyAId}
    </delete>

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