OrderGoods Mapper and Service
This commit is contained in:
parent
1a22ec11b6
commit
9e31d58627
|
|
@ -1,4 +1,42 @@
|
||||||
package com.ghy.order.mapper;
|
package com.ghy.order.mapper;
|
||||||
|
|
||||||
|
import com.ghy.order.domain.OrderGoods;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单商品
|
||||||
|
*
|
||||||
|
* @author HH 2022/5/17
|
||||||
|
*/
|
||||||
public interface OrderGoodsMapper {
|
public interface OrderGoodsMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param orderGoods 订单商品属性
|
||||||
|
*/
|
||||||
|
int insertOrderGoods(OrderGoods orderGoods);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param orderGoods 订单商品属性
|
||||||
|
*/
|
||||||
|
int updateOrderGoods(OrderGoods orderGoods);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param orderGoods 订单商品入参
|
||||||
|
*/
|
||||||
|
List<OrderGoods> selectOrderGoodsList(OrderGoods orderGoods);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param orderGoodsId 订单商品id
|
||||||
|
* @return 订单商品
|
||||||
|
*/
|
||||||
|
OrderGoods selectById(Long orderGoodsId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除订单商品信息
|
||||||
|
*
|
||||||
|
* @param orderGoodsIds 需要删除的数据ID
|
||||||
|
*/
|
||||||
|
int deleteOrderGoodsByIds(Long[] orderGoodsIds);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,41 @@
|
||||||
package com.ghy.order.service;
|
package com.ghy.order.service;
|
||||||
|
|
||||||
|
import com.ghy.order.domain.OrderGoods;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单商品属性
|
||||||
|
*
|
||||||
|
* @author HH 2022/5/17
|
||||||
|
*/
|
||||||
public interface OrderGoodsService {
|
public interface OrderGoodsService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param orderGoods 订单商品属性
|
||||||
|
*/
|
||||||
|
int insertOrderGoods(OrderGoods orderGoods);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param orderGoods 订单商品属性
|
||||||
|
*/
|
||||||
|
int updateOrderGoods(OrderGoods orderGoods);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param orderGoods 订单商品入参
|
||||||
|
*/
|
||||||
|
List<OrderGoods> selectOrderGoodsList(OrderGoods orderGoods);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param orderGoodsId 订单商品id
|
||||||
|
* @return 订单商品
|
||||||
|
*/
|
||||||
|
OrderGoods selectById(Long orderGoodsId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除订单商品信息
|
||||||
|
*
|
||||||
|
* @param orderGoodsIds 需要删除的数据ID
|
||||||
|
*/
|
||||||
|
int deleteOrderGoodsByIds(Long[] orderGoodsIds);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,45 @@
|
||||||
package com.ghy.order.service.impl;
|
package com.ghy.order.service.impl;
|
||||||
|
|
||||||
|
import com.ghy.order.domain.OrderGoods;
|
||||||
|
import com.ghy.order.mapper.OrderGoodsMapper;
|
||||||
import com.ghy.order.service.OrderGoodsService;
|
import com.ghy.order.service.OrderGoodsService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class OrderGoodsServiceImpl implements OrderGoodsService {
|
public class OrderGoodsServiceImpl implements OrderGoodsService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
OrderGoodsMapper orderGoodsMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertOrderGoods(OrderGoods orderGoods) {
|
||||||
|
return orderGoodsMapper.insertOrderGoods(orderGoods);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updateOrderGoods(OrderGoods orderGoods) {
|
||||||
|
Assert.notNull(orderGoods.getOrderGoodsId(), "OrderGoodsId cannot be null!");
|
||||||
|
return orderGoodsMapper.updateOrderGoods(orderGoods);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<OrderGoods> selectOrderGoodsList(OrderGoods orderGoods) {
|
||||||
|
return orderGoodsMapper.selectOrderGoodsList(orderGoods);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OrderGoods selectById(Long orderGoodsId) {
|
||||||
|
return orderGoodsMapper.selectById(orderGoodsId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int deleteOrderGoodsByIds(Long[] orderGoodsIds) {
|
||||||
|
return orderGoodsMapper.deleteOrderGoodsByIds(orderGoodsIds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,96 @@
|
||||||
|
<?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>
|
||||||
Loading…
Reference in New Issue