<?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.ems.mapper.AdmEmsDeviceRbookMapper">
    
    <resultMap type="com.ruoyi.ems.domain.AdmEmsDeviceRbook" id="AdmEmsDeviceRbookResult">
        <result property="id"    column="id"    />
        <result property="recordCode"    column="record_code"    />
        <result property="objType"    column="obj_type"    />
        <result property="objCode"    column="obj_code"    />
        <result property="objName"    column="obj_name"    />
        <result property="insLocation"    column="ins_location"    />
        <result property="maintainTitle"    column="maintain_title"    />
        <result property="maintainContent"    column="maintain_content"    />
        <result property="maintainPerson"    column="maintain_person"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectAdmEmsDeviceRbookVo">
        select id, record_code, obj_type, obj_code, obj_name, ins_location, maintain_title, maintain_content, maintain_person, create_time, update_time from adm_ems_device_rbook
    </sql>

    <select id="selectAdmEmsDeviceRbookList" parameterType="com.ruoyi.ems.domain.AdmEmsDeviceRbook" resultMap="AdmEmsDeviceRbookResult">
        <include refid="selectAdmEmsDeviceRbookVo"/>
        <where>  
            <if test="recordCode != null  and recordCode != ''"> and record_code = #{recordCode}</if>
            <if test="objType != null "> and obj_type = #{objType}</if>
            <if test="objCode != null  and objCode != ''"> and obj_code = #{objCode}</if>
            <if test="objName != null  and objName != ''"> and obj_name like concat('%', #{objName}, '%')</if>
            <if test="insLocation != null  and insLocation != ''"> and ins_location = #{insLocation}</if>
            <if test="maintainTitle != null  and maintainTitle != ''"> and maintain_title = #{maintainTitle}</if>
            <if test="maintainContent != null  and maintainContent != ''"> and maintain_content = #{maintainContent}</if>
            <if test="maintainPerson != null  and maintainPerson != ''"> and maintain_person = #{maintainPerson}</if>
        </where>
    </select>
    
    <select id="selectAdmEmsDeviceRbookById" parameterType="Long" resultMap="AdmEmsDeviceRbookResult">
        <include refid="selectAdmEmsDeviceRbookVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertAdmEmsDeviceRbook" parameterType="com.ruoyi.ems.domain.AdmEmsDeviceRbook" useGeneratedKeys="true" keyProperty="id">
        insert into adm_ems_device_rbook
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="recordCode != null and recordCode != ''">record_code,</if>
            <if test="objType != null">obj_type,</if>
            <if test="objCode != null and objCode != ''">obj_code,</if>
            <if test="objName != null">obj_name,</if>
            <if test="insLocation != null">ins_location,</if>
            <if test="maintainTitle != null and maintainTitle != ''">maintain_title,</if>
            <if test="maintainContent != null">maintain_content,</if>
            <if test="maintainPerson != null">maintain_person,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="recordCode != null and recordCode != ''">#{recordCode},</if>
            <if test="objType != null">#{objType},</if>
            <if test="objCode != null and objCode != ''">#{objCode},</if>
            <if test="objName != null">#{objName},</if>
            <if test="insLocation != null">#{insLocation},</if>
            <if test="maintainTitle != null and maintainTitle != ''">#{maintainTitle},</if>
            <if test="maintainContent != null">#{maintainContent},</if>
            <if test="maintainPerson != null">#{maintainPerson},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateAdmEmsDeviceRbook" parameterType="com.ruoyi.ems.domain.AdmEmsDeviceRbook">
        update adm_ems_device_rbook
        <trim prefix="SET" suffixOverrides=",">
            <if test="recordCode != null and recordCode != ''">record_code = #{recordCode},</if>
            <if test="objType != null">obj_type = #{objType},</if>
            <if test="objCode != null and objCode != ''">obj_code = #{objCode},</if>
            <if test="objName != null">obj_name = #{objName},</if>
            <if test="insLocation != null">ins_location = #{insLocation},</if>
            <if test="maintainTitle != null and maintainTitle != ''">maintain_title = #{maintainTitle},</if>
            <if test="maintainContent != null">maintain_content = #{maintainContent},</if>
            <if test="maintainPerson != null">maintain_person = #{maintainPerson},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAdmEmsDeviceRbookById" parameterType="Long">
        delete from adm_ems_device_rbook where id = #{id}
    </delete>

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