Commit c96d2da2ba890f0bc227f86c3e0a2d94e27ee942
Merge remote-tracking branch 'origin/master'
Showing
5 changed files
with
242 additions
and
13 deletions
src/main/java/com/diligrp/xtrade/order/domain/builder/DefaultOrderCreator.java
... | ... | @@ -8,7 +8,6 @@ import java.util.List; |
8 | 8 | import com.diligrp.xtrade.order.domain.dto.AccountDto; |
9 | 9 | import com.diligrp.xtrade.order.domain.dto.OrderCreateRequestDto; |
10 | 10 | import com.diligrp.xtrade.order.domain.dto.OrderItemDto; |
11 | -import com.diligrp.xtrade.order.domain.dto.OrderQueryResponseDto; | |
12 | 11 | import com.diligrp.xtrade.order.domain.emuns.OrderType; |
13 | 12 | import com.diligrp.xtrade.order.domain.emuns.SaleUnit; |
14 | 13 | import com.diligrp.xtrade.order.domain.emuns.TradeType; |
... | ... | @@ -106,12 +105,4 @@ public class DefaultOrderCreator { |
106 | 105 | items.add(orderItemDo); |
107 | 106 | } |
108 | 107 | |
109 | - /** | |
110 | - * 构建基本的订单详情数据 TODO need modify because of change | |
111 | - */ | |
112 | - public static OrderQueryResponseDto buildOrderDetail(OrderDo order, List<OrderItemDo> orderItem) { | |
113 | - OrderQueryResponseDto orderQueryResponseDto = new OrderQueryResponseDto(); | |
114 | - return orderQueryResponseDto; | |
115 | - } | |
116 | - | |
117 | 108 | } | ... | ... |
src/main/java/com/diligrp/xtrade/order/domain/builder/OrderResponseBuilder.java
0 → 100644
1 | +package com.diligrp.xtrade.order.domain.builder; | |
2 | + | |
3 | +import java.util.List; | |
4 | + | |
5 | +import com.diligrp.xtrade.order.domain.dto.OrderQueryResponseDto; | |
6 | +import com.diligrp.xtrade.order.domain.entity.OrderDo; | |
7 | +import com.diligrp.xtrade.order.domain.entity.OrderItemDo; | |
8 | + | |
9 | +/** | |
10 | + * | |
11 | + * @ClassName: OrderResponseBuilder | |
12 | + * @Description 用于订单相应实体操作 | |
13 | + * @author zhangxing | |
14 | + * @date 2020年4月22日 | |
15 | + */ | |
16 | +public class OrderResponseBuilder { | |
17 | + | |
18 | + /** | |
19 | + * 构建基本的订单详情数据 TODO need modify because of change | |
20 | + */ | |
21 | + public static OrderQueryResponseDto buildOrderDetail(OrderDo order, List<OrderItemDo> orderItem) { | |
22 | + OrderQueryResponseDto orderQueryResponseDto = new OrderQueryResponseDto(); | |
23 | + return orderQueryResponseDto; | |
24 | + } | |
25 | + | |
26 | +} | ... | ... |
src/main/java/com/diligrp/xtrade/order/service/impl/OrderServiceImpl.java
... | ... | @@ -12,6 +12,7 @@ import org.springframework.transaction.annotation.Transactional; |
12 | 12 | import com.diligrp.xtrade.order.dao.OrderDao; |
13 | 13 | import com.diligrp.xtrade.order.dao.OrderItemDao; |
14 | 14 | import com.diligrp.xtrade.order.domain.builder.DefaultOrderCreator; |
15 | +import com.diligrp.xtrade.order.domain.builder.OrderResponseBuilder; | |
15 | 16 | import com.diligrp.xtrade.order.domain.dto.AccountDto; |
16 | 17 | import com.diligrp.xtrade.order.domain.dto.OrderCreateRequestDto; |
17 | 18 | import com.diligrp.xtrade.order.domain.dto.OrderItemDto; |
... | ... | @@ -82,7 +83,7 @@ public class OrderServiceImpl implements OrderService { |
82 | 83 | // TODO need modify because of change |
83 | 84 | @Override |
84 | 85 | public OrderQueryResponseDto orderDetail(Long orderId) { |
85 | - OrderQueryResponseDto orderQueryResponseDto = DefaultOrderCreator | |
86 | + OrderQueryResponseDto orderQueryResponseDto = OrderResponseBuilder | |
86 | 87 | .buildOrderDetail(orderDao.selectEntityByOrderId(orderId), orderItemDao.selectItemsByOrderId(orderId)); |
87 | 88 | return orderQueryResponseDto; |
88 | 89 | } | ... | ... |
src/main/java/com/diligrp/xtrade/product/dao/ProductDao.java
1 | 1 | package com.diligrp.xtrade.product.dao; |
2 | 2 | |
3 | +import java.util.List; | |
4 | + | |
5 | +import org.springframework.stereotype.Repository; | |
6 | + | |
7 | +import com.diligrp.xtrade.product.domain.entity.ProductDo; | |
8 | + | |
9 | +import io.lettuce.core.dynamic.annotation.Param; | |
10 | + | |
11 | +/** | |
12 | + * @ClassName:ProductDao | |
13 | + * @Description:商品实体 | |
14 | + * @author dengjf | |
15 | + * @date 2020-04-22 | |
16 | + * | |
17 | + */ | |
18 | +@Repository("productDao") | |
3 | 19 | public interface ProductDao { |
20 | + | |
21 | + /** | |
22 | + * | |
23 | + * @Title insertEntity | |
24 | + * @Description 保存商品信息 | |
25 | + * @param product 商品数据实体 | |
26 | + * @return | |
27 | + * @throws | |
28 | + */ | |
29 | + int insertEntity(ProductDo product); | |
30 | + | |
31 | + /** | |
32 | + * | |
33 | + * @Title lastSequence | |
34 | + * @Description 返回插入的编号,在事务开启状态下有效 | |
35 | + * @return | |
36 | + * @throws | |
37 | + */ | |
38 | + int lastSequence(); | |
4 | 39 | |
40 | + /** | |
41 | + * | |
42 | + * @Title deleteByArrayKey | |
43 | + * @Description 删除记录 | |
44 | + * @param id 主键 | |
45 | + * @return | |
46 | + * @throws | |
47 | + */ | |
48 | + int deleteByArrayKey(@Param("id") Long id); | |
49 | + | |
50 | + /** | |
51 | + * | |
52 | + * @Title deleteByCondtion | |
53 | + * @Description 删除记录 | |
54 | + * @param condition 条件 | |
55 | + * @return | |
56 | + * @throws | |
57 | + */ | |
58 | + int deleteByCondtion(ProductDo condition); | |
59 | + | |
60 | + /** | |
61 | + * | |
62 | + * @Title updateByKey | |
63 | + * @Description 通过主键修改记录 | |
64 | + * @param product 商品实体 | |
65 | + * @return | |
66 | + * @throws | |
67 | + */ | |
68 | + int updateByKey(ProductDo product); | |
69 | + | |
70 | + /** | |
71 | + * | |
72 | + * @Title selectEntryList | |
73 | + * @Description 查询商品列表 | |
74 | + * @param ProductDo 查询条件 | |
75 | + * @return 满足条件商品实体列表 | |
76 | + * @throws | |
77 | + */ | |
78 | + List<ProductDo> selectEntryList(ProductDo product); | |
79 | + | |
80 | + /** | |
81 | + * @Title selectEntryListCount | |
82 | + * @Description 商品数量统计 | |
83 | + * @param ProductDo 查询条件 | |
84 | + * @return 满足条件商品数量 | |
85 | + * @throws | |
86 | + */ | |
87 | + int selectEntryListCount(ProductDo product); | |
88 | + | |
89 | + /** | |
90 | + * @Title selectEntryById | |
91 | + * @Description 根据id查询商品 | |
92 | + * @param id 商品主键 | |
93 | + * @return 满足条件商品实体 | |
94 | + * @throws | |
95 | + */ | |
96 | + ProductDo selectEntryById(@Param("id") Long id); | |
5 | 97 | } | ... | ... |
src/main/resources/mapping/com/diligrp/xtrade/product/ProductDao.xml
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
3 | 3 | <mapper namespace="com.diligrp.xtrade.product.dao.ProductDao"> |
4 | - | |
5 | - | |
6 | - | |
4 | + | |
5 | + <!-- xt_product 所有查询列 --> | |
6 | + <sql id="QUERY_COLUMN_LIST"> | |
7 | + <![CDATA[id,product_id AS productId,product_name AS productName,cate_id AS cateId,cname,account_id AS accountId,account_name AS accountName,price,unit_weight AS unitWeight,unit,amount,weight,status,place,created_time AS createdTime,modified_time AS modifiedTime]]> | |
8 | + </sql> | |
9 | + | |
10 | + <!-- xt_product 查询列来源表 --> | |
11 | + <sql id="QUERY_FROM_TABLE"><![CDATA[FROM xt_product]]></sql> | |
12 | + | |
13 | + <!-- 全部条件(更多功能可以通过queryData扩展实现) --> | |
14 | + <sql id="QUERY_WHERE_CLAUSE"> | |
15 | + <where> | |
16 | + <if test="id != null and id != ''"><![CDATA[AND id = #{id}]]></if> | |
17 | + <if test="productId != null and productId != ''"><![CDATA[AND product_id = #{productId}]]></if> | |
18 | + <if test="productName != null and productName != ''"><![CDATA[AND product_name = #{productName}]]></if> | |
19 | + <if test="cateId != null and cateId != ''"><![CDATA[AND cate_id = #{cateId}]]></if> | |
20 | + <if test="cname != null and cname != ''"><![CDATA[AND cname = #{cname}]]></if> | |
21 | + <if test="accountId != null and accountId != ''"><![CDATA[AND account_id = #{accountId}]]></if> | |
22 | + <if test="accountName != null and accountName != ''"><![CDATA[AND account_name = #{accountName}]]></if> | |
23 | + <if test="price != null and price != ''"><![CDATA[AND price = #{price}]]></if> | |
24 | + <if test="unitWeight != null and unitWeight != ''"><![CDATA[AND unit_weight = #{unitWeight}]]></if> | |
25 | + <if test="unit != null and unit != ''"><![CDATA[AND unit = #{unit}]]></if> | |
26 | + <if test="amount != null and amount != ''"><![CDATA[AND amount = #{amount}]]></if> | |
27 | + <if test="weight != null and weight != ''"><![CDATA[AND weight = #{weight}]]></if> | |
28 | + <if test="status != null and status != ''"><![CDATA[AND status = #{status}]]></if> | |
29 | + <if test="place != null and place != ''"><![CDATA[AND place = #{place}]]></if> | |
30 | + <if test="createdTime != null and createdTime != ''"><![CDATA[AND created_time = #{createdTime}]]></if> | |
31 | + <if test="modifiedTime != null and modifiedTime != ''"><![CDATA[AND modified_time = #{modifiedTime}]]></if> | |
32 | + </where> | |
33 | + </sql> | |
34 | + | |
35 | + <!-- 智能排序与分页 --> | |
36 | + <sql id="QUERY_ORDER_LIMIT_CONDTION"> | |
37 | + <if | |
38 | + test="orderField != null and orderField != '' and orderFieldType != null and orderFieldType != ''"><![CDATA[ORDER BY ${orderField} ${orderFieldType}]]></if> | |
39 | + <if | |
40 | + test="startIndex != null and startIndex >= 0 and pageSize != null and pageSize > 0"><![CDATA[LIMIT #{startIndex},#{pageSize}]]></if> | |
41 | + </sql> | |
42 | + | |
43 | + <!-- 更新列字段,只要不为NULL则更新,除开主键列 --> | |
44 | + <sql id="UPDATE_COLUMN_SET"> | |
45 | + <set> | |
46 | + <if test="productId != null"><![CDATA[product_id = #{productId},]]></if> | |
47 | + <if test="productName != null"><![CDATA[product_name = #{productName},]]></if> | |
48 | + <if test="cateId != null"><![CDATA[cate_id = #{cateId},]]></if> | |
49 | + <if test="cname != null"><![CDATA[cname = #{cname},]]></if> | |
50 | + <if test="accountId != null"><![CDATA[account_id = #{accountId},]]></if> | |
51 | + <if test="accountName != null"><![CDATA[account_name = #{accountName},]]></if> | |
52 | + <if test="price != null"><![CDATA[price = #{price},]]></if> | |
53 | + <if test="unitWeight != null"><![CDATA[unit_weight = #{unitWeight},]]></if> | |
54 | + <if test="unit != null"><![CDATA[unit = #{unit},]]></if> | |
55 | + <if test="amount != null"><![CDATA[amount = #{amount},]]></if> | |
56 | + <if test="weight != null"><![CDATA[weight = #{weight},]]></if> | |
57 | + <if test="status != null"><![CDATA[status = #{status},]]></if> | |
58 | + <if test="place != null"><![CDATA[place = #{place},]]></if> | |
59 | + <if test="createdTime != null"><![CDATA[created_time = #{createdTime},]]></if> | |
60 | + <if test="modifiedTime != null"><![CDATA[modified_time = #{modifiedTime},]]></if> | |
61 | + </set> | |
62 | + </sql> | |
63 | + | |
64 | + <!-- 插入xt_product记录 --> | |
65 | + <insert id="insertEntry" parameterType="productDo"> | |
66 | + <![CDATA[ | |
67 | + INSERT INTO xt_product (id,product_id,product_name,cate_id,cname,account_id,account_name,price,unit_weight,unit,amount,weight,status,place,created_time,modified_time) | |
68 | + VALUES (#{id},#{productId},#{productName},#{cateId},#{cname},#{accountId},#{accountName},#{price},#{unitWeight},#{unit},#{amount},#{weight},#{status},#{place},#{createdTime},#{modifiedTime}) | |
69 | + ]]> | |
70 | + </insert> | |
71 | + | |
72 | + <!-- 返回插入的编号,在事务开启状态下有效 --> | |
73 | + <select id="lastSequence" resultType="int"><![CDATA[SELECT LAST_INSERT_ID() AS id]]></select> | |
74 | + | |
75 | + <!-- 删除记录,主键IN(array) --> | |
76 | + <delete id="deleteByArrayKey" | |
77 | + parameterType="java.lang.reflect.Array"> | |
78 | + <![CDATA[DELETE FROM xt_product WHERE id IN]]> | |
79 | + <foreach collection="array" item="id" open="(" separator="," | |
80 | + close=")"> | |
81 | + <![CDATA[#{id}]]> | |
82 | + </foreach> | |
83 | + </delete> | |
84 | + | |
85 | + <!-- 删除,通过条件 --> | |
86 | + <update id="deleteByCondtion" parameterType="productDo"> | |
87 | + <![CDATA[DELETE FROM xt_product]]> | |
88 | + <include refid="QUERY_WHERE_CLAUSE" /> | |
89 | + </update> | |
90 | + | |
91 | + <!-- 修改记录通过主键 --> | |
92 | + <update id="updateByKey" parameterType="productDo"> | |
93 | + <![CDATA[UPDATE xt_product]]> | |
94 | + <include refid="UPDATE_COLUMN_SET" /> | |
95 | + <![CDATA[WHERE id = #{id}]]> | |
96 | + </update> | |
97 | + | |
98 | + | |
99 | + <!-- 查询,通过条件 --> | |
100 | + <select id="selectEntryList" parameterType="productDo" | |
101 | + resultType="productDo"> | |
102 | + <![CDATA[SELECT]]> | |
103 | + <include refid="QUERY_COLUMN_LIST" /> | |
104 | + <include refid="QUERY_FROM_TABLE" /> | |
105 | + <include refid="QUERY_WHERE_CLAUSE" /> | |
106 | + <include refid="QUERY_ORDER_LIMIT_CONDTION" /> | |
107 | + </select> | |
108 | + | |
109 | + <!-- 总数查询,通过条件 --> | |
110 | + <select id="selectEntryListCount" parameterType="productDo" | |
111 | + resultType="int"> | |
112 | + <![CDATA[SELECT COUNT(id) AS dataCount]]> | |
113 | + <include refid="QUERY_FROM_TABLE" /> | |
114 | + <include refid="QUERY_WHERE_CLAUSE" /> | |
115 | + </select> | |
116 | + | |
117 | + <!-- 其它SQL语句 --> | |
118 | + | |
119 | + <select id="selectEntryById" parameterType="long" resultType="productDo"> | |
120 | + <![CDATA[SELECT]]> | |
121 | + <include refid="QUERY_COLUMN_LIST" /> | |
122 | + <include refid="QUERY_FROM_TABLE" /> | |
123 | + <![CDATA[WHERE id=#{id}]]> | |
124 | + </select> | |
125 | + | |
7 | 126 | </mapper> |
8 | 127 | \ No newline at end of file | ... | ... |