<?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.zongzhi.mapper.TcZhongdianEnterpriseMapper">
    
    <resultMap type="TcZhongdianEnterprise" id="TcZhongdianEnterpriseResult">
        <result property="id"    column="id"    />
        <result property="areaId"    column="area_id"    />
        <result property="enterpriseName"    column="enterprise_name"    />
        <result property="enterpriseType"    column="enterprise_type"    />
        <result property="networkYewu"    column="network_yewu"    />
        <result property="jianguanBumen"    column="jianguan_bumen"    />
        <result property="address"    column="address"    />
        <result property="linkMan"    column="link_man"    />
        <result property="phoneNum"    column="phone_num"    />
        <result property="productName"    column="product_name"    />
        <result property="dns"    column="dns"    />
        <result property="createId"    column="create_id"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateId"    column="update_id"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectTcZhongdianEnterpriseVo">
        select id, area_id, enterprise_name, enterprise_type, network_yewu, jianguan_bumen, address, link_man, phone_num, product_name, dns, create_id, create_by, create_time, update_id, update_by, update_time, remark from tc_zhongdian_enterprise
    </sql>

    <select id="selectTcZhongdianEnterpriseList" parameterType="TcZhongdianEnterprise" resultMap="TcZhongdianEnterpriseResult">
        <include refid="selectTcZhongdianEnterpriseVo"/>
        <where>  
            <if test="areaId != null "> and area_id = #{areaId}</if>
            <if test="enterpriseName != null  and enterpriseName != ''"> and enterprise_name like concat('%', #{enterpriseName}, '%')</if>
            <if test="enterpriseType != null "> and enterprise_type = #{enterpriseType}</if>
            <if test="networkYewu != null "> and network_yewu = #{networkYewu}</if>
            <if test="jianguanBumen != null  and jianguanBumen != ''"> and jianguan_bumen = #{jianguanBumen}</if>
            <if test="address != null  and address != ''"> and address = #{address}</if>
            <if test="linkMan != null  and linkMan != ''"> and link_man = #{linkMan}</if>
            <if test="phoneNum != null  and phoneNum != ''"> and phone_num = #{phoneNum}</if>
            <if test="productName != null  and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
            <if test="dns != null  and dns != ''"> and dns = #{dns}</if>
            <if test="createId != null "> and create_id = #{createId}</if>
            <if test="updateId != null "> and update_id = #{updateId}</if>
        </where>
    </select>
    
    <select id="selectTcZhongdianEnterpriseById" parameterType="Long" resultMap="TcZhongdianEnterpriseResult">
        <include refid="selectTcZhongdianEnterpriseVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTcZhongdianEnterprise" parameterType="TcZhongdianEnterprise" useGeneratedKeys="true" keyProperty="id">
        insert into tc_zhongdian_enterprise
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="areaId != null">area_id,</if>
            <if test="enterpriseName != null">enterprise_name,</if>
            <if test="enterpriseType != null">enterprise_type,</if>
            <if test="networkYewu != null">network_yewu,</if>
            <if test="jianguanBumen != null">jianguan_bumen,</if>
            <if test="address != null">address,</if>
            <if test="linkMan != null">link_man,</if>
            <if test="phoneNum != null">phone_num,</if>
            <if test="productName != null">product_name,</if>
            <if test="dns != null">dns,</if>
            <if test="createId != null">create_id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateId != null">update_id,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="areaId != null">#{areaId},</if>
            <if test="enterpriseName != null">#{enterpriseName},</if>
            <if test="enterpriseType != null">#{enterpriseType},</if>
            <if test="networkYewu != null">#{networkYewu},</if>
            <if test="jianguanBumen != null">#{jianguanBumen},</if>
            <if test="address != null">#{address},</if>
            <if test="linkMan != null">#{linkMan},</if>
            <if test="phoneNum != null">#{phoneNum},</if>
            <if test="productName != null">#{productName},</if>
            <if test="dns != null">#{dns},</if>
            <if test="createId != null">#{createId},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateId != null">#{updateId},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateTcZhongdianEnterprise" parameterType="TcZhongdianEnterprise">
        update tc_zhongdian_enterprise
        <trim prefix="SET" suffixOverrides=",">
            <if test="areaId != null">area_id = #{areaId},</if>
            <if test="enterpriseName != null">enterprise_name = #{enterpriseName},</if>
            <if test="enterpriseType != null">enterprise_type = #{enterpriseType},</if>
            <if test="networkYewu != null">network_yewu = #{networkYewu},</if>
            <if test="jianguanBumen != null">jianguan_bumen = #{jianguanBumen},</if>
            <if test="address != null">address = #{address},</if>
            <if test="linkMan != null">link_man = #{linkMan},</if>
            <if test="phoneNum != null">phone_num = #{phoneNum},</if>
            <if test="productName != null">product_name = #{productName},</if>
            <if test="dns != null">dns = #{dns},</if>
            <if test="createId != null">create_id = #{createId},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateId != null">update_id = #{updateId},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTcZhongdianEnterpriseById" parameterType="Long">
        delete from tc_zhongdian_enterprise where id = #{id}
    </delete>

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