<?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.biz.mapper.BizPatentValidOgMapper">
    
    <resultMap type="com.ruoyi.biz.domain.BizPatentValidOg" id="BizPatentValidOgResult">
        <result property="id"    column="id"    />
        <result property="an"    column="an"    />
        <result property="databaseDate"    column="database_date"    />
        <result property="ad"    column="ad"    />
        <result property="patentName"    column="patent_name"    />
        <result property="agentOrgCode"    column="agent_org_code"    />
        <result property="agentOrgName"    column="agent_org_name"    />
        <result property="ipc"    column="ipc"    />
        <result property="peopleName"    column="people_name"    />
        <result property="zipCode"    column="zip_code"    />
        <result property="address"    column="address"    />
        <result property="pts"    column="pts"    />
        <result property="ppType"    column="pp_type"    />
        <result property="provinceName"    column="province_name"    />
        <result property="cityName"    column="city_name"    />
        <result property="districtName"    column="district_name"    />
        <result property="batch"    column="batch"    />
        <result property="ogTag"    column="og_tag"    />
        <result property="ogId"    column="og_id"    />
        <result property="createUser"    column="create_user"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectBizPatentValidOgVo">
        select id, an, database_date, ad, patent_name, agent_org_code, agent_org_name, ipc, people_name, zip_code, address, pts, pp_type, province_name, city_name, district_name, batch, og_tag, og_id, create_user, create_time from biz_patent_valid_og
    </sql>

    <select id="selectBizPatentValidOgList" parameterType="com.ruoyi.biz.domain.BizPatentValidOg" resultMap="BizPatentValidOgResult">
        <include refid="selectBizPatentValidOgVo"/>
        <where>  
            <if test="an != null  and an != ''"> and an = #{an}</if>
            <if test="databaseDate != null  and databaseDate != ''"> and database_date = #{databaseDate}</if>
            <if test="ad != null  and ad != ''"> and ad = #{ad}</if>
            <if test="patentName != null  and patentName != ''"> and patent_name like concat('%', #{patentName}, '%')</if>
            <if test="agentOrgCode != null  and agentOrgCode != ''"> and agent_org_code = #{agentOrgCode}</if>
            <if test="agentOrgName != null  and agentOrgName != ''"> and agent_org_name like concat('%', #{agentOrgName}, '%')</if>
            <if test="ipc != null  and ipc != ''"> and ipc = #{ipc}</if>
            <if test="peopleName != null  and peopleName != ''"> and people_name like concat('%', #{peopleName}, '%')</if>
            <if test="zipCode != null  and zipCode != ''"> and zip_code = #{zipCode}</if>
            <if test="address != null  and address != ''"> and address = #{address}</if>
            <if test="pts != null  and pts != ''"> and pts = #{pts}</if>
            <if test="ppType != null  and ppType != ''"> and pp_type = #{ppType}</if>
            <if test="provinceName != null  and provinceName != ''"> and province_name like concat('%', #{provinceName}, '%')</if>
            <if test="cityName != null  and cityName != ''"> and city_name like concat('%', #{cityName}, '%')</if>
            <if test="districtName != null  and districtName != ''"> and district_name like concat('%', #{districtName}, '%')</if>
            <if test="batch != null  and batch != ''"> and batch = #{batch}</if>
            <if test="ogTag != null  and ogTag != ''"> and og_tag = #{ogTag}</if>
            <if test="ogId != null  and ogId != ''"> and og_id = #{ogId}</if>
            <if test="createUser != null  and createUser != ''"> and create_user = #{createUser}</if>
        </where>
    </select>
    
    <select id="selectBizPatentValidOgById" parameterType="String" resultMap="BizPatentValidOgResult">
        <include refid="selectBizPatentValidOgVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertBizPatentValidOg" parameterType="com.ruoyi.biz.domain.BizPatentValidOg">
        insert into biz_patent_valid_og
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="an != null">an,</if>
            <if test="databaseDate != null">database_date,</if>
            <if test="ad != null">ad,</if>
            <if test="patentName != null">patent_name,</if>
            <if test="agentOrgCode != null">agent_org_code,</if>
            <if test="agentOrgName != null">agent_org_name,</if>
            <if test="ipc != null">ipc,</if>
            <if test="peopleName != null">people_name,</if>
            <if test="zipCode != null">zip_code,</if>
            <if test="address != null">address,</if>
            <if test="pts != null">pts,</if>
            <if test="ppType != null">pp_type,</if>
            <if test="provinceName != null">province_name,</if>
            <if test="cityName != null">city_name,</if>
            <if test="districtName != null">district_name,</if>
            <if test="batch != null">batch,</if>
            <if test="ogTag != null">og_tag,</if>
            <if test="ogId != null">og_id,</if>
            <if test="createUser != null">create_user,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="an != null">#{an},</if>
            <if test="databaseDate != null">#{databaseDate},</if>
            <if test="ad != null">#{ad},</if>
            <if test="patentName != null">#{patentName},</if>
            <if test="agentOrgCode != null">#{agentOrgCode},</if>
            <if test="agentOrgName != null">#{agentOrgName},</if>
            <if test="ipc != null">#{ipc},</if>
            <if test="peopleName != null">#{peopleName},</if>
            <if test="zipCode != null">#{zipCode},</if>
            <if test="address != null">#{address},</if>
            <if test="pts != null">#{pts},</if>
            <if test="ppType != null">#{ppType},</if>
            <if test="provinceName != null">#{provinceName},</if>
            <if test="cityName != null">#{cityName},</if>
            <if test="districtName != null">#{districtName},</if>
            <if test="batch != null">#{batch},</if>
            <if test="ogTag != null">#{ogTag},</if>
            <if test="ogId != null">#{ogId},</if>
            <if test="createUser != null">#{createUser},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateBizPatentValidOg" parameterType="com.ruoyi.biz.domain.BizPatentValidOg">
        update biz_patent_valid_og
        <trim prefix="SET" suffixOverrides=",">
            <if test="an != null">an = #{an},</if>
            <if test="databaseDate != null">database_date = #{databaseDate},</if>
            <if test="ad != null">ad = #{ad},</if>
            <if test="patentName != null">patent_name = #{patentName},</if>
            <if test="agentOrgCode != null">agent_org_code = #{agentOrgCode},</if>
            <if test="agentOrgName != null">agent_org_name = #{agentOrgName},</if>
            <if test="ipc != null">ipc = #{ipc},</if>
            <if test="peopleName != null">people_name = #{peopleName},</if>
            <if test="zipCode != null">zip_code = #{zipCode},</if>
            <if test="address != null">address = #{address},</if>
            <if test="pts != null">pts = #{pts},</if>
            <if test="ppType != null">pp_type = #{ppType},</if>
            <if test="provinceName != null">province_name = #{provinceName},</if>
            <if test="cityName != null">city_name = #{cityName},</if>
            <if test="districtName != null">district_name = #{districtName},</if>
            <if test="batch != null">batch = #{batch},</if>
            <if test="ogTag != null">og_tag = #{ogTag},</if>
            <if test="ogId != null">og_id = #{ogId},</if>
            <if test="createUser != null">create_user = #{createUser},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBizPatentValidOgById" parameterType="String">
        delete from biz_patent_valid_og where id = #{id}
    </delete>

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

    <!-- 逻辑删除 -->
    <update id="setDeleteById">
        update biz_patent_valid_og set delete_flag="Y",update_time=sysdate(),update_user_id=#{operId},update_user_name=#{operName} where id = #{id}
    </update>

    <!-- 逻辑删除 -->
    <update id="setDeleteByIds">
        update biz_patent_valid_og set delete_flag="Y",update_time=sysdate(),update_user_id=#{operId},update_user_name=#{operName} where id in
        <foreach item="id" collection="ids" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
</mapper>