<?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.business.mapper.TReturnGoodsMapper">
    
    <resultMap type="TReturnGoods" id="TReturnGoodsResult">
        <result property="returngoodsid"    column="returnGoodsId"    />
        <result property="goodsid"    column="goodsId"    />
        <result property="goodsname"    column="goodsName"    />
        <result property="productlotid"    column="productlotId"    />
        <result property="ctl"    column="ctl"    />
        <result property="location"    column="location"    />
        <result property="productiondate"    column="productionDate"    />
        <result property="expirationdate"    column="expirationDate"    />
        <result property="delaydate"    column="delayDate"    />
        <result property="shelfnum"    column="shelfNum"    />
        <result property="username"    column="userName"    />
        <result property="image"    column="image"    />
        <result property="ebs"    column="ebs"    />
        <result property="status"    column="status"    />
        <result property="createTime"    column="createTime"    />
    </resultMap>

    <sql id="selectTReturnGoodsVo">
        select returnGoodsId, goodsId, goodsName, productlotId, ctl, location, productionDate, expirationDate, delayDate, shelfNum, userName, image, ebs, status, createTime from t_return_goods
    </sql>

    <select id="selectTReturnGoodsList" parameterType="TReturnGoods" resultMap="TReturnGoodsResult">
        <include refid="selectTReturnGoodsVo"/>
        <where>  
            <if test="goodsid != null  and goodsid != ''"> and goodsId = #{goodsid}</if>
            <if test="goodsname != null  and goodsname != ''"> and goodsName like concat('%', #{goodsname}, '%')</if>
            <if test="productlotid != null  and productlotid != ''"> and productlotId = #{productlotid}</if>
            <if test="ctl != null  and ctl != ''"> and ctl = #{ctl}</if>
            <if test="location != null  and location != ''"> and location = #{location}</if>
            <if test="productiondate != null "> and productionDate = #{productiondate}</if>
            <if test="expirationdate != null "> and expirationDate = #{expirationdate}</if>
            <if test="delaydate != null "> and delayDate = #{delaydate}</if>
            <if test="shelfnum != null  and shelfnum != ''"> and shelfNum = #{shelfnum}</if>
            <if test="username != null  and username != ''"> and userName like concat('%', #{username}, '%')</if>
            <if test="image != null  and image != ''"> and image = #{image}</if>
            <if test="ebs != null  and ebs != ''"> and ebs = #{ebs}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="createTime != null  and createTime != ''"> and createTime = #{createTime}</if>
        </where>
    </select>
    
    <select id="selectTReturnGoodsByReturngoodsid" parameterType="String" resultMap="TReturnGoodsResult">
        <include refid="selectTReturnGoodsVo"/>
        where returnGoodsId = #{returngoodsid}
    </select>
        
    <insert id="insertTReturnGoods" parameterType="TReturnGoods">
        insert into t_return_goods
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="returngoodsid != null">returnGoodsId,</if>
            <if test="goodsid != null">goodsId,</if>
            <if test="goodsname != null">goodsName,</if>
            <if test="productlotid != null">productlotId,</if>
            <if test="ctl != null">ctl,</if>
            <if test="location != null">location,</if>
            <if test="productiondate != null">productionDate,</if>
            <if test="expirationdate != null">expirationDate,</if>
            <if test="delaydate != null">delayDate,</if>
            <if test="shelfnum != null">shelfNum,</if>
            <if test="username != null">userName,</if>
            <if test="image != null">image,</if>
            <if test="ebs != null">ebs,</if>
            <if test="status != null">status,</if>
            <if test="createTime != null">createTime,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="returngoodsid != null">#{returngoodsid},</if>
            <if test="goodsid != null">#{goodsid},</if>
            <if test="goodsname != null">#{goodsname},</if>
            <if test="productlotid != null">#{productlotid},</if>
            <if test="ctl != null">#{ctl},</if>
            <if test="location != null">#{location},</if>
            <if test="productiondate != null">#{productiondate},</if>
            <if test="expirationdate != null">#{expirationdate},</if>
            <if test="delaydate != null">#{delaydate},</if>
            <if test="shelfnum != null">#{shelfnum},</if>
            <if test="username != null">#{username},</if>
            <if test="image != null">#{image},</if>
            <if test="ebs != null">#{ebs},</if>
            <if test="status != null">#{status},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateTReturnGoods" parameterType="TReturnGoods">
        update t_return_goods
        <trim prefix="SET" suffixOverrides=",">
            <if test="goodsid != null">goodsId = #{goodsid},</if>
            <if test="goodsname != null">goodsName = #{goodsname},</if>
            <if test="productlotid != null">productlotId = #{productlotid},</if>
            <if test="ctl != null">ctl = #{ctl},</if>
            <if test="location != null">location = #{location},</if>
            <if test="productiondate != null">productionDate = #{productiondate},</if>
            <if test="expirationdate != null">expirationDate = #{expirationdate},</if>
            <if test="delaydate != null">delayDate = #{delaydate},</if>
            <if test="shelfnum != null">shelfNum = #{shelfnum},</if>
            <if test="username != null">userName = #{username},</if>
            <if test="image != null">image = #{image},</if>
            <if test="ebs != null">ebs = #{ebs},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createTime != null">createTime = #{createTime},</if>
        </trim>
        where returnGoodsId = #{returngoodsid}
    </update>

    <delete id="deleteTReturnGoodsByReturngoodsid" parameterType="String">
        delete from t_return_goods where returnGoodsId = #{returngoodsid}
    </delete>

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

</mapper>