MerchantRemoteImpl.java
2.26 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
package cn.com.glsx.entmicro.remote;
import cn.com.glsx.entmicro.model.MerchantRopResponse;
import cn.com.glsx.entmicro.model.response.DictDataResponse;
import cn.com.glsx.entmicro.model.response.MerchantResponse;
import cn.com.glsx.entmicro.service.MerchantService;
import cn.com.glsx.entmicro.util.AppIdUtil;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import com.alibaba.dubbo.config.annotation.Service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
@Slf4j
@Component
@Service(version = "1.0.0", protocol = "dubbo", timeout = 10000)
public class MerchantRemoteImpl implements MerchantRemote {
@Autowired
private MerchantService merchantService;
@Autowired
private AppIdUtil appIdUtil;
@Override
public RpcResponse<List<DictDataResponse>> findAllByDictType(String dictType) {
List<DictDataResponse> allByDictType = merchantService.findAllByDictType(dictType);
return RpcResponse.success(allByDictType);
}
@Override
public RpcResponse<MerchantResponse> findMerchantByMerchantNo(Integer merchantno) {
MerchantResponse merchantResponse = new MerchantResponse();
MerchantRopResponse merchantByMerchantNo = merchantService.findMerchantByMerchantNo(merchantno);
if (merchantByMerchantNo != null) {
BeanUtils.copyProperties(merchantByMerchantNo, merchantResponse);
}
return RpcResponse.success(merchantResponse);
}
/**
* 根据merchantId查询配置文件中非默认的appId
*
* @param merchantId 门店号
* @return
*/
@Override
public RpcResponse<String> findAppIdByMerchantNo(Integer merchantId) {
try {
if (merchantId == null) {
return null;
}
String appid = appIdUtil.getAppId(merchantId);
return RpcResponse.success(appid);
} catch (Exception e) {
log.info("根据merchantId查询配置文件中非默认的appId异常:",e);
return RpcResponse.error(DefaultErrorEnum.SERVICE_ERROR,e.getMessage());
}
}
}