<?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.ss.hardwareVersion.mapper.HardwareVersionMapper">

    <resultMap type="HardwareVersion" id="EHardwareVersionResult">
        <result property="id"    column="id"    />
        <result property="version"    column="version"    />
        <result property="productionTime"    column="production_time"    />
        <result property="quantity"    column="quantity"    />
        <result property="instructions"    column="instructions"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectEHardwareVersionVo">
        select id, version, production_time, quantity, instructions, create_time from ss_hardware_version
    </sql>

    <select id="selectEHardwareVersionList" parameterType="HardwareVersion" resultMap="EHardwareVersionResult">
        <include refid="selectEHardwareVersionVo"/>
        <where>
            <if test="version != null  and version != ''"> and version = #{version}</if>
            <if test="productionTime != null "> and production_time = #{productionTime}</if>
            <if test="instructions != null  and instructions != ''"> and instructions = #{instructions}</if>
        </where>
        order by version
    </select>

    <select id="selectEHardwareVersionById" parameterType="Long" resultMap="EHardwareVersionResult">
        <include refid="selectEHardwareVersionVo"/>
        where id = #{id}
    </select>

    <insert id="insertEHardwareVersion" parameterType="HardwareVersion">
        insert into ss_hardware_version
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="version != null">version,</if>
            <if test="productionTime != null">production_time,</if>
            <if test="quantity != null">quantity,</if>
            <if test="instructions != null">instructions,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="version != null">#{version},</if>
            <if test="productionTime != null">#{productionTime},</if>
            <if test="quantity != null">#{quantity},</if>
            <if test="instructions != null">#{instructions},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateEHardwareVersion" parameterType="HardwareVersion">
        update ss_hardware_version
        <trim prefix="SET" suffixOverrides=",">
            <if test="version != null">version = #{version},</if>
            <if test="productionTime != null">production_time = #{productionTime},</if>
            <if test="quantity != null">quantity = #{quantity},</if>
            <if test="instructions != null">instructions = #{instructions},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteEHardwareVersionById" parameterType="Long">
        delete from ss_hardware_version where id = #{id}
    </delete>

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