Commit 19ae0675f7713c8e8988aecda3d12579572cb828
Merge branch 'master' of http://git3.nong12.com/xtrade/order-service
# Conflicts: # src/main/java/com/diligrp/xtrade/product/controllor/CategoryController.java # src/main/java/com/diligrp/xtrade/product/controllor/ShopController.java
Showing
38 changed files
with
1369 additions
and
223 deletions
src/main/java/com/diligrp/xtrade/order/controllor/OrderApiController.java
@@ -34,7 +34,7 @@ public class OrderApiController { | @@ -34,7 +34,7 @@ public class OrderApiController { | ||
34 | @RequestMapping(value = "/createOrder",method = {RequestMethod.POST}) | 34 | @RequestMapping(value = "/createOrder",method = {RequestMethod.POST}) |
35 | public Message<Boolean> createOrder(@RequestBody @Validated OrderCreateRequestDto orderCreateRequestDto) { | 35 | public Message<Boolean> createOrder(@RequestBody @Validated OrderCreateRequestDto orderCreateRequestDto) { |
36 | orderservice.createOrder(orderCreateRequestDto); | 36 | orderservice.createOrder(orderCreateRequestDto); |
37 | - return Message.builder().success(Boolean.TRUE); | 37 | + return Message.success(Boolean.TRUE); |
38 | } | 38 | } |
39 | 39 | ||
40 | /** | 40 | /** |
@@ -42,7 +42,7 @@ public class OrderApiController { | @@ -42,7 +42,7 @@ public class OrderApiController { | ||
42 | */ | 42 | */ |
43 | @RequestMapping(value = "/listOrders") | 43 | @RequestMapping(value = "/listOrders") |
44 | public Message<List<OrderQueryResponseDto>> listOrders(@RequestBody OrderQueryRequestDto orderQueryRequestDto) { | 44 | public Message<List<OrderQueryResponseDto>> listOrders(@RequestBody OrderQueryRequestDto orderQueryRequestDto) { |
45 | - return Message.builder().success(orderservice.orderLists(orderQueryRequestDto)); | 45 | + return Message.success(orderservice.orderLists(orderQueryRequestDto)); |
46 | } | 46 | } |
47 | 47 | ||
48 | /** | 48 | /** |
@@ -50,6 +50,6 @@ public class OrderApiController { | @@ -50,6 +50,6 @@ public class OrderApiController { | ||
50 | */ | 50 | */ |
51 | @RequestMapping(value = "/orderDetail") | 51 | @RequestMapping(value = "/orderDetail") |
52 | public Message<OrderQueryResponseDto> orderDetail(@RequestBody @Validated OrderQueryRequestDto orderQueryRequestDto) { | 52 | public Message<OrderQueryResponseDto> orderDetail(@RequestBody @Validated OrderQueryRequestDto orderQueryRequestDto) { |
53 | - return Message.builder().success(orderservice.orderDetail(orderQueryRequestDto.getOrderId())); | 53 | + return Message.success(orderservice.orderDetail(orderQueryRequestDto.getOrderId())); |
54 | } | 54 | } |
55 | } | 55 | } |
src/main/java/com/diligrp/xtrade/order/dao/OrderItemDao.java
@@ -60,4 +60,13 @@ public interface OrderItemDao { | @@ -60,4 +60,13 @@ public interface OrderItemDao { | ||
60 | */ | 60 | */ |
61 | int updateCommission(@Param("scommission") Long scommission, @Param("bcommission") Long bcommission, | 61 | int updateCommission(@Param("scommission") Long scommission, @Param("bcommission") Long bcommission, |
62 | @Param("ruleId") Long ruleId, @Param("ruleRate") String ruleRate, @Param("itemId") Long itemId); | 62 | @Param("ruleId") Long ruleId, @Param("ruleRate") String ruleRate, @Param("itemId") Long itemId); |
63 | + | ||
64 | + /** | ||
65 | + * @Title insertBatch | ||
66 | + * @Description 批量插入 | ||
67 | + * @param orderItemDos 批量插入实体 | ||
68 | + * @return | ||
69 | + * @throws | ||
70 | + */ | ||
71 | + int insertBatch(List<OrderItemDo> orderItemDos); | ||
63 | } | 72 | } |
src/main/java/com/diligrp/xtrade/order/domain/dto/AccountDto.java
@@ -26,7 +26,7 @@ public class AccountDto implements Serializable { | @@ -26,7 +26,7 @@ public class AccountDto implements Serializable { | ||
26 | private String mobile; | 26 | private String mobile; |
27 | 27 | ||
28 | //卡号类型 | 28 | //卡号类型 |
29 | - private String type; | 29 | + private Integer type; |
30 | 30 | ||
31 | // 资金账号ID | 31 | // 资金账号ID |
32 | private Long fundAccount; | 32 | private Long fundAccount; |
@@ -81,11 +81,11 @@ public class AccountDto implements Serializable { | @@ -81,11 +81,11 @@ public class AccountDto implements Serializable { | ||
81 | this.mobile = mobile; | 81 | this.mobile = mobile; |
82 | } | 82 | } |
83 | 83 | ||
84 | - public String getType() { | 84 | + public Integer getType() { |
85 | return type; | 85 | return type; |
86 | } | 86 | } |
87 | 87 | ||
88 | - public void setType(String type) { | 88 | + public void setType(Integer type) { |
89 | this.type = type; | 89 | this.type = type; |
90 | } | 90 | } |
91 | 91 |
src/main/java/com/diligrp/xtrade/order/domain/dto/OrderItemDto.java
@@ -10,43 +10,43 @@ import javax.validation.constraints.NotNull; | @@ -10,43 +10,43 @@ import javax.validation.constraints.NotNull; | ||
10 | * @date 2020年4月21日 | 10 | * @date 2020年4月21日 |
11 | */ | 11 | */ |
12 | public class OrderItemDto { | 12 | public class OrderItemDto { |
13 | - | ||
14 | - //商品id | 13 | + |
14 | + // 商品id | ||
15 | @NotNull(message = "商品id不能为空") | 15 | @NotNull(message = "商品id不能为空") |
16 | - private Long productId; | ||
17 | - | ||
18 | - //商品名称 | ||
19 | - private Long productName; | ||
20 | - | ||
21 | - //销售单位 | 16 | + private Long pid; |
17 | + | ||
18 | + // 商品名称 | ||
19 | + private String pname; | ||
20 | + | ||
21 | + // 销售单位 | ||
22 | @NotNull(message = "销售单位不能为空") | 22 | @NotNull(message = "销售单位不能为空") |
23 | private Integer saleUnit; | 23 | private Integer saleUnit; |
24 | - | ||
25 | - //价格 | 24 | + |
25 | + // 价格 | ||
26 | @NotNull(message = "销售单价不能为空") | 26 | @NotNull(message = "销售单价不能为空") |
27 | private Integer price; | 27 | private Integer price; |
28 | - | ||
29 | - //数量 | 28 | + |
29 | + // 数量 | ||
30 | @NotNull(message = "销售数量不能为空") | 30 | @NotNull(message = "销售数量不能为空") |
31 | private Double amount; | 31 | private Double amount; |
32 | - | ||
33 | - //件重 | 32 | + |
33 | + // 件重 | ||
34 | private Double unitWeight; | 34 | private Double unitWeight; |
35 | 35 | ||
36 | - public Long getProductId() { | ||
37 | - return productId; | 36 | + public Long getPid() { |
37 | + return pid; | ||
38 | } | 38 | } |
39 | 39 | ||
40 | - public void setProductId(Long productId) { | ||
41 | - this.productId = productId; | 40 | + public void setPid(Long pid) { |
41 | + this.pid = pid; | ||
42 | } | 42 | } |
43 | 43 | ||
44 | - public Long getProductName() { | ||
45 | - return productName; | 44 | + public String getPname() { |
45 | + return pname; | ||
46 | } | 46 | } |
47 | 47 | ||
48 | - public void setProductName(Long productName) { | ||
49 | - this.productName = productName; | 48 | + public void setPname(String pname) { |
49 | + this.pname = pname; | ||
50 | } | 50 | } |
51 | 51 | ||
52 | public Integer getSaleUnit() { | 52 | public Integer getSaleUnit() { |
src/main/java/com/diligrp/xtrade/order/domain/emuns/OrderType.java
0 → 100644
1 | +package com.diligrp.xtrade.order.domain.emuns; | ||
2 | + | ||
3 | +/** | ||
4 | + * | ||
5 | + * @ClassName: OrderType | ||
6 | + * @Description 订单类型枚举类 | ||
7 | + * @author zhangxing | ||
8 | + * @date 2020年4月22日 | ||
9 | + */ | ||
10 | +public enum OrderType { | ||
11 | + | ||
12 | + //普通交易 | ||
13 | + NORMAL(1, "普通"); | ||
14 | + | ||
15 | + // 编码 | ||
16 | + private int code; | ||
17 | + | ||
18 | + // 名称 | ||
19 | + private String name; | ||
20 | + | ||
21 | + private OrderType(int code, String name) { | ||
22 | + this.code = code; | ||
23 | + this.name = name; | ||
24 | + } | ||
25 | + | ||
26 | + public int getCode() { | ||
27 | + return code; | ||
28 | + } | ||
29 | + | ||
30 | + public String getName() { | ||
31 | + return name; | ||
32 | + } | ||
33 | + | ||
34 | + public static OrderType getByCode(int code) { | ||
35 | + for (OrderType orderType : values()) { | ||
36 | + if (orderType.getCode() == code) { | ||
37 | + return orderType; | ||
38 | + } | ||
39 | + } | ||
40 | + return null; | ||
41 | + } | ||
42 | + | ||
43 | + public static String getNameByCode(int code) { | ||
44 | + for (OrderType orderType : OrderType.values()) { | ||
45 | + if (orderType.getCode() == code) { | ||
46 | + return orderType.name; | ||
47 | + } | ||
48 | + } | ||
49 | + return null; | ||
50 | + } | ||
51 | +} |
src/main/java/com/diligrp/xtrade/order/domain/emuns/TradeType.java
0 → 100644
1 | +package com.diligrp.xtrade.order.domain.emuns; | ||
2 | + | ||
3 | +/** | ||
4 | + * | ||
5 | + * @ClassName: TradeType | ||
6 | + * @Description 订单交易类型枚举类 | ||
7 | + * @author zhangxing | ||
8 | + * @date 2020年4月22日 | ||
9 | + */ | ||
10 | +public enum TradeType { | ||
11 | + | ||
12 | + //普通交易 | ||
13 | + NORMAL(1, "普通"); | ||
14 | + | ||
15 | + // 编码 | ||
16 | + private int code; | ||
17 | + | ||
18 | + // 名称 | ||
19 | + private String name; | ||
20 | + | ||
21 | + private TradeType(int code, String name) { | ||
22 | + this.code = code; | ||
23 | + this.name = name; | ||
24 | + } | ||
25 | + | ||
26 | + public int getCode() { | ||
27 | + return code; | ||
28 | + } | ||
29 | + | ||
30 | + public String getName() { | ||
31 | + return name; | ||
32 | + } | ||
33 | + | ||
34 | + public static TradeType getByCode(int code) { | ||
35 | + for (TradeType tradeType : values()) { | ||
36 | + if (tradeType.getCode() == code) { | ||
37 | + return tradeType; | ||
38 | + } | ||
39 | + } | ||
40 | + return null; | ||
41 | + } | ||
42 | + | ||
43 | + public static String getNameByCode(int code) { | ||
44 | + for (TradeType tradeType : TradeType.values()) { | ||
45 | + if (tradeType.getCode() == code) { | ||
46 | + return tradeType.name; | ||
47 | + } | ||
48 | + } | ||
49 | + return null; | ||
50 | + } | ||
51 | +} |
src/main/java/com/diligrp/xtrade/order/exception/OrderExceptionHandler.java
@@ -16,6 +16,6 @@ public class OrderExceptionHandler { | @@ -16,6 +16,6 @@ public class OrderExceptionHandler { | ||
16 | @ResponseBody | 16 | @ResponseBody |
17 | @ExceptionHandler({OrderException.class}) | 17 | @ExceptionHandler({OrderException.class}) |
18 | public Message<?> handleOrderException(OrderException ex) { | 18 | public Message<?> handleOrderException(OrderException ex) { |
19 | - return Message.builder().failure(ex.getCode(), ex.getMessage()); | 19 | + return Message.failure(ex.getCode(), ex.getMessage()); |
20 | } | 20 | } |
21 | } | 21 | } |
src/main/java/com/diligrp/xtrade/order/rpc/feign/AccountService.java renamed to src/main/java/com/diligrp/xtrade/order/rpc/feign/AccountRPC.java
1 | -package com.diligrp.xtrade.order.rpc.feign; | ||
2 | - | ||
3 | -import org.springframework.cloud.openfeign.FeignClient; | ||
4 | -import org.springframework.web.bind.annotation.RequestMapping; | ||
5 | - | ||
6 | -import com.diligrp.xtrade.order.domain.dto.AccountDto; | ||
7 | -import com.diligrp.xtrade.shared.domain.Message; | ||
8 | - | ||
9 | -@FeignClient(value = "user-service") | ||
10 | -public interface AccountService { | ||
11 | - | ||
12 | - @RequestMapping("/dltAccount/getDltAccount") | ||
13 | - public Message<AccountDto> getDltAccount(); | ||
14 | - | ||
15 | -} | 1 | +package com.diligrp.xtrade.order.rpc.feign; |
2 | + | ||
3 | +import org.springframework.cloud.openfeign.FeignClient; | ||
4 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
5 | + | ||
6 | +import com.diligrp.xtrade.order.domain.dto.AccountDto; | ||
7 | +import com.diligrp.xtrade.shared.domain.Message; | ||
8 | + | ||
9 | +@FeignClient(value = "user-service") | ||
10 | +public interface AccountRPC { | ||
11 | + | ||
12 | + @RequestMapping("/dltAccount/getDltAccount") | ||
13 | + public Message<AccountDto> getDltAccount(Long account); | ||
14 | + | ||
15 | +} |
src/main/java/com/diligrp/xtrade/order/rpc/feign/CatagoryService.java deleted
100644 → 0
src/main/java/com/diligrp/xtrade/product/common/constants/Constant.java
src/main/java/com/diligrp/xtrade/product/common/utils/Constant.java deleted
100644 → 0
src/main/java/com/diligrp/xtrade/product/controllor/CategoryController.java
@@ -35,10 +35,9 @@ public class CategoryController { | @@ -35,10 +35,9 @@ public class CategoryController { | ||
35 | * @return | 35 | * @return |
36 | * @throws | 36 | * @throws |
37 | */ | 37 | */ |
38 | - @RequestMapping("save") | ||
39 | - public Message<Object> insert(@Validated @RequestBody CategoryDto categoryDTO){ | ||
40 | categoryService.insert(categoryDTO); | 38 | categoryService.insert(categoryDTO); |
41 | return Message.builder().success(); | 39 | return Message.builder().success(); |
40 | + return Message.success(); | ||
42 | } | 41 | } |
43 | /** | 42 | /** |
44 | * 修改品类 | 43 | * 修改品类 |
@@ -49,9 +48,8 @@ public class CategoryController { | @@ -49,9 +48,8 @@ public class CategoryController { | ||
49 | * @throws | 48 | * @throws |
50 | */ | 49 | */ |
51 | @RequestMapping("update") | 50 | @RequestMapping("update") |
52 | - public Message<Object> update(@Validated @RequestBody CategoryDto categoryDTO){ | ||
53 | - categoryService.update(categoryDTO); | ||
54 | - return Message.builder().success(); | 51 | + public Message<Object> update(CategoryDto categoryDTO){ categoryService.update(categoryDTO); |
52 | + | ||
55 | } | 53 | } |
56 | 54 | ||
57 | /** | 55 | /** |
@@ -64,7 +62,7 @@ public class CategoryController { | @@ -64,7 +62,7 @@ public class CategoryController { | ||
64 | */ | 62 | */ |
65 | @RequestMapping("get/{id}") | 63 | @RequestMapping("get/{id}") |
66 | public Message<?> get(@PathVariable Long id){ | 64 | public Message<?> get(@PathVariable Long id){ |
67 | - return Message.builder().success(categoryService.selectEntityById(id)); | 65 | + return Message.success(categoryService.selectEntityById(id)); |
68 | } | 66 | } |
69 | /** | 67 | /** |
70 | * 主键删除 | 68 | * 主键删除 |
@@ -75,7 +73,7 @@ public class CategoryController { | @@ -75,7 +73,7 @@ public class CategoryController { | ||
75 | * @throws | 73 | * @throws |
76 | */ | 74 | */ |
77 | @RequestMapping("delect/{id}") | 75 | @RequestMapping("delect/{id}") |
78 | - public Message<Object> delect(@PathVariable Long id){ | 76 | + public Message<?> delect(@PathVariable Long id){ |
79 | categoryService.delectById(id); | 77 | categoryService.delectById(id); |
80 | return Message.builder().success(); | 78 | return Message.builder().success(); |
81 | } | 79 | } |
src/main/java/com/diligrp/xtrade/product/controllor/MerchantController.java
0 → 100644
1 | +package com.diligrp.xtrade.product.controllor; | ||
2 | + | ||
3 | +import com.diligrp.xtrade.product.common.constants.Constant; | ||
4 | +import com.diligrp.xtrade.product.domain.dto.MerchantRequestDto; | ||
5 | +import com.diligrp.xtrade.product.domain.dto.MerchantResponseDto; | ||
6 | +import com.diligrp.xtrade.product.service.MerchantService; | ||
7 | +import com.diligrp.xtrade.shared.domain.Message; | ||
8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
9 | +import org.springframework.validation.annotation.Validated; | ||
10 | +import org.springframework.web.bind.annotation.PostMapping; | ||
11 | +import org.springframework.web.bind.annotation.RequestBody; | ||
12 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
13 | +import org.springframework.web.bind.annotation.RestController; | ||
14 | + | ||
15 | +/** | ||
16 | + * 市场接口 | ||
17 | + * | ||
18 | + * @author miaoguoxin | ||
19 | + * @since 2020-04-21 15:47:20 | ||
20 | + */ | ||
21 | +@RestController | ||
22 | +@RequestMapping("/sapi/merchant") | ||
23 | +public class MerchantController { | ||
24 | + @Autowired | ||
25 | + private MerchantService merchantService; | ||
26 | + | ||
27 | + @PostMapping("/save") | ||
28 | + public Message<MerchantResponseDto> save(@RequestBody @Validated(Constant.InsertGroup.class) | ||
29 | + MerchantRequestDto requestDto) throws Exception { | ||
30 | + return Message.success(merchantService.create(requestDto)); | ||
31 | + } | ||
32 | +} |
src/main/java/com/diligrp/xtrade/product/controllor/ProductApiControllor.java
@@ -21,17 +21,17 @@ public class ProductApiControllor { | @@ -21,17 +21,17 @@ public class ProductApiControllor { | ||
21 | @RequestMapping(value = "/createProduct") | 21 | @RequestMapping(value = "/createProduct") |
22 | public Message createOrder(@RequestBody ProductCreateRequestDto productCreateRequestDto) { | 22 | public Message createOrder(@RequestBody ProductCreateRequestDto productCreateRequestDto) { |
23 | productService.createProduct(productCreateRequestDto); | 23 | productService.createProduct(productCreateRequestDto); |
24 | - return Message.builder().success(); | 24 | + return Message.success(); |
25 | } | 25 | } |
26 | 26 | ||
27 | @RequestMapping(value = "/listProducts") | 27 | @RequestMapping(value = "/listProducts") |
28 | public Message listOrders(@RequestBody ProductQueryRequestDto productQueryRequestDto) { | 28 | public Message listOrders(@RequestBody ProductQueryRequestDto productQueryRequestDto) { |
29 | - return Message.builder().success(productService.orderLists(productQueryRequestDto)); | 29 | + return Message.success(productService.orderLists(productQueryRequestDto)); |
30 | } | 30 | } |
31 | 31 | ||
32 | @RequestMapping(value = "/productDetail") | 32 | @RequestMapping(value = "/productDetail") |
33 | public Message orderDetail(@RequestBody ProductQueryRequestDto productQueryRequestDto) { | 33 | public Message orderDetail(@RequestBody ProductQueryRequestDto productQueryRequestDto) { |
34 | - return Message.builder().success(productService.orderDetail(productQueryRequestDto)); | 34 | + return Message.success(productService.orderDetail(productQueryRequestDto)); |
35 | } | 35 | } |
36 | 36 | ||
37 | } | 37 | } |
src/main/java/com/diligrp/xtrade/product/controllor/ShopController.java
@@ -37,9 +37,10 @@ public class ShopController { | @@ -37,9 +37,10 @@ public class ShopController { | ||
37 | * @throws | 37 | * @throws |
38 | */ | 38 | */ |
39 | @RequestMapping("save") | 39 | @RequestMapping("save") |
40 | + | ||
40 | public Message<?> save(@Validated @RequestBody ShopDto shop){ | 41 | public Message<?> save(@Validated @RequestBody ShopDto shop){ |
41 | shopService.insert(shop); | 42 | shopService.insert(shop); |
42 | - return Message.builder().success(); | 43 | + |
43 | } | 44 | } |
44 | 45 | ||
45 | /** | 46 | /** |
@@ -51,8 +52,9 @@ public class ShopController { | @@ -51,8 +52,9 @@ public class ShopController { | ||
51 | * @throws | 52 | * @throws |
52 | */ | 53 | */ |
53 | @RequestMapping("get/{shopId}") | 54 | @RequestMapping("get/{shopId}") |
55 | + | ||
54 | public Message<?> get(@PathVariable Long shopId){ | 56 | public Message<?> get(@PathVariable Long shopId){ |
55 | - return Message.builder().success(shopService.selectByShopId(shopId)); | 57 | + |
56 | } | 58 | } |
57 | 59 | ||
58 | /** | 60 | /** |
@@ -66,7 +68,7 @@ public class ShopController { | @@ -66,7 +68,7 @@ public class ShopController { | ||
66 | @RequestMapping("selectShopByMerId/{merId}") | 68 | @RequestMapping("selectShopByMerId/{merId}") |
67 | public Message<?> selectShopByMerId(@PathVariable Long merId){ | 69 | public Message<?> selectShopByMerId(@PathVariable Long merId){ |
68 | List<ShopDo> shopDos = shopService.selectShopByMerId(merId); | 70 | List<ShopDo> shopDos = shopService.selectShopByMerId(merId); |
69 | - return Message.builder().success(shopDos); | 71 | + |
70 | } | 72 | } |
71 | 73 | ||
72 | /** | 74 | /** |
src/main/java/com/diligrp/xtrade/product/dao/MerchantDao.java
1 | package com.diligrp.xtrade.product.dao; | 1 | package com.diligrp.xtrade.product.dao; |
2 | 2 | ||
3 | +import com.diligrp.xtrade.product.domain.entity.Merchant; | ||
4 | +import org.apache.ibatis.annotations.Param; | ||
5 | + | ||
6 | +import java.util.List; | ||
7 | + | ||
3 | public interface MerchantDao { | 8 | public interface MerchantDao { |
4 | 9 | ||
10 | + Merchant findById(Long id); | ||
11 | + | ||
12 | + List<Merchant> findPage(@Param("offset") int offset, @Param("limit") int limit); | ||
13 | + | ||
14 | + List<Merchant> findByCondition(Merchant xtMerchant); | ||
15 | + | ||
16 | + int insert(Merchant merchant); | ||
17 | + | ||
18 | + int update(Merchant xtMerchant); | ||
19 | + | ||
20 | + int deleteById(Long id); | ||
21 | + | ||
5 | } | 22 | } |
src/main/java/com/diligrp/xtrade/product/domain/converter/MerchantConverter.java
0 → 100644
1 | +package com.diligrp.xtrade.product.domain.converter; | ||
2 | + | ||
3 | +import com.diligrp.xtrade.product.domain.dto.MerchantRequestDto; | ||
4 | +import com.diligrp.xtrade.product.domain.dto.MerchantResponseDto; | ||
5 | +import com.diligrp.xtrade.product.domain.emuns.AccountType; | ||
6 | +import com.diligrp.xtrade.product.domain.emuns.MerchantStatus; | ||
7 | +import com.diligrp.xtrade.product.domain.entity.Merchant; | ||
8 | +import org.springframework.beans.BeanUtils; | ||
9 | +import org.springframework.stereotype.Component; | ||
10 | + | ||
11 | +import java.util.Optional; | ||
12 | + | ||
13 | +/** | ||
14 | + * @Auther: miaoguoxin | ||
15 | + * @Date: 2020/4/22 09:10 | ||
16 | + * @Description: 用于merchant的实体转换 | ||
17 | + */ | ||
18 | +@Component | ||
19 | +public class MerchantConverter { | ||
20 | + | ||
21 | + public Merchant request2Entity(MerchantRequestDto requestDto) { | ||
22 | + Integer type = Optional.ofNullable(requestDto.getAccountType()) | ||
23 | + .map(AccountType::getCode) | ||
24 | + .orElse(0); | ||
25 | + Merchant merchant = new Merchant(); | ||
26 | + merchant.setMerName(requestDto.getMerchantName()); | ||
27 | + merchant.setAccountId(requestDto.getAccountId()); | ||
28 | + merchant.setType(type); | ||
29 | + merchant.setDescription(requestDto.getAddress()); | ||
30 | + merchant.setStatus(MerchantStatus.NORMAL.getType()); | ||
31 | + return merchant; | ||
32 | + } | ||
33 | + | ||
34 | + public MerchantResponseDto entity2Response(Merchant merchant){ | ||
35 | + MerchantResponseDto responseDto = new MerchantResponseDto(); | ||
36 | + BeanUtils.copyProperties(merchant,responseDto); | ||
37 | + responseDto.setType(AccountType.getAccountType(merchant.getType())); | ||
38 | + return responseDto; | ||
39 | + } | ||
40 | +} |
src/main/java/com/diligrp/xtrade/product/domain/dto/MerchantRequestDto.java
0 → 100644
1 | +package com.diligrp.xtrade.product.domain.dto; | ||
2 | + | ||
3 | +import com.diligrp.xtrade.product.common.constants.Constant; | ||
4 | +import com.diligrp.xtrade.product.domain.emuns.AccountType; | ||
5 | + | ||
6 | +import javax.validation.constraints.NotBlank; | ||
7 | +import javax.validation.constraints.NotNull; | ||
8 | +import javax.validation.constraints.Pattern; | ||
9 | +import java.io.Serializable; | ||
10 | + | ||
11 | +/** | ||
12 | + * @Auther: miaoguoxin | ||
13 | + * @Date: 2020/4/21 15:54 | ||
14 | + */ | ||
15 | +public class MerchantRequestDto implements Serializable { | ||
16 | + /**账户id*/ | ||
17 | + private transient Long accountId; | ||
18 | + /**真实名字*/ | ||
19 | + private transient String realName; | ||
20 | + /**用户名字*/ | ||
21 | + @NotBlank(message = "{merchant.user_name.not.blank}", groups = Constant.InsertGroup.class) | ||
22 | + @Pattern(regexp = "^[a-zA-Z0-9\u4E00-\u9FA5._,:-]*$",message = "{illegal.pattern}",groups = Constant.InsertGroup.class) | ||
23 | + private String userName; | ||
24 | + /**密码*/ | ||
25 | + private String password; | ||
26 | + /**电话*/ | ||
27 | + private String mobile; | ||
28 | + /**账户类型*/ | ||
29 | + @NotNull(message = "{account_type.not.null}", groups = Constant.InsertGroup.class) | ||
30 | + private AccountType accountType; | ||
31 | + /**市场名称*/ | ||
32 | + @NotBlank(message = "{merchant_name.not.blank}",groups = Constant.InsertGroup.class) | ||
33 | + @Pattern(regexp = "^[a-zA-Z0-9\u4E00-\u9FA5._,:-]*$",message = "{illegal.pattern}",groups = Constant.InsertGroup.class) | ||
34 | + private String merchantName; | ||
35 | + /**市场地址*/ | ||
36 | + private String address; | ||
37 | + | ||
38 | + public String getRealName() { | ||
39 | + return realName; | ||
40 | + } | ||
41 | + | ||
42 | + public void setRealName(String realName) { | ||
43 | + this.realName = realName; | ||
44 | + } | ||
45 | + | ||
46 | + public Long getAccountId() { | ||
47 | + return accountId; | ||
48 | + } | ||
49 | + | ||
50 | + public void setAccountId(Long accountId) { | ||
51 | + this.accountId = accountId; | ||
52 | + } | ||
53 | + | ||
54 | + public String getUserName() { | ||
55 | + return userName; | ||
56 | + } | ||
57 | + | ||
58 | + public void setUserName(String userName) { | ||
59 | + this.userName = userName; | ||
60 | + } | ||
61 | + | ||
62 | + public String getPassword() { | ||
63 | + return password; | ||
64 | + } | ||
65 | + | ||
66 | + public void setPassword(String password) { | ||
67 | + this.password = password; | ||
68 | + } | ||
69 | + | ||
70 | + public String getMobile() { | ||
71 | + return mobile; | ||
72 | + } | ||
73 | + | ||
74 | + public void setMobile(String mobile) { | ||
75 | + this.mobile = mobile; | ||
76 | + } | ||
77 | + | ||
78 | + public AccountType getAccountType() { | ||
79 | + return accountType; | ||
80 | + } | ||
81 | + | ||
82 | + public void setAccountType(AccountType accountType) { | ||
83 | + this.accountType = accountType; | ||
84 | + } | ||
85 | + | ||
86 | + public String getMerchantName() { | ||
87 | + return merchantName; | ||
88 | + } | ||
89 | + | ||
90 | + public void setMerchantName(String merchantName) { | ||
91 | + this.merchantName = merchantName; | ||
92 | + } | ||
93 | + | ||
94 | + public String getAddress() { | ||
95 | + return address; | ||
96 | + } | ||
97 | + | ||
98 | + public void setAddress(String address) { | ||
99 | + this.address = address; | ||
100 | + } | ||
101 | +} |
src/main/java/com/diligrp/xtrade/product/domain/dto/MerchantResponseDto.java
0 → 100644
1 | +package com.diligrp.xtrade.product.domain.dto; | ||
2 | + | ||
3 | +import com.diligrp.xtrade.product.domain.emuns.AccountType; | ||
4 | + | ||
5 | +import java.io.Serializable; | ||
6 | + | ||
7 | +/** | ||
8 | + * @Auther: miaoguoxin | ||
9 | + * @Date: 2020/4/21 16:04 | ||
10 | + */ | ||
11 | +public class MerchantResponseDto implements Serializable { | ||
12 | + //商户id | ||
13 | + private Long merId; | ||
14 | + | ||
15 | + //商户名称 | ||
16 | + private String merName; | ||
17 | + | ||
18 | + //园区编码 | ||
19 | + private String marketId; | ||
20 | + | ||
21 | + /**类型 */ | ||
22 | + private AccountType type; | ||
23 | + | ||
24 | + //主账号 | ||
25 | + private Long accountId; | ||
26 | + | ||
27 | + //账户名称 | ||
28 | + private String accountName; | ||
29 | + | ||
30 | + //商户状态 | ||
31 | + private Integer status; | ||
32 | + | ||
33 | + //市场编码 | ||
34 | + private String marketCode; | ||
35 | + | ||
36 | + //描述 | ||
37 | + private String description; | ||
38 | + | ||
39 | + public Long getMerId() { | ||
40 | + return merId; | ||
41 | + } | ||
42 | + | ||
43 | + public void setMerId(Long merId) { | ||
44 | + this.merId = merId; | ||
45 | + } | ||
46 | + | ||
47 | + public String getMerName() { | ||
48 | + return merName; | ||
49 | + } | ||
50 | + | ||
51 | + public void setMerName(String merName) { | ||
52 | + this.merName = merName; | ||
53 | + } | ||
54 | + | ||
55 | + public String getMarketId() { | ||
56 | + return marketId; | ||
57 | + } | ||
58 | + | ||
59 | + public void setMarketId(String marketId) { | ||
60 | + this.marketId = marketId; | ||
61 | + } | ||
62 | + | ||
63 | + public AccountType getType() { | ||
64 | + return type; | ||
65 | + } | ||
66 | + | ||
67 | + public void setType(AccountType type) { | ||
68 | + this.type = type; | ||
69 | + } | ||
70 | + | ||
71 | + public Long getAccountId() { | ||
72 | + return accountId; | ||
73 | + } | ||
74 | + | ||
75 | + public void setAccountId(Long accountId) { | ||
76 | + this.accountId = accountId; | ||
77 | + } | ||
78 | + | ||
79 | + public String getAccountName() { | ||
80 | + return accountName; | ||
81 | + } | ||
82 | + | ||
83 | + public void setAccountName(String accountName) { | ||
84 | + this.accountName = accountName; | ||
85 | + } | ||
86 | + | ||
87 | + public Integer getStatus() { | ||
88 | + return status; | ||
89 | + } | ||
90 | + | ||
91 | + public void setStatus(Integer status) { | ||
92 | + this.status = status; | ||
93 | + } | ||
94 | + | ||
95 | + public String getMarketCode() { | ||
96 | + return marketCode; | ||
97 | + } | ||
98 | + | ||
99 | + public void setMarketCode(String marketCode) { | ||
100 | + this.marketCode = marketCode; | ||
101 | + } | ||
102 | + | ||
103 | + public String getDescription() { | ||
104 | + return description; | ||
105 | + } | ||
106 | + | ||
107 | + public void setDescription(String description) { | ||
108 | + this.description = description; | ||
109 | + } | ||
110 | +} |
src/main/java/com/diligrp/xtrade/product/domain/emuns/AccountStatus.java
0 → 100644
1 | +/** | ||
2 | + * Copyright (c) 2016 www.diligrp.com All rights reserved. <br /> | ||
3 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
4 | + * | ||
5 | + */ | ||
6 | +package com.diligrp.xtrade.product.domain.emuns; | ||
7 | + | ||
8 | +import com.diligrp.xtrade.shared.type.IEnumType; | ||
9 | + | ||
10 | +import java.util.Arrays; | ||
11 | + | ||
12 | +/** | ||
13 | + * 账户状态的枚举类 | ||
14 | + */ | ||
15 | +public enum AccountStatus implements IEnumType { | ||
16 | + NORMAL(1, "正常"), | ||
17 | + LOCKED(2, "锁定") | ||
18 | + ; | ||
19 | + | ||
20 | + private int code; | ||
21 | + private String name; | ||
22 | + | ||
23 | + AccountStatus(int code, String name) { | ||
24 | + this.code = code; | ||
25 | + this.name = name; | ||
26 | + } | ||
27 | + | ||
28 | + | ||
29 | + @Override | ||
30 | + public int getCode() { | ||
31 | + return this.code; | ||
32 | + } | ||
33 | + | ||
34 | + public String getName() { | ||
35 | + return this.name; | ||
36 | + } | ||
37 | + | ||
38 | + public static AccountStatus getByType(int code) { | ||
39 | + return Arrays.stream(values()) | ||
40 | + .filter(accountStatus -> accountStatus.getCode() == code) | ||
41 | + .findFirst() | ||
42 | + .orElse(null); | ||
43 | + } | ||
44 | + | ||
45 | + public static String getName(int index) { | ||
46 | + return Arrays.stream(AccountStatus.values()) | ||
47 | + .filter(c -> c.getCode() == index) | ||
48 | + .findFirst().map(c -> c.name) | ||
49 | + .orElse(null); | ||
50 | + } | ||
51 | + | ||
52 | +} |
src/main/java/com/diligrp/xtrade/product/domain/emuns/AccountType.java
0 → 100644
1 | +package com.diligrp.xtrade.product.domain.emuns; | ||
2 | + | ||
3 | +import com.diligrp.xtrade.shared.type.IEnumType; | ||
4 | +import com.fasterxml.jackson.annotation.JsonCreator; | ||
5 | +import com.fasterxml.jackson.annotation.JsonValue; | ||
6 | + | ||
7 | +import java.util.Arrays; | ||
8 | + | ||
9 | +/** | ||
10 | + * @Auther: miaoguoxin | ||
11 | + * @Date: 2020/4/21 16:13 | ||
12 | + */ | ||
13 | +public enum AccountType implements IEnumType { | ||
14 | + PERSONAL(10, "个人账户"), | ||
15 | + | ||
16 | + PUBLIC(20, "对公账户"), | ||
17 | + | ||
18 | + /**临时卡用*/ | ||
19 | + Anonymous(30, "不记名"); | ||
20 | + | ||
21 | + private int code; | ||
22 | + private String name; | ||
23 | + | ||
24 | + AccountType(int code,String name) | ||
25 | + { | ||
26 | + this.name = name; | ||
27 | + this.code = code; | ||
28 | + } | ||
29 | + | ||
30 | + @JsonCreator | ||
31 | + public static AccountType getAccountType(int code) | ||
32 | + { | ||
33 | + return Arrays.stream(AccountType.values()) | ||
34 | + .filter(type -> type.getCode() == code) | ||
35 | + .findFirst() | ||
36 | + .orElse(null); | ||
37 | + } | ||
38 | + | ||
39 | + public static String getName(int code) | ||
40 | + { | ||
41 | + return Arrays.stream(AccountType.values()) | ||
42 | + .filter(type -> type.getCode() == code) | ||
43 | + .findFirst() | ||
44 | + .map(type -> type.name) | ||
45 | + .orElse(null); | ||
46 | + } | ||
47 | + | ||
48 | + @Override | ||
49 | + public String getName() | ||
50 | + { | ||
51 | + return this.name; | ||
52 | + } | ||
53 | + | ||
54 | + @Override | ||
55 | + @JsonValue | ||
56 | + public int getCode() | ||
57 | + { | ||
58 | + return this.code; | ||
59 | + } | ||
60 | + | ||
61 | +} |
src/main/java/com/diligrp/xtrade/product/domain/emuns/IKeyGeneratorKeys.java
1 | -package com.diligrp.xtrade.product.domain.emuns; | ||
2 | - | ||
3 | -/** | ||
4 | - * @ClassName: IKeyGeneratorKeys | ||
5 | - * @Description id生成key配置 | ||
6 | - * @author yangfan | ||
7 | - * @date 2020年4月21日 | ||
8 | - */ | ||
9 | -public enum IKeyGeneratorKeys { | ||
10 | - SHOP_SEQUENCE, | ||
11 | - CATEGORY_SEQUENCE | ||
12 | -} | 1 | +package com.diligrp.xtrade.product.domain.emuns; |
2 | + | ||
3 | + | ||
4 | +/** | ||
5 | + * @ClassName: IKeyGeneratorKeys | ||
6 | + * @Description id生成key配置 | ||
7 | + * @author yangfan | ||
8 | + * @date 2020年4月21日 | ||
9 | + */ | ||
10 | +public enum IKeyGeneratorKeys { | ||
11 | + SHOP_SEQUENCE("SHOP_SEQUENCE","店铺id"), | ||
12 | + MERCHANT_SEQUENCE("MERCHANT_SEQUENCE","市场id"), | ||
13 | + ACCOUNT_SEQUENCE("ACCOUNT_SEQUENCE","账号id") | ||
14 | + ; | ||
15 | + | ||
16 | + private String code; | ||
17 | + private String name; | ||
18 | + | ||
19 | + IKeyGeneratorKeys(String code, String name) { | ||
20 | + this.code = code; | ||
21 | + this.name = name; | ||
22 | + } | ||
23 | + | ||
24 | + public String getCode() { | ||
25 | + return code; | ||
26 | + } | ||
27 | + | ||
28 | + public String getName() { | ||
29 | + return name; | ||
30 | + } | ||
31 | +} |
src/main/java/com/diligrp/xtrade/product/domain/emuns/MerchantStatus.java
0 → 100644
1 | +package com.diligrp.xtrade.product.domain.emuns; | ||
2 | + | ||
3 | +import com.diligrp.xtrade.shared.type.IEnumType; | ||
4 | + | ||
5 | +import java.util.Arrays; | ||
6 | + | ||
7 | +/** | ||
8 | + * @Auther: miaoguoxin | ||
9 | + * @Date: 2020/4/21 16:31 | ||
10 | + */ | ||
11 | +public enum MerchantStatus implements IEnumType { | ||
12 | + NORMAL(1, "正常"), | ||
13 | + LIMITED(2, "受限"); | ||
14 | + | ||
15 | + private int type; | ||
16 | + private String name; | ||
17 | + | ||
18 | + MerchantStatus(int type, String name) { | ||
19 | + this.type = type; | ||
20 | + this.name = name; | ||
21 | + } | ||
22 | + | ||
23 | + public int getType() { | ||
24 | + return type; | ||
25 | + } | ||
26 | + | ||
27 | + @Override | ||
28 | + public int getCode() { | ||
29 | + return this.type; | ||
30 | + } | ||
31 | + @Override | ||
32 | + public String getName() { | ||
33 | + return this.name; | ||
34 | + } | ||
35 | + | ||
36 | + public static MerchantStatus getByType(int type) { | ||
37 | + return Arrays.stream(values()) | ||
38 | + .filter(accountStatus -> accountStatus.getType() == type) | ||
39 | + .findFirst() | ||
40 | + .orElse(null); | ||
41 | + } | ||
42 | + | ||
43 | + public static String getName(int index) { | ||
44 | + return Arrays.stream(MerchantStatus.values()) | ||
45 | + .filter(c -> c.getType() == index).findFirst() | ||
46 | + .map(c -> c.name) | ||
47 | + .orElse(null); | ||
48 | + } | ||
49 | +} |
src/main/java/com/diligrp/xtrade/product/domain/emuns/ResponseCode.java
0 → 100644
1 | +package com.diligrp.xtrade.product.domain.emuns; | ||
2 | + | ||
3 | +import com.diligrp.xtrade.shared.type.IEnumType; | ||
4 | + | ||
5 | +/** | ||
6 | + * @Auther: miaoguoxin | ||
7 | + * @Date: 2020/4/22 08:48 | ||
8 | + * @Description: 响应code枚举 | ||
9 | + */ | ||
10 | +public enum ResponseCode implements IEnumType { | ||
11 | + ACCOUNT_EXIST(200001,"账号已存在"), | ||
12 | + CARD_MERCHANT_CREATED(200002,"该卡已创建商户,请使用用户名密码登录"), | ||
13 | + ; | ||
14 | + | ||
15 | + | ||
16 | + private int code; | ||
17 | + private String name; | ||
18 | + | ||
19 | + ResponseCode(int code,String name) | ||
20 | + { | ||
21 | + this.name = name; | ||
22 | + this.code = code; | ||
23 | + } | ||
24 | + | ||
25 | + @Override | ||
26 | + public int getCode() { | ||
27 | + return this.code; | ||
28 | + } | ||
29 | + | ||
30 | + @Override | ||
31 | + public String getName() { | ||
32 | + return this.name; | ||
33 | + } | ||
34 | +} |
src/main/java/com/diligrp/xtrade/product/domain/entity/Account.java
0 → 100644
1 | +package com.diligrp.xtrade.product.domain.entity; | ||
2 | + | ||
3 | +import com.diligrp.xtrade.shared.domain.BaseDo; | ||
4 | + | ||
5 | +/** | ||
6 | + * @Auther: miaoguoxin | ||
7 | + * @Date: 2020/4/21 17:20 | ||
8 | + * @Description: 账户实体 | ||
9 | + */ | ||
10 | +public class Account extends BaseDo { | ||
11 | + private String name; | ||
12 | + private String password; | ||
13 | + private String realName; | ||
14 | + private String mobile; | ||
15 | + private Integer status; | ||
16 | + private Long merId; | ||
17 | + private Integer isAdmin; | ||
18 | + private String role; | ||
19 | + private String shops; | ||
20 | + private Long roleId; | ||
21 | + | ||
22 | + public String getName() { | ||
23 | + return name; | ||
24 | + } | ||
25 | + | ||
26 | + public void setName(String name) { | ||
27 | + this.name = name; | ||
28 | + } | ||
29 | + | ||
30 | + public String getPassword() { | ||
31 | + return password; | ||
32 | + } | ||
33 | + | ||
34 | + public void setPassword(String password) { | ||
35 | + this.password = password; | ||
36 | + } | ||
37 | + | ||
38 | + public String getRealName() { | ||
39 | + return realName; | ||
40 | + } | ||
41 | + | ||
42 | + public void setRealName(String realName) { | ||
43 | + this.realName = realName; | ||
44 | + } | ||
45 | + | ||
46 | + public String getMobile() { | ||
47 | + return mobile; | ||
48 | + } | ||
49 | + | ||
50 | + public void setMobile(String mobile) { | ||
51 | + this.mobile = mobile; | ||
52 | + } | ||
53 | + | ||
54 | + public Integer getStatus() { | ||
55 | + return status; | ||
56 | + } | ||
57 | + | ||
58 | + public void setStatus(Integer status) { | ||
59 | + this.status = status; | ||
60 | + } | ||
61 | + | ||
62 | + public Long getMerId() { | ||
63 | + return merId; | ||
64 | + } | ||
65 | + | ||
66 | + public void setMerId(Long merId) { | ||
67 | + this.merId = merId; | ||
68 | + } | ||
69 | + | ||
70 | + public Integer getIsAdmin() { | ||
71 | + return isAdmin; | ||
72 | + } | ||
73 | + | ||
74 | + public void setIsAdmin(Integer isAdmin) { | ||
75 | + this.isAdmin = isAdmin; | ||
76 | + } | ||
77 | + | ||
78 | + public String getRole() { | ||
79 | + return role; | ||
80 | + } | ||
81 | + | ||
82 | + public void setRole(String role) { | ||
83 | + this.role = role; | ||
84 | + } | ||
85 | + | ||
86 | + public String getShops() { | ||
87 | + return shops; | ||
88 | + } | ||
89 | + | ||
90 | + public void setShops(String shops) { | ||
91 | + this.shops = shops; | ||
92 | + } | ||
93 | + | ||
94 | + public Long getRoleId() { | ||
95 | + return roleId; | ||
96 | + } | ||
97 | + | ||
98 | + public void setRoleId(Long roleId) { | ||
99 | + this.roleId = roleId; | ||
100 | + } | ||
101 | + | ||
102 | +} |
src/main/java/com/diligrp/xtrade/product/domain/entity/Merchant.java
1 | package com.diligrp.xtrade.product.domain.entity; | 1 | package com.diligrp.xtrade.product.domain.entity; |
2 | 2 | ||
3 | +import com.diligrp.xtrade.product.domain.emuns.AccountType; | ||
3 | import com.diligrp.xtrade.shared.domain.BaseDo; | 4 | import com.diligrp.xtrade.shared.domain.BaseDo; |
4 | 5 | ||
5 | /** | 6 | /** |
6 | - * 商户实体 | ||
7 | - * @author kuk | ||
8 | - * | 7 | + * 商户实体(xt_merchant) |
9 | */ | 8 | */ |
10 | -public class Merchant extends BaseDo{ | ||
11 | - | ||
12 | - //商户id | ||
13 | - private Long merId; | ||
14 | - | ||
15 | - //商户名称 | ||
16 | - private String merName; | ||
17 | - | ||
18 | - //类型 | ||
19 | - private Integer type; | ||
20 | - | ||
21 | - //主账号 | ||
22 | - private Long accountId; | ||
23 | - | ||
24 | - //商户状态 | ||
25 | - private Integer status; | ||
26 | - | ||
27 | - //市场编码 | ||
28 | - private String marketCode; | ||
29 | - | ||
30 | - //描述 | ||
31 | - private String description; | ||
32 | - | ||
33 | - public Merchant(){ | ||
34 | - } | ||
35 | - | ||
36 | - public Merchant(Long merId){ | ||
37 | - this.setMerId(merId); | ||
38 | - } | ||
39 | - | ||
40 | - /** | ||
41 | - * 获取 商户编码 | ||
42 | - * @return | ||
43 | - */ | ||
44 | - public Long getMerId(){ | ||
45 | - return merId; | ||
46 | - } | ||
47 | - | ||
48 | - /** | ||
49 | - * 设置 商户编码 | ||
50 | - * @param merId | ||
51 | - */ | ||
52 | - public void setMerId(Long merId){ | ||
53 | - this.merId = merId; | ||
54 | - } | ||
55 | - | ||
56 | - /** | ||
57 | - * 获取 商户名称 | ||
58 | - * @return | ||
59 | - */ | ||
60 | - public String getMerName(){ | ||
61 | - return merName; | ||
62 | - } | ||
63 | - | ||
64 | - /** | ||
65 | - * 设置 商户名称 | ||
66 | - * @param merName | ||
67 | - */ | ||
68 | - public void setMerName(String merName){ | ||
69 | - this.merName = merName; | ||
70 | - } | ||
71 | - | ||
72 | - /** | ||
73 | - * 获取 商户类型-个体、企业 | ||
74 | - * @return | ||
75 | - */ | ||
76 | - public Integer getType(){ | ||
77 | - return type; | ||
78 | - } | ||
79 | - | ||
80 | - /** | ||
81 | - * 设置 商户类型-个体、企业 | ||
82 | - * @param type | ||
83 | - */ | ||
84 | - public void setType(Integer type){ | ||
85 | - this.type = type; | ||
86 | - } | ||
87 | - | ||
88 | - /** | ||
89 | - * 获取 账户ID | ||
90 | - * @return | ||
91 | - */ | ||
92 | - public Long getAccountId(){ | ||
93 | - return accountId; | ||
94 | - } | ||
95 | - | ||
96 | - /** | ||
97 | - * 设置 账户ID | ||
98 | - * @param accountId | ||
99 | - */ | ||
100 | - public void setAccountId(Long accountId){ | ||
101 | - this.accountId = accountId; | ||
102 | - } | ||
103 | - | ||
104 | - /** | ||
105 | - * 获取 商户状态 | ||
106 | - * @return | ||
107 | - */ | ||
108 | - public Integer getStatus(){ | ||
109 | - return status; | ||
110 | - } | ||
111 | - | ||
112 | - /** | ||
113 | - * 设置 商户状态 | ||
114 | - * @param status | ||
115 | - */ | ||
116 | - public void setStatus(Integer status){ | ||
117 | - this.status = status; | ||
118 | - } | ||
119 | - | ||
120 | - | ||
121 | - /** | ||
122 | - * 获取 商户描述 | ||
123 | - * @return | ||
124 | - */ | ||
125 | - public String getDescription(){ | ||
126 | - return description; | ||
127 | - } | ||
128 | - | ||
129 | - /** | ||
130 | - * 设置 商户描述 | ||
131 | - * @param description | ||
132 | - */ | ||
133 | - public void setDescription(String description){ | ||
134 | - this.description = description; | ||
135 | - } | ||
136 | - | ||
137 | - public String getMarketCode() { | ||
138 | - return marketCode; | ||
139 | - } | ||
140 | - | ||
141 | - public void setMarketCode(String marketCode) { | ||
142 | - this.marketCode = marketCode; | ||
143 | - } | ||
144 | -} | ||
145 | \ No newline at end of file | 9 | \ No newline at end of file |
10 | +public class Merchant extends BaseDo { | ||
11 | + //商户id | ||
12 | + private Long merId; | ||
13 | + | ||
14 | + //商户名称 | ||
15 | + private String merName; | ||
16 | + | ||
17 | + //园区编码 | ||
18 | + private String marketId; | ||
19 | + | ||
20 | + /**类型 {@link AccountType}*/ | ||
21 | + private Integer type; | ||
22 | + | ||
23 | + //主账号 | ||
24 | + private Long accountId; | ||
25 | + | ||
26 | + //账户名称 | ||
27 | + private String accountName; | ||
28 | + | ||
29 | + //商户状态 | ||
30 | + private Integer status; | ||
31 | + | ||
32 | + //市场编码 | ||
33 | + private String marketCode; | ||
34 | + | ||
35 | + //描述 | ||
36 | + private String description; | ||
37 | + | ||
38 | + | ||
39 | + public String getMarketId() { | ||
40 | + return marketId; | ||
41 | + } | ||
42 | + | ||
43 | + public void setMarketId(String marketId) { | ||
44 | + this.marketId = marketId; | ||
45 | + } | ||
46 | + | ||
47 | + public String getAccountName() { | ||
48 | + return accountName; | ||
49 | + } | ||
50 | + | ||
51 | + public void setAccountName(String accountName) { | ||
52 | + this.accountName = accountName; | ||
53 | + } | ||
54 | + | ||
55 | + public Long getMerId() { | ||
56 | + return merId; | ||
57 | + } | ||
58 | + | ||
59 | + public void setMerId(Long merId) { | ||
60 | + this.merId = merId; | ||
61 | + } | ||
62 | + | ||
63 | + public String getMerName() { | ||
64 | + return merName; | ||
65 | + } | ||
66 | + | ||
67 | + public void setMerName(String merName) { | ||
68 | + this.merName = merName; | ||
69 | + } | ||
70 | + | ||
71 | + public Integer getType() { | ||
72 | + return type; | ||
73 | + } | ||
74 | + | ||
75 | + public void setType(Integer type) { | ||
76 | + this.type = type; | ||
77 | + } | ||
78 | + | ||
79 | + public Long getAccountId() { | ||
80 | + return accountId; | ||
81 | + } | ||
82 | + | ||
83 | + public void setAccountId(Long accountId) { | ||
84 | + this.accountId = accountId; | ||
85 | + } | ||
86 | + | ||
87 | + public Integer getStatus() { | ||
88 | + return status; | ||
89 | + } | ||
90 | + | ||
91 | + public void setStatus(Integer status) { | ||
92 | + this.status = status; | ||
93 | + } | ||
94 | + | ||
95 | + public String getDescription() { | ||
96 | + return description; | ||
97 | + } | ||
98 | + | ||
99 | + public void setDescription(String description) { | ||
100 | + this.description = description; | ||
101 | + } | ||
102 | + | ||
103 | + public String getMarketCode() { | ||
104 | + return marketCode; | ||
105 | + } | ||
106 | + | ||
107 | + public void setMarketCode(String marketCode) { | ||
108 | + this.marketCode = marketCode; | ||
109 | + } | ||
110 | +} |
src/main/java/com/diligrp/xtrade/product/domain/entity/Operator.java
0 → 100644
1 | +package com.diligrp.xtrade.product.domain.entity; | ||
2 | + | ||
3 | +/** | ||
4 | + * @Auther: miaoguoxin | ||
5 | + * @Date: 2020/4/21 17:15 | ||
6 | + * @Description: 操作员实体 | ||
7 | + */ | ||
8 | +public class Operator { | ||
9 | + private Long accountId; | ||
10 | + private String account; | ||
11 | + private String name; | ||
12 | + private String mobile; | ||
13 | + private Long merId; | ||
14 | + private String merName; | ||
15 | + private Long roleId; | ||
16 | + // 商户对应卡务账户ID | ||
17 | + private Long merAccountId; | ||
18 | + //商户对应资金账号ID | ||
19 | + private Long merFundAccountId; | ||
20 | + private boolean admin; | ||
21 | + | ||
22 | + public Long getAccountId() { | ||
23 | + return accountId; | ||
24 | + } | ||
25 | + | ||
26 | + public void setAccountId(Long accountId) { | ||
27 | + this.accountId = accountId; | ||
28 | + } | ||
29 | + | ||
30 | + public String getAccount() { | ||
31 | + return account; | ||
32 | + } | ||
33 | + | ||
34 | + public void setAccount(String account) { | ||
35 | + this.account = account; | ||
36 | + } | ||
37 | + | ||
38 | + public String getName() { | ||
39 | + return name; | ||
40 | + } | ||
41 | + | ||
42 | + public void setName(String name) { | ||
43 | + this.name = name; | ||
44 | + } | ||
45 | + | ||
46 | + public String getMobile() { | ||
47 | + return mobile; | ||
48 | + } | ||
49 | + | ||
50 | + public void setMobile(String mobile) { | ||
51 | + this.mobile = mobile; | ||
52 | + } | ||
53 | + | ||
54 | + public Long getMerId() { | ||
55 | + return merId; | ||
56 | + } | ||
57 | + | ||
58 | + public void setMerId(Long merId) { | ||
59 | + this.merId = merId; | ||
60 | + } | ||
61 | + | ||
62 | + public String getMerName() { | ||
63 | + return merName; | ||
64 | + } | ||
65 | + | ||
66 | + public void setMerName(String merName) { | ||
67 | + this.merName = merName; | ||
68 | + } | ||
69 | + | ||
70 | + public Long getRoleId() { | ||
71 | + return roleId; | ||
72 | + } | ||
73 | + | ||
74 | + public void setRoleId(Long roleId) { | ||
75 | + this.roleId = roleId; | ||
76 | + } | ||
77 | + | ||
78 | + public Long getMerAccountId() { | ||
79 | + return merAccountId; | ||
80 | + } | ||
81 | + | ||
82 | + public void setMerAccountId(Long merAccountId) { | ||
83 | + this.merAccountId = merAccountId; | ||
84 | + } | ||
85 | + | ||
86 | + public Long getMerFundAccountId() { | ||
87 | + return merFundAccountId; | ||
88 | + } | ||
89 | + | ||
90 | + public void setMerFundAccountId(Long merFundAccountId) { | ||
91 | + this.merFundAccountId = merFundAccountId; | ||
92 | + } | ||
93 | + | ||
94 | + public boolean isAdmin() { | ||
95 | + return admin; | ||
96 | + } | ||
97 | + | ||
98 | + public void setAdmin(boolean admin) { | ||
99 | + this.admin = admin; | ||
100 | + } | ||
101 | +} |
src/main/java/com/diligrp/xtrade/product/exception/ProductException.java
1 | package com.diligrp.xtrade.product.exception; | 1 | package com.diligrp.xtrade.product.exception; |
2 | 2 | ||
3 | -public class ProductException { | 3 | +import com.diligrp.xtrade.shared.exception.BaseBusinessException; |
4 | +import com.diligrp.xtrade.shared.type.IEnumType; | ||
4 | 5 | ||
6 | +public class ProductException extends BaseBusinessException { | ||
7 | + | ||
8 | + public ProductException(IEnumType type) { | ||
9 | + super(type); | ||
10 | + } | ||
5 | } | 11 | } |
src/main/java/com/diligrp/xtrade/product/repository/AccountRepository.java
0 → 100644
1 | +package com.diligrp.xtrade.product.repository; | ||
2 | + | ||
3 | +import com.diligrp.xtrade.product.domain.entity.Account; | ||
4 | +import com.diligrp.xtrade.product.domain.entity.Operator; | ||
5 | +import org.springframework.stereotype.Repository; | ||
6 | + | ||
7 | +import java.util.ArrayList; | ||
8 | +import java.util.List; | ||
9 | + | ||
10 | +/** | ||
11 | + * @Auther: miaoguoxin | ||
12 | + * @Date: 2020/4/21 17:17 | ||
13 | + * @Description: | ||
14 | + */ | ||
15 | +@Repository | ||
16 | +public class AccountRepository implements IAccountRepository { | ||
17 | + private final static List<Account> ACCOUNTS = new ArrayList<>(); | ||
18 | + @Override | ||
19 | + public Operator getOperator() { | ||
20 | + return new Operator(); | ||
21 | + } | ||
22 | + | ||
23 | + @Override | ||
24 | + public Account getAccountByName(String userName) { | ||
25 | + Account account = new Account(); | ||
26 | + account.setName(userName); | ||
27 | + return null; | ||
28 | + } | ||
29 | + | ||
30 | + @Override | ||
31 | + public void add(Account account) { | ||
32 | + ACCOUNTS.add(account); | ||
33 | + } | ||
34 | +} |
src/main/java/com/diligrp/xtrade/product/repository/IAccountRepository.java
0 → 100644
1 | +package com.diligrp.xtrade.product.repository; | ||
2 | + | ||
3 | +import com.diligrp.xtrade.product.domain.entity.Account; | ||
4 | +import com.diligrp.xtrade.product.domain.entity.Operator; | ||
5 | + | ||
6 | +/** | ||
7 | + * @Auther: miaoguoxin | ||
8 | + * @Date: 2020/4/21 17:14 | ||
9 | + * @Description: 账户相关仓储接口 | ||
10 | + */ | ||
11 | +public interface IAccountRepository { | ||
12 | + | ||
13 | + Operator getOperator(); | ||
14 | + | ||
15 | + Account getAccountByName(String userName); | ||
16 | + | ||
17 | + void add(Account account); | ||
18 | +} |
src/main/java/com/diligrp/xtrade/product/repository/IMerchantRepository.java
0 → 100644
1 | +package com.diligrp.xtrade.product.repository; | ||
2 | + | ||
3 | +import com.diligrp.xtrade.product.domain.entity.Merchant; | ||
4 | + | ||
5 | +/** | ||
6 | + * @Auther: miaoguoxin | ||
7 | + * @Date: 2020/4/22 08:59 | ||
8 | + * @Description: merchant仓储接口 | ||
9 | + */ | ||
10 | +public interface IMerchantRepository { | ||
11 | + | ||
12 | + Merchant getByAccountId(Long accountId); | ||
13 | + | ||
14 | + void add(Merchant merchant); | ||
15 | + | ||
16 | + void update(Merchant merchant); | ||
17 | +} |
src/main/java/com/diligrp/xtrade/product/repository/MerchantRepository.java
0 → 100644
1 | +package com.diligrp.xtrade.product.repository; | ||
2 | + | ||
3 | +import com.diligrp.xtrade.product.dao.MerchantDao; | ||
4 | +import com.diligrp.xtrade.product.dao.ShopDao; | ||
5 | +import com.diligrp.xtrade.product.domain.emuns.AccountType; | ||
6 | +import com.diligrp.xtrade.product.domain.emuns.IKeyGeneratorKeys; | ||
7 | +import com.diligrp.xtrade.product.domain.entity.Merchant; | ||
8 | +import com.diligrp.xtrade.product.domain.entity.ShopDo; | ||
9 | +import com.diligrp.xtrade.shared.sequence.IKeyGenerator; | ||
10 | +import com.diligrp.xtrade.shared.sequence.KeyGeneratorManager; | ||
11 | +import org.springframework.beans.factory.annotation.Autowired; | ||
12 | +import org.springframework.stereotype.Repository; | ||
13 | + | ||
14 | +import java.time.LocalDateTime; | ||
15 | +import java.util.List; | ||
16 | + | ||
17 | +/** | ||
18 | + * @Auther: miaoguoxin | ||
19 | + * @Date: 2020/4/22 09:01 | ||
20 | + */ | ||
21 | +@Repository | ||
22 | +public class MerchantRepository implements IMerchantRepository { | ||
23 | + @Autowired | ||
24 | + private MerchantDao merchantDao; | ||
25 | + @Autowired | ||
26 | + private ShopDao shopDao; | ||
27 | + @Autowired | ||
28 | + private KeyGeneratorManager keyGeneratorManager; | ||
29 | + | ||
30 | + @Override | ||
31 | + public Merchant getByAccountId(Long accountId) { | ||
32 | + Merchant merchant = new Merchant(); | ||
33 | + merchant.setAccountId(accountId); | ||
34 | + List<Merchant> merchants = merchantDao.findByCondition(merchant); | ||
35 | + if (merchants.isEmpty()){ | ||
36 | + return null; | ||
37 | + } | ||
38 | + return merchants.get(0); | ||
39 | + } | ||
40 | + | ||
41 | + @Override | ||
42 | + public void add(Merchant newMerchant) { | ||
43 | + IKeyGenerator keyGenerator = keyGeneratorManager.getKeyGenerator(IKeyGeneratorKeys.MERCHANT_SEQUENCE); | ||
44 | + newMerchant.setMerId(keyGenerator.nextId()); | ||
45 | + newMerchant.setMarketId("SY001"); | ||
46 | + newMerchant.setCreatedTime(LocalDateTime.now()); | ||
47 | + merchantDao.insert(newMerchant); | ||
48 | + } | ||
49 | + | ||
50 | + @Override | ||
51 | + public void update(Merchant merchant) { | ||
52 | + merchant.setModifiedTime(LocalDateTime.now()); | ||
53 | + ShopDo shopDo = new ShopDo(); | ||
54 | + shopDo.setType(AccountType.PUBLIC.getCode()); | ||
55 | + shopDo.setMerId(merchant.getMerId()); | ||
56 | + shopDao.update(shopDo); | ||
57 | + } | ||
58 | +} |
src/main/java/com/diligrp/xtrade/product/rpc/feign/CardService.java renamed to src/main/java/com/diligrp/xtrade/product/rpc/feign/CardRpc.java
src/main/java/com/diligrp/xtrade/product/service/AccountService.java
0 → 100644
1 | +package com.diligrp.xtrade.product.service; | ||
2 | + | ||
3 | +import com.diligrp.xtrade.product.domain.dto.MerchantRequestDto; | ||
4 | +import com.diligrp.xtrade.product.domain.entity.Account; | ||
5 | +import com.diligrp.xtrade.product.domain.entity.Merchant; | ||
6 | + | ||
7 | +/** | ||
8 | + * @Auther: miaoguoxin | ||
9 | + * @Date: 2020/4/22 11:08 | ||
10 | + */ | ||
11 | +public interface AccountService { | ||
12 | + | ||
13 | + Account build(MerchantRequestDto requestDto, Merchant merchant) throws Exception; | ||
14 | + | ||
15 | + void create(MerchantRequestDto requestDto, Merchant merchant) throws Exception; | ||
16 | +} |
src/main/java/com/diligrp/xtrade/product/service/MerchantService.java
1 | package com.diligrp.xtrade.product.service; | 1 | package com.diligrp.xtrade.product.service; |
2 | 2 | ||
3 | +import com.diligrp.xtrade.product.domain.dto.MerchantRequestDto; | ||
4 | +import com.diligrp.xtrade.product.domain.dto.MerchantResponseDto; | ||
5 | + | ||
3 | public interface MerchantService { | 6 | public interface MerchantService { |
4 | 7 | ||
8 | + MerchantResponseDto create(MerchantRequestDto requestDto) throws Exception; | ||
9 | + | ||
5 | } | 10 | } |
src/main/java/com/diligrp/xtrade/product/service/impl/AccountServiceImpl.java
0 → 100644
1 | +package com.diligrp.xtrade.product.service.impl; | ||
2 | + | ||
3 | +import com.diligrp.xtrade.product.domain.dto.MerchantRequestDto; | ||
4 | +import com.diligrp.xtrade.product.domain.emuns.AccountStatus; | ||
5 | +import com.diligrp.xtrade.product.domain.emuns.IKeyGeneratorKeys; | ||
6 | +import com.diligrp.xtrade.product.domain.entity.Account; | ||
7 | +import com.diligrp.xtrade.product.domain.entity.Merchant; | ||
8 | +import com.diligrp.xtrade.product.repository.IAccountRepository; | ||
9 | +import com.diligrp.xtrade.product.service.AccountService; | ||
10 | +import com.diligrp.xtrade.shared.security.PasswordUtils; | ||
11 | +import com.diligrp.xtrade.shared.sequence.IKeyGenerator; | ||
12 | +import com.diligrp.xtrade.shared.sequence.KeyGeneratorManager; | ||
13 | +import org.springframework.beans.factory.annotation.Autowired; | ||
14 | +import org.springframework.stereotype.Service; | ||
15 | + | ||
16 | +import java.time.LocalDateTime; | ||
17 | + | ||
18 | +/** | ||
19 | + * @Auther: miaoguoxin | ||
20 | + * @Date: 2020/4/22 11:10 | ||
21 | + */ | ||
22 | +@Service | ||
23 | +public class AccountServiceImpl implements AccountService { | ||
24 | + @Autowired | ||
25 | + private IAccountRepository accountRepository; | ||
26 | + @Autowired | ||
27 | + private KeyGeneratorManager keyGeneratorManager; | ||
28 | + | ||
29 | + @Override | ||
30 | + public Account build(MerchantRequestDto requestDto, Merchant merchant) throws Exception { | ||
31 | + Account newAccount = new Account(); | ||
32 | + newAccount.setName(requestDto.getUserName()); | ||
33 | + newAccount.setRealName(requestDto.getRealName()); | ||
34 | + newAccount.setPassword(PasswordUtils.encrypt(requestDto.getPassword(), | ||
35 | + requestDto.getUserName())); | ||
36 | + newAccount.setMobile(requestDto.getMobile()); | ||
37 | + newAccount.setStatus(AccountStatus.NORMAL.getCode()); | ||
38 | + newAccount.setIsAdmin(1); | ||
39 | + newAccount.setMerId(merchant.getMerId()); | ||
40 | + newAccount.setCreatedTime(LocalDateTime.now()); | ||
41 | + IKeyGenerator keyGenerator = keyGeneratorManager.getKeyGenerator(IKeyGeneratorKeys.ACCOUNT_SEQUENCE); | ||
42 | + newAccount.setId(keyGenerator.nextId()); | ||
43 | + return newAccount; | ||
44 | + } | ||
45 | + | ||
46 | + @Override | ||
47 | + public void create(MerchantRequestDto requestDto, Merchant merchant) throws Exception { | ||
48 | + Account newAccount = this.build(requestDto, merchant); | ||
49 | + accountRepository.add(newAccount); | ||
50 | + } | ||
51 | +} |
src/main/java/com/diligrp/xtrade/product/service/impl/MerchantServiceImpl.java
1 | package com.diligrp.xtrade.product.service.impl; | 1 | package com.diligrp.xtrade.product.service.impl; |
2 | 2 | ||
3 | +import com.diligrp.xtrade.product.domain.converter.MerchantConverter; | ||
4 | +import com.diligrp.xtrade.product.domain.dto.MerchantRequestDto; | ||
5 | +import com.diligrp.xtrade.product.domain.dto.MerchantResponseDto; | ||
6 | +import com.diligrp.xtrade.product.domain.emuns.AccountType; | ||
7 | +import com.diligrp.xtrade.product.domain.emuns.ResponseCode; | ||
8 | +import com.diligrp.xtrade.product.domain.entity.Account; | ||
9 | +import com.diligrp.xtrade.product.domain.entity.Merchant; | ||
10 | +import com.diligrp.xtrade.product.domain.entity.Operator; | ||
11 | +import com.diligrp.xtrade.product.exception.ProductException; | ||
12 | +import com.diligrp.xtrade.product.repository.IAccountRepository; | ||
13 | +import com.diligrp.xtrade.product.repository.IMerchantRepository; | ||
14 | +import com.diligrp.xtrade.product.service.AccountService; | ||
3 | import com.diligrp.xtrade.product.service.MerchantService; | 15 | import com.diligrp.xtrade.product.service.MerchantService; |
16 | +import org.springframework.beans.factory.annotation.Autowired; | ||
17 | +import org.springframework.stereotype.Service; | ||
18 | +import org.springframework.transaction.annotation.Transactional; | ||
4 | 19 | ||
20 | +@Service | ||
5 | public class MerchantServiceImpl implements MerchantService { | 21 | public class MerchantServiceImpl implements MerchantService { |
22 | + @Autowired | ||
23 | + private IAccountRepository accountRepository; | ||
24 | + @Autowired | ||
25 | + private IMerchantRepository merchantRepository; | ||
26 | + @Autowired | ||
27 | + private MerchantConverter merchantConverter; | ||
28 | + @Autowired | ||
29 | + private AccountService accountService; | ||
30 | + | ||
31 | + @Override | ||
32 | + @Transactional | ||
33 | + public MerchantResponseDto create(MerchantRequestDto requestDto) throws Exception { | ||
34 | + Operator operator = accountRepository.getOperator(); | ||
35 | + requestDto.setAccountId(operator.getAccountId()); | ||
36 | + requestDto.setRealName(operator.getName()); | ||
37 | + Account account = accountRepository.getAccountByName(requestDto.getUserName()); | ||
38 | + if (account != null) { | ||
39 | + throw new ProductException(ResponseCode.ACCOUNT_EXIST); | ||
40 | + } | ||
41 | + Merchant merchant = merchantRepository.getByAccountId(requestDto.getAccountId()); | ||
42 | + if (merchant == null){ | ||
43 | + merchant = merchantConverter.request2Entity(requestDto); | ||
44 | + merchantRepository.add(merchant); | ||
45 | + } else { | ||
46 | + if (AccountType.PERSONAL.getCode() != merchant.getType()){ | ||
47 | + throw new ProductException(ResponseCode.CARD_MERCHANT_CREATED); | ||
48 | + } | ||
49 | + merchantRepository.update(merchant); | ||
50 | + } | ||
51 | + //创建市场管理员账户 | ||
52 | + accountService.create(requestDto,merchant); | ||
53 | + return merchantConverter.entity2Response(merchant); | ||
54 | + } | ||
6 | 55 | ||
7 | } | 56 | } |
src/main/resources/mapping/com/diligrp/xtrade/product/MerchantDao.xml
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
3 | <mapper namespace="com.diligrp.xtrade.product.dao.MerchantDao"> | 3 | <mapper namespace="com.diligrp.xtrade.product.dao.MerchantDao"> |
4 | - | ||
5 | - | ||
6 | - | ||
7 | -</mapper> | ||
8 | \ No newline at end of file | 4 | \ No newline at end of file |
5 | + | ||
6 | + <resultMap type="com.diligrp.xtrade.product.domain.entity.Merchant" id="XtMerchantMap"> | ||
7 | + <result property="id" column="id"/> | ||
8 | + <result property="merId" column="mer_id"/> | ||
9 | + <result property="merName" column="mer_name"/> | ||
10 | + <result property="marketId" column="market_id"/> | ||
11 | + <result property="accountId" column="account_id"/> | ||
12 | + <result property="accountName" column="account_name"/> | ||
13 | + <result property="type" column="type"/> | ||
14 | + <result property="status" column="status"/> | ||
15 | + <result property="description" column="description"/> | ||
16 | + <result property="createdTime" column="created_time"/> | ||
17 | + <result property="modifiedTime" column="modified_time"/> | ||
18 | + </resultMap> | ||
19 | + <sql id="Base_Column"> | ||
20 | + id, | ||
21 | + mer_id, | ||
22 | + mer_name, | ||
23 | + market_id, | ||
24 | + account_id, | ||
25 | + account_name, | ||
26 | + type, | ||
27 | + `status`, | ||
28 | + `description`, | ||
29 | + created_time, | ||
30 | + modified_time | ||
31 | + </sql> | ||
32 | + <sql id="Base_Condition_Column"> | ||
33 | + <if test="merId != null"> | ||
34 | + mer_id = #{merId}, | ||
35 | + </if> | ||
36 | + <if test="merName != null and merName != ''"> | ||
37 | + mer_name = #{merName}, | ||
38 | + </if> | ||
39 | + <if test="marketId != null and marketId != ''"> | ||
40 | + market_id = #{marketId}, | ||
41 | + </if> | ||
42 | + <if test="accountId != null"> | ||
43 | + account_id = #{accountId}, | ||
44 | + </if> | ||
45 | + <if test="accountName != null and accountName != ''"> | ||
46 | + account_name = #{accountName}, | ||
47 | + </if> | ||
48 | + <if test="type != null"> | ||
49 | + type = #{type}, | ||
50 | + </if> | ||
51 | + <if test="status != null"> | ||
52 | + `status` = #{status}, | ||
53 | + </if> | ||
54 | + <if test="description != null and description != ''"> | ||
55 | + `description` = #{description}, | ||
56 | + </if> | ||
57 | + <if test="createdTime != null"> | ||
58 | + created_time = #{createdTime}, | ||
59 | + </if> | ||
60 | + <if test="modifiedTime != null"> | ||
61 | + modified_time = #{modifiedTime}, | ||
62 | + </if> | ||
63 | + </sql> | ||
64 | + | ||
65 | + <!--查询单个--> | ||
66 | + <select id="findById" resultMap="XtMerchantMap"> | ||
67 | + select | ||
68 | + <include refid="Base_Column"/> | ||
69 | + from xt_merchant | ||
70 | + where id = #{id} | ||
71 | + </select> | ||
72 | + | ||
73 | + <!--查询指定行数据--> | ||
74 | + <select id="findPage" resultMap="XtMerchantMap"> | ||
75 | + select | ||
76 | + <include refid="Base_Column"/> | ||
77 | + from xt_merchant | ||
78 | + limit #{offset}, #{limit} | ||
79 | + </select> | ||
80 | + | ||
81 | + <select id="findByCondition" parameterType="com.diligrp.xtrade.product.domain.entity.Merchant" resultMap="XtMerchantMap"> | ||
82 | + SELECT | ||
83 | + <include refid="Base_Column"/> | ||
84 | + from xt_merchant | ||
85 | + <where> | ||
86 | + <include refid="Base_Condition_Column"/> | ||
87 | + </where> | ||
88 | + </select> | ||
89 | + | ||
90 | + <!--新增所有列--> | ||
91 | + <insert id="insert" keyProperty="id" useGeneratedKeys="true"> | ||
92 | + insert into xt_merchant(mer_id, mer_name, market_id, account_id, account_name, type, status, description, | ||
93 | + created_time, modified_time) | ||
94 | + values (#{merId}, #{merName}, #{marketId}, #{accountId}, #{accountName}, #{type}, #{status}, #{description}, | ||
95 | + #{createdTime}, #{modifiedTime}) | ||
96 | + </insert> | ||
97 | + | ||
98 | + <!--通过主键修改数据--> | ||
99 | + <update id="update"> | ||
100 | + update xt_merchant | ||
101 | + <set> | ||
102 | + <include refid="Base_Condition_Column"/> | ||
103 | + </set> | ||
104 | + where id = #{id} | ||
105 | + </update> | ||
106 | + | ||
107 | + <!--通过主键删除--> | ||
108 | + <delete id="deleteById"> | ||
109 | + delete | ||
110 | + from xt_merchant | ||
111 | + where id = #{id} | ||
112 | + </delete> | ||
113 | + | ||
114 | +</mapper> |