<?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.system.mapper.DanganMapper">
    
    <resultMap type="Dangan" id="DanganResult">
        <result property="danganId"    column="dangan_id"    />
        <result property="danganName"    column="dangan_name"    />
        <result property="danganNo"    column="dangan_no"    />
        <result property="keyId"    column="key_id"    />

        <result property="status"    column="status"    />
        <result property="sysPerson"    column="sys_person"    />
        <result property="fileType"    column="file_type"    />
        <result property="model"    column="model"    />
        <result property="projectId"    column="project_id"    />
        <result property="brand"    column="brand"    />
        <result property="runDeviceId"    column="run_device_id"    />
        <result property="relateDeviceId"    column="relate_device_id"    />
        <result property="maintainItemId"    column="maintain_item_id"    />
        <result property="factoryTime"    column="factory_time"    />
        <result property="projectTime"    column="project_time"    />
        <result property="useUnit"    column="use_unit"    />
        <result property="medium"    column="medium"    />
        <result property="maintainTime"    column="maintain_time"    />
        <result property="pageAddress"    column="page_address"    />
        <result property="testAddress"    column="test_address"    />
        <result property="buildFactory"    column="build_factory"    />
        <result property="buildFactoryTime"    column="build_factory_time"    />
        <result property="factoryPerson"    column="factory_person"    />
        <result property="factoryPersonPhone"    column="factory_person_phone"    />
        <result property="language"    column="language"    />
        <result property="serverIp"    column="server_ip"    />
        <result property="serverLocation"    column="server_location"    />
        <result property="serverInfo"    column="server_info"    />
        <result property="serverBasedYesNo"    column="server_based_yes_no"    />
        <result property="opsPerson"    column="ops_person"    />
        <result property="chargeUnit"    column="charge_unit"    />
        <result property="mode"    column="mode"    />
        <result property="fileInfo"    column="file_info"    />
        <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="selectDanganVo">
        select dangan_id,
        key_id,
        dangan_no,dangan_name, status,
         sys_person, file_type, model, project_id, brand, run_device_id, relate_device_id, maintain_item_id, factory_time, project_time, use_unit, medium, maintain_time, page_address, test_address, build_factory, build_factory_time, factory_person, factory_person_phone, language, server_ip, server_location, server_info, server_based_yes_no, ops_person, charge_unit, mode, file_info, create_by, create_time, update_by, update_time, remark from sys_dangan
    </sql>

    <select id="selectDanganList" parameterType="Dangan" resultMap="DanganResult">
        <include refid="selectDanganVo"/>
        <where>  
            <if test="danganName != null  and danganName != ''"> and dangan_name like concat('%', #{danganName}, '%')</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="danganNo != null  and danganNo != ''"> and dangan_no = #{danganNo}</if>
            <if test="keyId != null  and keyId != ''"> and key_id = #{keyId}</if>

            <if test="sysPerson != null  and sysPerson != ''"> and sys_person = #{sysPerson}</if>
            <if test="fileType != null  and fileType != ''"> and file_type = #{fileType}</if>
            <if test="model != null  and model != ''"> and model = #{model}</if>
            <if test="projectId != null  and projectId != ''"> and project_id = #{projectId}</if>
            <if test="brand != null  and brand != ''"> and brand = #{brand}</if>
            <if test="runDeviceId != null  and runDeviceId != ''"> and run_device_id = #{runDeviceId}</if>
            <if test="relateDeviceId != null  and relateDeviceId != ''"> and relate_device_id = #{relateDeviceId}</if>
            <if test="maintainItemId != null  and maintainItemId != ''"> and maintain_item_id = #{maintainItemId}</if>
            <if test="factoryTime != null  and factoryTime != ''"> and factory_time = #{factoryTime}</if>
            <if test="projectTime != null  and projectTime != ''"> and project_time = #{projectTime}</if>
            <if test="useUnit != null  and useUnit != ''"> and use_unit = #{useUnit}</if>
            <if test="medium != null  and medium != ''"> and medium = #{medium}</if>
            <if test="maintainTime != null "> and maintain_time = #{maintainTime}</if>
            <if test="pageAddress != null  and pageAddress != ''"> and page_address = #{pageAddress}</if>
            <if test="testAddress != null  and testAddress != ''"> and test_address = #{testAddress}</if>
            <if test="buildFactory != null  and buildFactory != ''"> and build_factory = #{buildFactory}</if>
            <if test="buildFactoryTime != null "> and build_factory_time = #{buildFactoryTime}</if>
            <if test="factoryPerson != null  and factoryPerson != ''"> and factory_person = #{factoryPerson}</if>
            <if test="factoryPersonPhone != null  and factoryPersonPhone != ''"> and factory_person_phone = #{factoryPersonPhone}</if>
            <if test="language != null  and language != ''"> and language = #{language}</if>
            <if test="serverIp != null  and serverIp != ''"> and server_ip = #{serverIp}</if>
            <if test="serverLocation != null  and serverLocation != ''"> and server_location = #{serverLocation}</if>
            <if test="serverInfo != null  and serverInfo != ''"> and server_info = #{serverInfo}</if>
            <if test="serverBasedYesNo != null  and serverBasedYesNo != ''"> and server_based_yes_no = #{serverBasedYesNo}</if>
            <if test="opsPerson != null  and opsPerson != ''"> and ops_person = #{opsPerson}</if>
            <if test="chargeUnit != null  and chargeUnit != ''"> and charge_unit = #{chargeUnit}</if>
            <if test="mode != null  and mode != ''"> and mode = #{mode}</if>
            <if test="fileInfo != null  and fileInfo != ''"> and file_info = #{fileInfo}</if>
        </where>
    </select>
    
    <select id="selectDanganById" parameterType="Long" resultMap="DanganResult">
        <include refid="selectDanganVo"/>
        where dangan_id = #{danganId}
    </select>
        
    <insert id="insertDangan" parameterType="Dangan" useGeneratedKeys="true" keyProperty="danganId">
        insert into sys_dangan
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="danganName != null">dangan_name,</if>
            <if test="status != null and status != ''">status,</if>
            <if test="danganNo != null and danganNo != ''">dangan_no,</if>
            <if test="keyId != null and keyId != ''">key_id,</if>

            <if test="sysPerson != null">sys_person,</if>
            <if test="fileType != null">file_type,</if>
            <if test="model != null">model,</if>
            <if test="projectId != null">project_id,</if>
            <if test="brand != null">brand,</if>
            <if test="runDeviceId != null">run_device_id,</if>
            <if test="relateDeviceId != null">relate_device_id,</if>
            <if test="maintainItemId != null">maintain_item_id,</if>
            <if test="factoryTime != null">factory_time,</if>
            <if test="projectTime != null">project_time,</if>
            <if test="useUnit != null">use_unit,</if>
            <if test="medium != null">medium,</if>
            <if test="maintainTime != null">maintain_time,</if>
            <if test="pageAddress != null">page_address,</if>
            <if test="testAddress != null">test_address,</if>
            <if test="buildFactory != null">build_factory,</if>
            <if test="buildFactoryTime != null">build_factory_time,</if>
            <if test="factoryPerson != null">factory_person,</if>
            <if test="factoryPersonPhone != null">factory_person_phone,</if>
            <if test="language != null">language,</if>
            <if test="serverIp != null">server_ip,</if>
            <if test="serverLocation != null">server_location,</if>
            <if test="serverInfo != null">server_info,</if>
            <if test="serverBasedYesNo != null">server_based_yes_no,</if>
            <if test="opsPerson != null">ops_person,</if>
            <if test="chargeUnit != null">charge_unit,</if>
            <if test="mode != null">mode,</if>
            <if test="fileInfo != null">file_info,</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="danganName != null">#{danganName},</if>
            <if test="status != null and status != ''">#{status},</if>
            <if test="danganNo != null and danganNo != ''">#{danganNo},</if>
            <if test="keyId != null and keyId != ''">#{keyId},</if>

            <if test="sysPerson != null">#{sysPerson},</if>
            <if test="fileType != null">#{fileType},</if>
            <if test="model != null">#{model},</if>
            <if test="projectId != null">#{projectId},</if>
            <if test="brand != null">#{brand},</if>
            <if test="runDeviceId != null">#{runDeviceId},</if>
            <if test="relateDeviceId != null">#{relateDeviceId},</if>
            <if test="maintainItemId != null">#{maintainItemId},</if>
            <if test="factoryTime != null">#{factoryTime},</if>
            <if test="projectTime != null">#{projectTime},</if>
            <if test="useUnit != null">#{useUnit},</if>
            <if test="medium != null">#{medium},</if>
            <if test="maintainTime != null">#{maintainTime},</if>
            <if test="pageAddress != null">#{pageAddress},</if>
            <if test="testAddress != null">#{testAddress},</if>
            <if test="buildFactory != null">#{buildFactory},</if>
            <if test="buildFactoryTime != null">#{buildFactoryTime},</if>
            <if test="factoryPerson != null">#{factoryPerson},</if>
            <if test="factoryPersonPhone != null">#{factoryPersonPhone},</if>
            <if test="language != null">#{language},</if>
            <if test="serverIp != null">#{serverIp},</if>
            <if test="serverLocation != null">#{serverLocation},</if>
            <if test="serverInfo != null">#{serverInfo},</if>
            <if test="serverBasedYesNo != null">#{serverBasedYesNo},</if>
            <if test="opsPerson != null">#{opsPerson},</if>
            <if test="chargeUnit != null">#{chargeUnit},</if>
            <if test="mode != null">#{mode},</if>
            <if test="fileInfo != null">#{fileInfo},</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="updateDangan" parameterType="Dangan">
        update sys_dangan
        <trim prefix="SET" suffixOverrides=",">
            <if test="danganName != null">dangan_name = #{danganName},</if>
            <if test="status != null and status != ''">status = #{status},</if>
            <if test="danganNo != null and danganNo != ''">dangan_no = #{danganNo},</if>
            <if test="keyId != null and keyId != ''">key_id = #{keyId},</if>

            <if test="sysPerson != null">sys_person = #{sysPerson},</if>
            <if test="fileType != null">file_type = #{fileType},</if>
            <if test="model != null">model = #{model},</if>
            <if test="projectId != null">project_id = #{projectId},</if>
            <if test="brand != null">brand = #{brand},</if>
            <if test="runDeviceId != null">run_device_id = #{runDeviceId},</if>
            <if test="relateDeviceId != null">relate_device_id = #{relateDeviceId},</if>
            <if test="maintainItemId != null">maintain_item_id = #{maintainItemId},</if>
            <if test="factoryTime != null">factory_time = #{factoryTime},</if>
            <if test="projectTime != null">project_time = #{projectTime},</if>
            <if test="useUnit != null">use_unit = #{useUnit},</if>
            <if test="medium != null">medium = #{medium},</if>
            <if test="maintainTime != null">maintain_time = #{maintainTime},</if>
            <if test="pageAddress != null">page_address = #{pageAddress},</if>
            <if test="testAddress != null">test_address = #{testAddress},</if>
            <if test="buildFactory != null">build_factory = #{buildFactory},</if>
            <if test="buildFactoryTime != null">build_factory_time = #{buildFactoryTime},</if>
            <if test="factoryPerson != null">factory_person = #{factoryPerson},</if>
            <if test="factoryPersonPhone != null">factory_person_phone = #{factoryPersonPhone},</if>
            <if test="language != null">language = #{language},</if>
            <if test="serverIp != null">server_ip = #{serverIp},</if>
            <if test="serverLocation != null">server_location = #{serverLocation},</if>
            <if test="serverInfo != null">server_info = #{serverInfo},</if>
            <if test="serverBasedYesNo != null">server_based_yes_no = #{serverBasedYesNo},</if>
            <if test="opsPerson != null">ops_person = #{opsPerson},</if>
            <if test="chargeUnit != null">charge_unit = #{chargeUnit},</if>
            <if test="mode != null">mode = #{mode},</if>
            <if test="fileInfo != null">file_info = #{fileInfo},</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 dangan_id = #{danganId}
    </update>

    <delete id="deleteDanganById" parameterType="Long">
        delete from sys_dangan where dangan_id = #{danganId}
    </delete>

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

    <select id="checkDanganNameUnique" parameterType="String" resultType="int">
		select count(1) from sys_dangan where dangan_name=#{danganName} limit 1
	</select>

    <select id="selectDanganByDanganName" parameterType="String" resultMap="DanganResult">
        <include refid="selectDanganVo"/>
        where dangan_no = #{danganName}
    </select>
</mapper>