MerchantDictDataService.java
3.69 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
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.MerchantDictDataRequest;
import cn.com.glsx.merchants.model.response.MerchantDictDataResponse;
import cn.com.glsx.merchants.remote.MerchantDictDataRemote;
import cn.com.glsx.merchants.request.dictdata.*;
import cn.com.glsx.merchants.response.DictDataResponse;
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: TODO
* @date 2021/7/13 11:02
*/
@Service
@Slf4j
public class MerchantDictDataService {
@Autowired
private MerchantDictDataRemote merchantDictDataRemote;
@Autowired
private MerchantUserService merchantUserService;
public void saveDictData(DictDataSaveRequest dictDataSaveRequest) {
RpcResponse<Boolean> booleanRpcResponse = merchantDictDataRemote.saveMerchantDictDataRemote(ConvertRequest.converRequest(dictDataSaveRequest, new MerchantDictDataRequest()));
if (booleanRpcResponse.isFailed()) {
throw new RpcServiceException(booleanRpcResponse.getException().getErrId(), booleanRpcResponse.getMessage());
}
}
public void updateDictData(DictDataUpdateRequest DictDataUpdateRequest) {
RpcResponse<Boolean> booleanRpcResponse = merchantDictDataRemote.updateMerchantDictDataRemote(ConvertRequest.converRequest(DictDataUpdateRequest, new MerchantDictDataRequest()));
if (booleanRpcResponse.isFailed()) {
throw new RpcServiceException(booleanRpcResponse.getException().getErrId(), booleanRpcResponse.getMessage());
}
}
public Pagination<DictDataResponse> findDictData(DictDataListSearchRequest DictDataListSearchRequest) {
RpcResponse<RpcPagination<MerchantDictDataResponse>> merProductByPageRemote = merchantDictDataRemote.findMerchantDictDataRemote(ConvertRequest.convertPage(DictDataListSearchRequest, new MerchantDictDataRequest()));
if (merProductByPageRemote.isSuccess()) {
return ConvertResponse.convertPage(merProductByPageRemote.getResult(), DictDataResponse.class);
}
throw new RpcServiceException(merProductByPageRemote.getException().getErrId(), merProductByPageRemote.getMessage());
}
public void deleteDictData(DictDataDeleteRequest DictDataDeleteRequest) {
RpcResponse<Boolean> booleanRpcResponse = merchantDictDataRemote.deleteMerchantDictDataRemote(ConvertRequest.converRequest(DictDataDeleteRequest, new MerchantDictDataRequest()));
if (booleanRpcResponse.isFailed()) {
throw new RpcServiceException(booleanRpcResponse.getException().getErrId(), booleanRpcResponse.getMessage());
}
}
public List<DictDataResponse> findAllDictData(DictDataSearchRequest dictDataSearchRequest) {
RpcResponse<List<MerchantDictDataResponse>> merProductByPageRemote = merchantDictDataRemote.findAllRemote(ConvertRequest.converRequest(dictDataSearchRequest, new MerchantDictDataRequest()));
if (merProductByPageRemote.isSuccess()) {
return ConvertResponse.convertList(merProductByPageRemote.getResult(), DictDataResponse.class);
}
throw new RpcServiceException(merProductByPageRemote.getException().getErrId(), merProductByPageRemote.getMessage());
}
}