ghy-all/ghy-order/src/main/resources/mapper/order/OrderGoodsMapper.xml

97 lines
4.7 KiB
XML

<?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.ghy.order.mapper.OrderGoodsMapper">
<resultMap id="OrderGoodsResult" type="com.ghy.order.domain.OrderGoods">
<id property="orderGoodsId" column="order_goods_id"/>
<result property="orderId" column="order_id"/>
<result property="goodsId" column="goods_id"/>
<result property="goodsName" column="goods_name"/>
<result property="goodsNum" column="goods_num"/>
<result property="serverGoodsNum" column="server_goods_num"/>
<result property="finishTime" column="finish_time"/>
<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="remark" column="remark"/>
</resultMap>
<sql id="selectOrderGoods">
SELECT order_goods_id, order_id, goods_name, goods_num, server_goods_num, finish_time, create_by, create_time, remark
FROM order_goods
</sql>
<update id="updateOrderGoods" parameterType="com.ghy.order.domain.OrderGoods">
UPDATE order_goods
<set>
<if test="orderId != null and orderId != ''">order_id = #{orderId},</if>
<if test="goodsId != null and goodsId != ''">goods_id = #{goodsId},</if>
<if test="goodsName != null and goodsName != ''">goods_name = #{goodsName},</if>
<if test="goodsNum != null and goodsNum != ''">goods_num = #{goodsNum},</if>
<if test="serverGoodsNum != null and serverGoodsNum != ''">server_goods_num = #{serverGoodsNum},</if>
<if test="finishTime != null and finishTime != ''">finish_time = #{finishTime},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = SYSDATE()
</set>
WHERE order_goods_id = #{orderGoodsId}
</update>
<insert id="insertOrderGoods" parameterType="com.ghy.order.domain.OrderGoods" useGeneratedKeys="true"
keyProperty="id">
INSERT INTO order_goods(
<if test="orderId != null and orderId != ''">order_id,</if>
<if test="goodsId != null and goodsId != ''">goods_id,</if>
<if test="goodsName != null and goodsName != ''">goods_name,</if>
<if test="goodsNum != null and goodsNum != ''">goods_num,</if>
<if test="serverGoodsNum != null and serverGoodsNum != ''">server_goods_num,</if>
<if test="finishTime != null and finishTime != ''">finish_time,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)VALUES(
<if test="orderId != null and orderId != ''">#{orderId},</if>
<if test="goodsId != null and goodsId != ''">#{goodsId},</if>
<if test="goodsName != null and goodsName != ''">#{goodsName},</if>
<if test="goodsNum != null and goodsNum != ''">#{goodsNum},</if>
<if test="serverGoodsNum != null and serverGoodsNum != ''">#{serverGoodsNum},</if>
<if test="finishTime != null and finishTime != ''">#{finishTime},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
SYSDATE()
)
</insert>
<select id="selectOrderGoodsList" parameterType="com.ghy.order.domain.OrderGoods" resultMap="OrderGoodsResult">
<include refid="selectOrderGoods"/>
<where>
<if test="orderId != null and orderId != ''">
AND order_id LIKE concat('%', #{orderId}, '%')
</if>
<if test="goodsId != null and goodsId != 0">
AND goods_id = #{goodsId}
</if>
<if test="goodsName != null and goodsName != 0">
AND goods_name = #{goodsName}
</if>
</where>
</select>
<select id="selectById" parameterType="long" resultMap="OrderGoodsResult">
<include refid="selectOrderGoods"/>
<where>
<if test="orderGoodsId != null and orderGoodsId != 0">
AND id = #{orderGoodsId}
</if>
</where>
</select>
<delete id="deleteOrderGoodsByIds" parameterType="Long">
DELETE FROM order_goods WHERE id IN
<foreach collection="array" item="orderGoodsId" open="(" separator="," close=")">
#{orderGoodsId}
</foreach>
</delete>
</mapper>