<?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.warehouseBusiness.mapper.BillnoSerialMapper">

    <resultMap type="BillnoSerial" id="BillnoSerialResult">
        <result property="id" column="id"/>
        <result property="billType" column="bill_type"/>
        <result property="billPrefix" column="bill_prefix"/>
        <result property="serial" column="serial"/>
        <result property="remarks" column="remarks"/>
    </resultMap>

    <sql id="selectBillnoSerialVo">
        select id, bill_type, bill_prefix, serial, remarks from billno_serial
    </sql>

    <select id="selectBillnoSerial" parameterType="BillnoSerial" resultMap="BillnoSerialResult">
        <include refid="selectBillnoSerialVo"/>
        <where>
            <if test="billType != null  and billType != ''">and bill_type = #{billType}</if>
            <if test="billPrefix != null  and billPrefix != ''">and bill_prefix = #{billPrefix}</if>
            <if test="serial != null ">and serial = #{serial}</if>
            <if test="remarks != null  and remarks != ''">and remarks = #{remarks}</if>
        </where>
    </select>

    <select id="selectBillnoSerialList" parameterType="BillnoSerial" resultMap="BillnoSerialResult">
        <include refid="selectBillnoSerialVo"/>
        <where>
            <if test="billType != null  and billType != ''">and bill_type = #{billType}</if>
            <if test="billPrefix != null  and billPrefix != ''">and bill_prefix = #{billPrefix}</if>
            <if test="serial != null ">and serial = #{serial}</if>
            <if test="remarks != null  and remarks != ''">and remarks = #{remarks}</if>
        </where>
    </select>

    <select id="selectBillnoSerialById" parameterType="Long" resultMap="BillnoSerialResult">
        <include refid="selectBillnoSerialVo"/>
        where id = #{id}
    </select>

    <insert id="insertBillnoSerial" parameterType="BillnoSerial" useGeneratedKeys="true" keyProperty="id">
        insert into billno_serial
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="billType != null">bill_type,</if>
            <if test="billPrefix != null">bill_prefix,</if>
            <if test="serial != null">serial,</if>
            <if test="remarks != null">remarks,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="billType != null">#{billType},</if>
            <if test="billPrefix != null">#{billPrefix},</if>
            <if test="serial != null">#{serial},</if>
            <if test="remarks != null">#{remarks},</if>
        </trim>
    </insert>

    <update id="updateBillnoSerial" parameterType="BillnoSerial">
        update billno_serial
        <trim prefix="SET" suffixOverrides=",">
            <if test="billType != null">bill_type = #{billType},</if>
            <if test="billPrefix != null">bill_prefix = #{billPrefix},</if>
            <if test="serial != null">serial = #{serial},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBillnoSerialById" parameterType="Long">
        delete from billno_serial where id = #{id}
    </delete>

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

</mapper>