OpenService.java
6.93 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
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.ConvertRequest;
import cn.com.glsx.merchants.convert.ConvertResponse;
import cn.com.glsx.merchants.model.request.MerchantFileRequest;
import cn.com.glsx.merchants.model.request.MerchantOpenRequest;
import cn.com.glsx.merchants.model.request.MerchantRequest;
import cn.com.glsx.merchants.model.request.MerchantUserRequest;
import cn.com.glsx.merchants.model.response.AccountTypeTreeResponse;
import cn.com.glsx.merchants.model.response.MerchantResponse;
import cn.com.glsx.merchants.model.response.MerchantUserResponse;
import cn.com.glsx.merchants.remote.MerchantRemote;
import cn.com.glsx.merchants.remote.MerchantUserRemote;
import cn.com.glsx.merchants.request.merchant.MerchantSaveOpenRequest;
import cn.com.glsx.merchants.request.merchant.MerchantSaveRequest;
import cn.com.glsx.merchants.request.merchant.OpenMerchantPageRequest;
import cn.com.glsx.merchants.request.merchant.OpenMerchantRequest;
import cn.com.glsx.merchants.request.user.OpenUserRequest;
import cn.com.glsx.merchants.response.AccountTypeTreeRopResponse;
import cn.com.glsx.merchants.response.MerchantRopResponse;
import cn.com.glsx.merchants.response.OpenUserResponse;
import cn.com.glsx.merchants.util.Pagination;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author zhouhaibao
* @version 1.0
* @description: TODO
* @date 2021/9/17 9:52
*/
@Service
public class OpenService {
@Autowired
private MerchantRemote merchantRemote;
@Autowired
private MerchantUserRemote merchantUserRemote;
public MerchantRopResponse findMerchantDetailByMerchantNo(OpenMerchantRequest openMerchantRequest) {
RpcResponse<MerchantResponse> merchantDetailByMerchantNoRemote = merchantRemote.findMerchantDetailByMerchantNoRemote(openMerchantRequest.getMerchantId());
if (merchantDetailByMerchantNoRemote.isSuccess()) {
return ConvertResponse.convertObject(merchantDetailByMerchantNoRemote.getResult(), MerchantRopResponse.class);
}
throw new RpcServiceException(merchantDetailByMerchantNoRemote.getException().getErrId(), merchantDetailByMerchantNoRemote.getMessage());
}
public Integer findSuperlativeMerchant(OpenMerchantRequest openMerchantRequest) {
RpcResponse<Integer> superlativeMerchantRemote = merchantRemote.findSuperlativeMerchantRemote(ConvertRequest.convertRequest(openMerchantRequest, new MerchantOpenRequest()));
if (superlativeMerchantRemote.isSuccess()) {
return superlativeMerchantRemote.getResult();
}
throw new RpcServiceException(superlativeMerchantRemote.getException().getErrId(), superlativeMerchantRemote.getMessage());
}
public List<MerchantRopResponse> findSuperiorList(OpenMerchantRequest openMerchantRequest) {
RpcResponse<List<MerchantResponse>> merchantListRemote = merchantRemote.findSuperiorListRemote(ConvertRequest.convertRequest(openMerchantRequest, new MerchantOpenRequest()));
if (merchantListRemote.isSuccess()) {
return ConvertResponse.convertList(merchantListRemote.getResult(), MerchantRopResponse.class);
}
throw new RpcServiceException(merchantListRemote.getException().getErrId(), merchantListRemote.getMessage());
}
public List<MerchantRopResponse> findMerchantList(OpenMerchantRequest openMerchantRequest) {
RpcResponse<List<MerchantResponse>> merchantListRemote = merchantRemote.findMerchantListRemote(ConvertRequest.convertRequest(openMerchantRequest, new MerchantOpenRequest()));
if (merchantListRemote.isSuccess()) {
return ConvertResponse.convertList(merchantListRemote.getResult(), MerchantRopResponse.class);
}
throw new RpcServiceException(merchantListRemote.getException().getErrId(), merchantListRemote.getMessage());
}
public Pagination<MerchantRopResponse> findSubordinateListByPage(OpenMerchantPageRequest openMerchantRequest) {
RpcResponse<RpcPagination<MerchantResponse>> subordinateListByPageRemote = merchantRemote.findSubordinateListByPageRemote(ConvertRequest.convertPage(openMerchantRequest, new MerchantOpenRequest()));
if (subordinateListByPageRemote.isSuccess()) {
return ConvertResponse.convertPage(subordinateListByPageRemote.getResult(), MerchantRopResponse.class);
}
throw new RpcServiceException(subordinateListByPageRemote.getException().getErrId(), subordinateListByPageRemote.getMessage());
}
public OpenUserResponse checkBussinessAccount(OpenUserRequest openUserRequest) {
RpcResponse<MerchantUserResponse> merchantUserResponseRpcResponse = merchantUserRemote.checkBussinessAccount(ConvertRequest.convertRequest(openUserRequest, new MerchantUserRequest()));
if (merchantUserResponseRpcResponse.isSuccess()) {
return ConvertResponse.convertObject(merchantUserResponseRpcResponse.getResult(), OpenUserResponse.class);
}
throw new RpcServiceException(merchantUserResponseRpcResponse.getException().getErrId(), merchantUserResponseRpcResponse.getMessage());
}
public List<Integer> findDataPermission(OpenUserRequest openUserRequest) {
RpcResponse<List<Integer>> dataPermission = merchantUserRemote.findDataPermission(ConvertRequest.convertRequest(openUserRequest, new MerchantUserRequest()));
if (dataPermission.isSuccess()) {
return dataPermission.getResult();
}
throw new RpcServiceException(dataPermission.getException().getErrId(), dataPermission.getMessage());
}
public List<AccountTypeTreeRopResponse> findMenuFunPermission(OpenUserRequest openUserRequest) {
RpcResponse<List<AccountTypeTreeResponse>> menuFunPermission = merchantUserRemote.findMenuFunPermission(ConvertRequest.convertRequest(openUserRequest, new MerchantUserRequest()));
if (menuFunPermission.isSuccess()) {
return ConvertResponse.convertList(menuFunPermission.getResult(), AccountTypeTreeRopResponse.class);
}
throw new RpcServiceException(menuFunPermission.getException().getErrId(), menuFunPermission.getMessage());
}
public Integer saveMerchant(MerchantSaveOpenRequest merchantSaveRequest) {
RpcResponse<Integer> booleanRpcResponse = merchantRemote.saveMerchantRemote(ConvertRequest.convertRequest(merchantSaveRequest, new MerchantRequest()));
if (booleanRpcResponse.isSuccess()) {
return booleanRpcResponse.getResult();
}
throw new RpcServiceException(booleanRpcResponse.getException().getErrId(), booleanRpcResponse.getMessage());
}
}