<?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.project.system.mapper.ZhCompanyInfoMapper">
    
    <resultMap type="ZhCompanyInfo" id="ZhCompanyInfoResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="zhFirmId"    column="zh_firm_id"    />
    </resultMap>

    <sql id="selectZhCompanyInfoVo">
        select id, name, zh_firm_id from zh_company_info
    </sql>

    <select id="selectZhCompanyInfoList" parameterType="ZhCompanyInfo" resultMap="ZhCompanyInfoResult">
        <include refid="selectZhCompanyInfoVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="zhFirmId != null  and zhFirmId != ''"> and zh_firm_id = #{zhFirmId}</if>
        </where>
    </select>
    
    <select id="selectZhCompanyInfoById" parameterType="Long" resultMap="ZhCompanyInfoResult">
        <include refid="selectZhCompanyInfoVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertZhCompanyInfo" parameterType="ZhCompanyInfo">
        insert into zh_company_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="name != null">name,</if>
            <if test="zhFirmId != null">zh_firm_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="name != null">#{name},</if>
            <if test="zhFirmId != null">#{zhFirmId},</if>
         </trim>
    </insert>

    <update id="updateZhCompanyInfo" parameterType="ZhCompanyInfo">
        update zh_company_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="zhFirmId != null">zh_firm_id = #{zhFirmId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteZhCompanyInfoById" parameterType="Long">
        delete from zh_company_info where id = #{id}
    </delete>

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