<?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.WorkOrderFjMapper">
    
    <resultMap type="WorkOrderFj" id="WorkOrderFjResult">
        <result property="id"    column="id"    />
        <result property="orderId"    column="order_id"    />
        <result property="name"    column="name"    />
        <result property="url"    column="url"    />
        <result property="type"    column="type"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectWorkOrderFjVo">
        select id, order_id, name, url, type, remark from work_order_fj
    </sql>

    <select id="selectWorkOrderFjList" parameterType="WorkOrderFj" resultMap="WorkOrderFjResult">
        <include refid="selectWorkOrderFjVo"/>
        <where>  
            <if test="orderId != null  and orderId != ''"> and order_id = #{orderId}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="url != null  and url != ''"> and url = #{url}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
        </where>
    </select>
    
    <select id="selectWorkOrderFjById" parameterType="Long" resultMap="WorkOrderFjResult">
        <include refid="selectWorkOrderFjVo"/>
        where id = #{id}
    </select>

    <insert id="insertWorkOrderFj" parameterType="WorkOrderFj" useGeneratedKeys="true" keyProperty="id">
        insert into work_order_fj
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderId != null">order_id,</if>
            <if test="name != null and name != ''">name,</if>
            <if test="url != null">url,</if>
            <if test="type != null">type,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orderId != null">#{orderId},</if>
            <if test="name != null and name != ''">#{name},</if>
            <if test="url != null">#{url},</if>
            <if test="type != null">#{type},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateWorkOrderFj" parameterType="WorkOrderFj">
        update work_order_fj
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderId != null">order_id = #{orderId},</if>
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="url != null">url = #{url},</if>
            <if test="type != null">type = #{type},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteWorkOrderFjById" parameterType="Long">
        delete from work_order_fj where id = #{id}
    </delete>

    <delete id="deleteWorkOrderFjByIds" parameterType="String">
        delete from work_order_fj where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <delete id="deleteWorkOrderFj">
        delete from work_order_fj where order_id = #{orderId} and type = #{type}
    </delete>
</mapper>