MerchantFunctionService.java
4.1 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
package cn.com.glsx.merchants.service;/**
* @author zhouhaibao
* @date 2021/7/12
*/
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.MerchantProductFunctionRequest;
import cn.com.glsx.merchants.model.response.MerchantProductFunctionResponse;
import cn.com.glsx.merchants.remote.MerchantProductFunctionRemote;
import cn.com.glsx.merchants.request.function.FunctionDeleteRequest;
import cn.com.glsx.merchants.request.function.FunctionListSearchRequest;
import cn.com.glsx.merchants.request.function.FunctionSaveRequest;
import cn.com.glsx.merchants.request.function.FunctionUpdateRequest;
import cn.com.glsx.merchants.response.FunctionResponse;
import cn.com.glsx.merchants.util.Pagination;
import com.glsx.plat.common.annotation.SysLog;
import com.glsx.plat.common.enums.OperateType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author zhouhaibao
* @version 1.0
* @description: TODO
* @date 2021/7/12 11:40
*/
@Service
@Slf4j
public class MerchantFunctionService {
@Autowired
private MerchantProductFunctionRemote merchantProductFunctionRemote;
@SysLog(value = "保存功能", action = OperateType.ADD, module = "功能模块")
public void saveMerchantFunction(FunctionSaveRequest functionSaveRequest) {
RpcResponse<Boolean> booleanRpcResponse = merchantProductFunctionRemote.saveMerchantProductFunctionRemote(ConvertRequest.convertRequest(functionSaveRequest, new MerchantProductFunctionRequest()));
if (booleanRpcResponse.isFailed()) {
throw new RpcServiceException(booleanRpcResponse.getException().getErrId(), booleanRpcResponse.getMessage());
}
}
public static void main(String[] args) {
FunctionSaveRequest functionSaveRequest = new FunctionSaveRequest();
functionSaveRequest.setProductId(123);
MerchantProductFunctionRequest merchantProductFunctionRequest = ConvertRequest.convertRequest(functionSaveRequest, new MerchantProductFunctionRequest());
System.out.println(merchantProductFunctionRequest);
}
@SysLog(value = "修改功能", action = OperateType.EDIT, module = "功能模块")
public void updateMerchantFunction(FunctionUpdateRequest functionUpdateRequest) {
RpcResponse<Boolean> booleanRpcResponse = merchantProductFunctionRemote.updateMerchantProductFunctionRemote(ConvertRequest.convertRequest(functionUpdateRequest, new MerchantProductFunctionRequest()));
if (booleanRpcResponse.isFailed()) {
throw new RpcServiceException(booleanRpcResponse.getException().getErrId(), booleanRpcResponse.getMessage());
}
}
public Pagination<FunctionResponse> findMerchantFunction(FunctionListSearchRequest functionListSearchRequest) {
RpcResponse<RpcPagination<MerchantProductFunctionResponse>> merProductByPageRemote = merchantProductFunctionRemote.findMerProFunctionByPageRemote(ConvertRequest.convertPage(functionListSearchRequest, new MerchantProductFunctionRequest()));
if (merProductByPageRemote.isSuccess()) {
return ConvertResponse.convertPage(merProductByPageRemote.getResult(), FunctionResponse.class);
}
throw new RpcServiceException(merProductByPageRemote.getException().getErrId(), merProductByPageRemote.getMessage());
}
public void deleteMerchantFunction(FunctionDeleteRequest functionDeleteRequest) {
RpcResponse<Boolean> booleanRpcResponse = merchantProductFunctionRemote.deleteMerchantProductFunctionRemote(ConvertRequest.convertRequest(functionDeleteRequest, new MerchantProductFunctionRequest()));
if (booleanRpcResponse.isFailed()) {
throw new RpcServiceException(booleanRpcResponse.getException().getErrId(), booleanRpcResponse.getMessage());
}
}
}