<?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.model.mapper.SingleMapper">
    
    <resultMap type="Single" id="SingleResult">
        <result property="singleId"    column="single_id"    />
        <result property="addressId"    column="address_id"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="noordersDate"    column="noorders_date"    />
        <result property="noordersEnd"    column="noorders_end"    />
        <result property="noordersStart"    column="noorders_start"    />
        <result property="reamk"    column="reamk"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="userId"    column="user_id"    />
    </resultMap>

    <sql id="selectSingleVo">
        select single_id, address_id, create_by, create_time, del_flag, noorders_date, noorders_end, noorders_start, reamk, update_by, update_time, user_id from single
    </sql>

    <select id="selectSingleList" parameterType="Single" resultMap="SingleResult">
        <include refid="selectSingleVo"/>
        <where>  
            <if test="addressId != null "> and address_id = #{addressId}</if>
            <if test="noordersDate != null "> and noorders_date = #{noordersDate}</if>
            <if test="noordersEnd != null "> and noorders_end = #{noordersEnd}</if>
            <if test="noordersStart != null "> and noorders_start = #{noordersStart}</if>
            <if test="reamk != null  and reamk != ''"> and reamk = #{reamk}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
        </where>
    </select>
    
    <select id="selectSingleBySingleId" parameterType="Long" resultMap="SingleResult">
        <include refid="selectSingleVo"/>
        where single_id = #{singleId}
    </select>
    <select id="getSingleList" resultType="com.ruoyi.model.domain.Single">
        <include refid="selectSingleVo"/>
    </select>

    <insert id="insertSingle" parameterType="Single">
        insert into single
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="singleId != null">single_id,</if>
            <if test="addressId != null">address_id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="noordersDate != null">noorders_date,</if>
            <if test="noordersEnd != null">noorders_end,</if>
            <if test="noordersStart != null">noorders_start,</if>
            <if test="reamk != null">reamk,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="userId != null">user_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="singleId != null">#{singleId},</if>
            <if test="addressId != null">#{addressId},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="noordersDate != null">#{noordersDate},</if>
            <if test="noordersEnd != null">#{noordersEnd},</if>
            <if test="noordersStart != null">#{noordersStart},</if>
            <if test="reamk != null">#{reamk},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="userId != null">#{userId},</if>
         </trim>
    </insert>

    <update id="updateSingle" parameterType="Single">
        update single
        <trim prefix="SET" suffixOverrides=",">
            <if test="addressId != null">address_id = #{addressId},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="noordersDate != null">noorders_date = #{noordersDate},</if>
            <if test="noordersEnd != null">noorders_end = #{noordersEnd},</if>
            <if test="noordersStart != null">noorders_start = #{noordersStart},</if>
            <if test="reamk != null">reamk = #{reamk},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="userId != null">user_id = #{userId},</if>
        </trim>
        where single_id = #{singleId}
    </update>

    <delete id="deleteSingleBySingleId" parameterType="Long">
        delete from single where single_id = #{singleId}
    </delete>

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