<?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.ZhGroupInfoMapper">
    <resultMap type="ZhGroupInfo" id="ZhGroupInfoResult">
        <result property="id" column="id"/>
        <result property="name" column="name"/>
        <result property="zhGroupId" column="zh_group_id"/>
        <result property="zhFirmId" column="zh_firm_id"/>
    </resultMap>

    <sql id="selectZhGroupInfoVo">
        select id, name, zh_group_id, zh_firm_id
        from zh_group_info
    </sql>

    <select id="selectZhGroupInfoList" parameterType="ZhGroupInfo" resultMap="ZhGroupInfoResult">
        <include refid="selectZhGroupInfoVo"/>
        <where>
            <if test="name != null  and name != ''">
                and name like concat('%', #{name}, '%')
            </if>
            <if test="zhGroupId != null  and zhGroupId != ''">
                and zh_group_id = #{zhGroupId}
            </if>
            <if test="zhFirmId != null  and zhFirmId != ''">
                and zh_firm_id = #{zhFirmId}
            </if>
        </where>
    </select>

    <select id="selectZhGroupInfoById" parameterType="Long" resultMap="ZhGroupInfoResult">
        <include refid="selectZhGroupInfoVo"/>
        where id = #{id}
    </select>

    <insert id="insertZhGroupInfo" parameterType="ZhGroupInfo">
        insert into zh_group_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="name != null">
                name,
            </if>
            <if test="zhGroupId != null">
                zh_group_id,
            </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="zhGroupId != null">
                #{zhGroupId},
            </if>
            <if test="zhFirmId != null">
                #{zhFirmId},
            </if>
        </trim>
    </insert>

    <update id="updateZhGroupInfo" parameterType="ZhGroupInfo">
        update zh_group_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">
                name = #{name},
            </if>
            <if test="zhGroupId != null">
                zh_group_id = #{zhGroupId},
            </if>
            <if test="zhFirmId != null">
                zh_firm_id = #{zhFirmId},
            </if>
        </trim>
        where id = #{id}
    </update>

    <update id="updateZhGroupInfoByGroupId" parameterType="ZhGroupInfo">
        update zh_group_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">
                name = #{name},
            </if>
            <if test="zhFirmId != null">
                zh_firm_id = #{zhFirmId},
            </if>
        </trim>
        where zh_group_id = #{zhGroupId}
    </update>

    <delete id="deleteZhGroupInfoById" parameterType="Long">
        delete
        from zh_group_info
        where id = #{id}
    </delete>

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