<?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.jsowell.pile.mapper.PileFirmwareInfoMapper">

    <resultMap type="com.jsowell.pile.domain.PileFirmwareInfo" id="PileFirmwareInfoResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="description"    column="description"    />
        <result property="filePath"    column="file_path"    />
        <result property="applyType"    column="apply_type"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>

    <sql id="selectPileFirmwareInfoVo">
        select id, name, description, file_path, apply_type, create_time, create_by, update_time, update_by, del_flag from pile_firmware_info
    </sql>

    <select id="selectPileFirmwareInfoList" parameterType="com.jsowell.pile.domain.PileFirmwareInfo" resultMap="PileFirmwareInfoResult">
        <include refid="selectPileFirmwareInfoVo"/>
        <where>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
        </where>
    </select>

    <select id="selectPileFirmwareInfoById" parameterType="Long" resultMap="PileFirmwareInfoResult">
        <include refid="selectPileFirmwareInfoVo"/>
        where id = #{id}
    </select>

    <insert id="insertPileFirmwareInfo" parameterType="com.jsowell.pile.domain.PileFirmwareInfo">
        insert into pile_firmware_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="name != null">name,</if>
            <if test="description != null">description,</if>
            <if test="filePath != null">file_path,</if>
            <if test="applyType != null">apply_type,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="delFlag != null">del_flag,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="name != null">#{name},</if>
            <if test="description != null">#{description},</if>
            <if test="filePath != null">#{filePath},</if>
            <if test="applyType != null">#{applyType},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="delFlag != null">#{delFlag},</if>
        </trim>
    </insert>

    <update id="updatePileFirmwareInfo" parameterType="com.jsowell.pile.domain.PileFirmwareInfo">
        update pile_firmware_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="description != null">description = #{description},</if>
            <if test="filePath != null">file_path = #{filePath},</if>
            <if test="applyType != null">apply_type = #{applyType},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePileFirmwareInfoById" parameterType="Long">
        delete from pile_firmware_info where id = #{id}
    </delete>

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