<?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.manage.mapper.NetworkManageMapper">
    
    <resultMap type="NetworkManage" id="NetworkManageResult">
        <result property="networkId"    column="network_id"    />
        <result property="networkName"    column="network_name"    />
        <result property="networkCardName"    column="network_card_name"    />
        <result property="networkIp"    column="network_ip"    />
        <result property="subnetMask"    column="subnet_mask"    />
        <result property="defaultGateway"    column="default_gateway"    />
        <result property="physicalAddress"    column="physical_address"    />
        <result property="allocationScheme"    column="allocation_scheme"    />
        <result property="domainNameServer"    column="domain_name_server"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectNetworkManageVo">
        select network_id, network_name, network_card_name, network_ip, subnet_mask, default_gateway, physical_address, allocation_scheme, domain_name_server, del_flag, create_by, create_time, update_by, update_time, remark from network_manage
    </sql>

    <select id="selectNetworkManageList" parameterType="NetworkManage" resultMap="NetworkManageResult">
        <include refid="selectNetworkManageVo"/>
        <where>  
            <if test="networkName != null  and networkName != ''"> and network_name like concat('%', #{networkName}, '%')</if>
            <if test="networkCardName != null  and networkCardName != ''"> and network_card_name like concat('%', #{networkCardName}, '%')</if>
            <if test="networkIp != null  and networkIp != ''"> and network_ip = #{networkIp}</if>
            <if test="subnetMask != null  and subnetMask != ''"> and subnet_mask = #{subnetMask}</if>
            <if test="defaultGateway != null  and defaultGateway != ''"> and default_gateway = #{defaultGateway}</if>
            <if test="physicalAddress != null  and physicalAddress != ''"> and physical_address = #{physicalAddress}</if>
            <if test="allocationScheme != null  and allocationScheme != ''"> and allocation_scheme = #{allocationScheme}</if>
            <if test="domainNameServer != null  and domainNameServer != ''"> and domain_name_server = #{domainNameServer}</if>
        </where>
    </select>
    
    <select id="selectNetworkManageByNetworkId" parameterType="Long" resultMap="NetworkManageResult">
        <include refid="selectNetworkManageVo"/>
        where network_id = #{networkId}
    </select>

    <insert id="insertNetworkManage" parameterType="NetworkManage" useGeneratedKeys="true" keyProperty="networkId">
        insert into network_manage
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="networkName != null">network_name,</if>
            <if test="networkCardName != null">network_card_name,</if>
            <if test="networkIp != null">network_ip,</if>
            <if test="subnetMask != null">subnet_mask,</if>
            <if test="defaultGateway != null">default_gateway,</if>
            <if test="physicalAddress != null">physical_address,</if>
            <if test="allocationScheme != null">allocation_scheme,</if>
            <if test="domainNameServer != null">domain_name_server,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</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="networkName != null">#{networkName},</if>
            <if test="networkCardName != null">#{networkCardName},</if>
            <if test="networkIp != null">#{networkIp},</if>
            <if test="subnetMask != null">#{subnetMask},</if>
            <if test="defaultGateway != null">#{defaultGateway},</if>
            <if test="physicalAddress != null">#{physicalAddress},</if>
            <if test="allocationScheme != null">#{allocationScheme},</if>
            <if test="domainNameServer != null">#{domainNameServer},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateNetworkManage" parameterType="NetworkManage">
        update network_manage
        <trim prefix="SET" suffixOverrides=",">
            <if test="networkName != null">network_name = #{networkName},</if>
            <if test="networkCardName != null">network_card_name = #{networkCardName},</if>
            <if test="networkIp != null">network_ip = #{networkIp},</if>
            <if test="subnetMask != null">subnet_mask = #{subnetMask},</if>
            <if test="defaultGateway != null">default_gateway = #{defaultGateway},</if>
            <if test="physicalAddress != null">physical_address = #{physicalAddress},</if>
            <if test="allocationScheme != null">allocation_scheme = #{allocationScheme},</if>
            <if test="domainNameServer != null">domain_name_server = #{domainNameServer},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</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 network_id = #{networkId}
    </update>

    <delete id="deleteNetworkManageByNetworkId" parameterType="Long">
        delete from network_manage where network_id = #{networkId}
    </delete>

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