DepartmentService.java
3.55 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
package cn.com.glsx.entmicro.service;
import cn.com.glsx.entmicro.convert.ConvertRequest;
import cn.com.glsx.entmicro.convert.ConvertResponse;
import cn.com.glsx.entmicro.model.request.EntmicroDepartmentRequest;
import cn.com.glsx.entmicro.model.response.DepartmentTreeResponse;
import cn.com.glsx.entmicro.model.response.EntmicroDepartmentResponse;
import cn.com.glsx.entmicro.remote.EntmicroDepartmentRemote;
import cn.com.glsx.entmicro.request.department.DepartmentListRequest;
import cn.com.glsx.entmicro.request.department.DepartmentPageRequest;
import cn.com.glsx.entmicro.request.department.DepartmentTreeRequest;
import cn.com.glsx.entmicro.request.department.MerchantRequest;
import cn.com.glsx.entmicro.utils.Pagination;
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 lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author Lichongyuan
* @Description: 组织Service
* @date 2021/9/28 11:54
*/
@Service
@Slf4j
public class DepartmentService {
@Autowired
private EntmicroDepartmentRemote entmicroDepartmentRemote;
/**
* 查询组织树
*/
public List<DepartmentTreeResponse> listDepartmentTree(DepartmentTreeRequest departmentTreeRequest) {
//入参转化
EntmicroDepartmentRequest entmicroDepartmentRequest = ConvertRequest.convertRequest(departmentTreeRequest, new EntmicroDepartmentRequest());
RpcResponse<List<DepartmentTreeResponse>> response = entmicroDepartmentRemote.findDepartmentTreeRemote(entmicroDepartmentRequest);
if (response.isSuccess()) {
List<DepartmentTreeResponse> result = response.getResult();
return result;
}
return null;
}
public Integer authorizeMerchant(MerchantRequest merchantRequest) {
RpcResponse<Integer> supMerchantNo = entmicroDepartmentRemote.findSupMerchantNo(merchantRequest.getMerchantId());
if (supMerchantNo.isSuccess()) {
return supMerchantNo.getResult();
}
throw new RpcServiceException(supMerchantNo.getException().getErrId(), supMerchantNo.getMessage());
}
public List<EntmicroDepartmentResponse> listDepartmentBySupId(DepartmentListRequest departmentRequest) {
EntmicroDepartmentRequest entmicroDepartmentRequest = ConvertRequest.convertRequest(departmentRequest, new EntmicroDepartmentRequest());
RpcResponse<List<EntmicroDepartmentResponse>> response = entmicroDepartmentRemote.listDepartmentBySupId(entmicroDepartmentRequest);
if (response.isSuccess()) {
List<EntmicroDepartmentResponse> result = response.getResult();
return result;
}
return null;
}
public Pagination<EntmicroDepartmentResponse> findDepartmentListByPage(DepartmentPageRequest departmentPageRequest) {
EntmicroDepartmentRequest entmicroDepartmentRequest = ConvertRequest.convertRequest(departmentPageRequest, new EntmicroDepartmentRequest());
RpcResponse<RpcPagination<EntmicroDepartmentResponse>> response = entmicroDepartmentRemote.findDepartmentListByPage(ConvertRequest.convertPage(departmentPageRequest,entmicroDepartmentRequest));
if (response.isSuccess()) {
return ConvertResponse.convertPage(response.getResult(), EntmicroDepartmentResponse.class);
}
throw new RpcServiceException(response.getException().getErrId(), response.getMessage());
}
}