<?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.api.manage.dao.butlerService.SysOperationsDao">

    <select id="list" parameterType="com.api.model.butlerService.SearchOperations" resultType="com.api.vo.butlerService.VoOperations">
        select so.*,su.actual_name as create_name
        from sys_operations as so,sys_user as su
        <where>
            so.create_id = su.id
            <if test="code != null and code != ''">
                and so.code like concat('%',#{code},'%')
            </if>
            <if test="equipment != null and equipment != ''">
                and so.equipment like concat('%',#{equipment},'%')
            </if>
            <if test="type != null">
                and so.type = #{type}
            </if>
            <if test="results != null">
                and so.results = #{results}
            </if>
        </where>
        order by so.create_date desc
    </select>

    <insert id="insert" parameterType="com.api.model.butlerService.SysOperations">
        insert into sys_operations(
            code,
            equipment,
            type,
            people,
            materials,
            costs,
            department,
            results,
            times,
            <if test="remakes != null and remakes != ''">
                remakes,
            </if>
            maintenance_date,
            create_id,
            create_date
        )values (
            #{code},
            #{equipment},
            #{type},
            #{people},
            #{materials},
            #{costs},
            #{department},
            #{results},
            #{times},
            <if test="remakes != null and remakes != ''">
                #{remakes},
            </if>
            #{maintenanceDate},
            #{createId},
            #{createDate}
        )
    </insert>

    <update id="update" parameterType="com.api.model.butlerService.SysOperations">
        update sys_operations
        <set>
            <if test="equipment != null and equipment != ''">
                equipment = #{equipment},
            </if>
            <if test="type != null">
                type = #{type},
            </if>
            <if test="people != null and people != ''">
                people = #{people},
            </if>
            <if test="materials != null and materials != ''">
                materials = #{materials},
            </if>
            <if test="costs != null">
                costs = #{costs},
            </if>
            <if test="department != null and department != ''">
                department = #{department},
            </if>
            <if test="results != null">
                results = #{results},
            </if>
            <if test="times != null">
                times = #{times},
            </if>
            <if test="remakes != null and remakes != ''">
                remakes = #{remakes},
            </if>
            <if test="maintenanceDate != null">
                maintenance_date = #{maintenanceDate},
            </if>
            modify_id = #{modifyId},
            modify_date = #{modifyDate}
        </set>
        where id = #{id}
    </update>

    <delete id="delete" parameterType="java.lang.Integer">
        delete from sys_operations where id = #{id}
    </delete>

</mapper>