<?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.younike.system.mapper.OrderGoodsServerMapper">

    <resultMap type="OrderGoodsServer" id="OrderGoodsServerResult">
        <result property="orderId"    column="order_id"    />
        <result property="serverId"    column="server_id"    />
        <result property="goodsId"    column="goods_id"    />
        <result property="goodsCounts"    column="goods_counts"    />
        <result property="singleTime"    column="single_time"    />
        <result property="goodsCoin"    column="goods_coin"    />
        <result property="goodsName"    column="goods_name"    />
        <result property="goodsServerPrice"    column="goods_server_price"    />
        <result property="goodsUnit"    column="goods_unit"    />
        <result property="serverName"    column="server_name"    />
        <result property="serverSex"    column="server_sex"    />
        <result property="serverAge"    column="server_age"    />
        <result property="serverAvatar"    column="server_avatar"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="loginIp"    column="login_ip"    />
        <result property="loginDate"    column="login_date"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="column1"    column="column1"    />
        <result property="column2"    column="column2"    />
        <result property="column3"    column="column3"    />
        <result property="merchantId"    column="merchant_id"    />
    </resultMap>

    <sql id="selectOrderGoodsServerVo">
        select order_id, server_id, goods_id, goods_counts, single_time, goods_coin, goods_name, goods_server_price, goods_unit, server_name, server_sex, server_age, server_avatar, del_flag, login_ip, login_date, create_by, create_time, update_by, update_time, column1, column2, column3, merchant_id from order_goods_server
    </sql>

    <select id="selectOrderGoodsServerList" parameterType="OrderGoodsServer" resultMap="OrderGoodsServerResult">
        <include refid="selectOrderGoodsServerVo"/>
        <where>
            <if test="serverId != null ">and server_id = #{serverId}</if>
            <if test="goodsId != null ">and goods_id = #{goodsId}</if>
            <if test="goodsCounts != null ">and goods_counts = #{goodsCounts}</if>
            <if test="singleTime != null ">and single_time = #{singleTime}</if>
            <if test="goodsCoin != null ">and goods_coin = #{goodsCoin}</if>
            <if test="goodsName != null  and goodsName != ''">and goods_name like concat('%', #{goodsName}, '%')</if>
            <if test="goodsServerPrice != null ">and goods_server_price = #{goodsServerPrice}</if>
            <if test="goodsUnit != null  and goodsUnit != ''">and goods_unit = #{goodsUnit}</if>
            <if test="serverName != null  and serverName != ''">and server_name like concat('%', #{serverName}, '%')
            </if>
            <if test="serverSex != null ">and server_sex = #{serverSex}</if>
            <if test="serverAge != null "> and server_age = #{serverAge}</if>
            <if test="serverAvatar != null  and serverAvatar != ''"> and server_avatar = #{serverAvatar}</if>
            <if test="loginIp != null  and loginIp != ''"> and login_ip = #{loginIp}</if>
            <if test="loginDate != null "> and login_date = #{loginDate}</if>
            <if test="column1 != null  and column1 != ''"> and column1 = #{column1}</if>
            <if test="column2 != null  and column2 != ''"> and column2 = #{column2}</if>
            <if test="column3 != null  and column3 != ''"> and column3 = #{column3}</if>
            <if test="merchantId != null  and merchantId != ''"> and merchant_id = #{merchantId}</if>
        </where>
    </select>

    <select id="selectOrderGoodsServerByOrderId" parameterType="Long" resultMap="OrderGoodsServerResult">
        <include refid="selectOrderGoodsServerVo"/>
        where order_id = #{orderId}
    </select>

    <insert id="insertOrderGoodsServer" parameterType="OrderGoodsServer">
        insert into order_goods_server
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderId != null">order_id,</if>
            <if test="serverId != null">server_id,</if>
            <if test="goodsId != null">goods_id,</if>
            <if test="goodsCounts != null">goods_counts,</if>
            <if test="singleTime != null">single_time,</if>
            <if test="goodsCoin != null">goods_coin,</if>
            <if test="goodsName != null and goodsName != ''">goods_name,</if>
            <if test="goodsServerPrice != null">goods_server_price,</if>
            <if test="goodsUnit != null">goods_unit,</if>
            <if test="serverName != null">server_name,</if>
            <if test="serverSex != null">server_sex,</if>
            <if test="serverAge != null">server_age,</if>
            <if test="serverAvatar != null">server_avatar,</if>
            <if test="delFlag != null and delFlag != ''">del_flag,</if>
            <if test="loginIp != null">login_ip,</if>
            <if test="loginDate != null">login_date,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="column1 != null">column1,</if>
            <if test="column2 != null">column2,</if>
            <if test="column3 != null">column3,</if>
            <if test="merchantId != null and merchantId != ''">merchant_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orderId != null">#{orderId},</if>
            <if test="serverId != null">#{serverId},</if>
            <if test="goodsId != null">#{goodsId},</if>
            <if test="goodsCounts != null">#{goodsCounts},</if>
            <if test="singleTime != null">#{singleTime},</if>
            <if test="goodsCoin != null">#{goodsCoin},</if>
            <if test="goodsName != null and goodsName != ''">#{goodsName},</if>
            <if test="goodsServerPrice != null">#{goodsServerPrice},</if>
            <if test="goodsUnit != null">#{goodsUnit},</if>
            <if test="serverName != null">#{serverName},</if>
            <if test="serverSex != null">#{serverSex},</if>
            <if test="serverAge != null">#{serverAge},</if>
            <if test="serverAvatar != null">#{serverAvatar},</if>
            <if test="delFlag != null and delFlag != ''">#{delFlag},</if>
            <if test="loginIp != null">#{loginIp},</if>
            <if test="loginDate != null">#{loginDate},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="column1 != null">#{column1},</if>
            <if test="column2 != null">#{column2},</if>
            <if test="column3 != null">#{column3},</if>
            <if test="merchantId != null and merchantId != ''">#{merchantId},</if>
         </trim>
    </insert>

    <update id="updateOrderGoodsServer" parameterType="OrderGoodsServer">
        update order_goods_server
        <trim prefix="SET" suffixOverrides=",">
            <if test="serverId != null">server_id = #{serverId},</if>
            <if test="goodsId != null">goods_id = #{goodsId},</if>
            <if test="goodsCounts != null">goods_counts = #{goodsCounts},</if>
            <if test="singleTime != null">single_time = #{singleTime},</if>
            <if test="goodsCoin != null">goods_coin = #{goodsCoin},</if>
            <if test="goodsName != null and goodsName != ''">goods_name = #{goodsName},</if>
            <if test="goodsServerPrice != null">goods_server_price = #{goodsServerPrice},</if>
            <if test="goodsUnit != null">goods_unit = #{goodsUnit},</if>
            <if test="serverName != null">server_name = #{serverName},</if>
            <if test="serverSex != null">server_sex = #{serverSex},</if>
            <if test="serverAge != null">server_age = #{serverAge},</if>
            <if test="serverAvatar != null">server_avatar = #{serverAvatar},</if>
            <if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
            <if test="loginIp != null">login_ip = #{loginIp},</if>
            <if test="loginDate != null">login_date = #{loginDate},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="column1 != null">column1 = #{column1},</if>
            <if test="column2 != null">column2 = #{column2},</if>
            <if test="column3 != null">column3 = #{column3},</if>
            <if test="merchantId != null">merchant_id = #{merchantId},</if>
        </trim>
        where order_id = #{orderId}
    </update>

    <delete id="deleteOrderGoodsServerByOrderId" parameterType="Long">
        delete from order_goods_server where order_id = #{orderId}
    </delete>

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