MerchantMenuService.java
3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package cn.com.glsx.merchants.service;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.merchants.convert.ConverRequest;
import cn.com.glsx.merchants.convert.ConverResponse;
import cn.com.glsx.merchants.model.request.MerchantProductMenuRequest;
import cn.com.glsx.merchants.model.request.MerchantProductRequest;
import cn.com.glsx.merchants.model.response.MerchantProductMenuResponse;
import cn.com.glsx.merchants.model.response.MerchantProductResponse;
import cn.com.glsx.merchants.remote.MerchantProductMenuRemote;
import cn.com.glsx.merchants.request.menu.MenuListSearchRequest;
import cn.com.glsx.merchants.request.menu.MenuSaveRequest;
import cn.com.glsx.merchants.request.menu.MenuSearchRequest;
import cn.com.glsx.merchants.request.menu.MenuUpdateRequest;
import cn.com.glsx.merchants.response.MenuResponse;
import cn.com.glsx.merchants.response.ProductResponse;
import cn.com.glsx.merchants.util.Pagination;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author zhouhaibao
* @version 1.0
* @description: 商户菜单service
* @date 2021/7/12 10:33
*/
@Service
@Slf4j
public class MerchantMenuService {
@Autowired
private MerchantProductMenuRemote merchantProductMenuRemote;
public List<MenuResponse> findMerProMenuTreeRemote(MenuSearchRequest menuSearchRequest) {
RpcResponse<List<MerchantProductMenuResponse>> merProMenuTreeRemote = merchantProductMenuRemote.findMerProMenuTreeRemote(ConverRequest.converRequest(menuSearchRequest, new MerchantProductMenuRequest()));
if (merProMenuTreeRemote.isSuccess()) {
List<MenuResponse> menuResponseList = ConverResponse.convertList(merProMenuTreeRemote.getResult(), MenuResponse.class);
return menuResponseList;
}
throw new RpcServiceException(merProMenuTreeRemote.getException().getError());
}
public void saveMerchantProductMenuRemote(MenuSaveRequest menuSaveRequest) {
RpcResponse<Boolean> booleanRpcResponse = merchantProductMenuRemote.saveMerchantProductMenuRemote(ConverRequest.converRequest(menuSaveRequest, new MerchantProductMenuRequest()));
if (booleanRpcResponse.isFailed()) {
throw new RpcServiceException(booleanRpcResponse.getException().getError());
}
}
public Pagination<MenuResponse> findMerProMenuByPageRemote(MenuListSearchRequest menuListSearchRequest) {
RpcResponse<RpcPagination<MerchantProductMenuResponse>> merProductByPageRemote = merchantProductMenuRemote.findMerProMenuByPageRemote(ConverRequest.converPage(menuListSearchRequest, new MerchantProductMenuRequest()));
if (merProductByPageRemote.isSuccess()) {
return ConverResponse.converPage(merProductByPageRemote.getResult(), MenuResponse.class);
}
throw new RpcServiceException(merProductByPageRemote.getException().getError());
}
public void updateMerchantProductMenuRemote(MenuUpdateRequest menuUpdateRequest) {
RpcResponse<Boolean> booleanRpcResponse = merchantProductMenuRemote.updateMerchantProductMenuRemote(ConverRequest.converRequest(menuUpdateRequest, new MerchantProductMenuRequest()));
if (booleanRpcResponse.isFailed()) {
throw new RpcServiceException(booleanRpcResponse.getException().getError());
}
}
}