forked from gzzfw/backEnd/gz-dyh

wangwh
2024-08-28 b47d4a7accabce974e19d2a1ffb3c5c67507d74b
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
package cn.huge.module.client.api.impl;
 
import cn.huge.base.common.bo.ReturnBO;
import cn.huge.base.common.constant.ReturnConsts;
import cn.huge.base.common.dto.SelectTermDTO;
import cn.huge.base.common.exception.ClientException;
import cn.huge.base.common.exception.ServiceException;
import cn.huge.module.client.api.CustClient;
import cn.huge.module.cust.dto.CtUserDTO;
import cn.huge.module.cust.dto.PaUserDTO;
import cn.huge.module.sync.domain.target.TargetCtAccount;
import cn.huge.module.sync.domain.target.TargetCtUnit;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestParam;
 
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
 
/**
 * @title: 客户用户中心微服务调用接口实现
 * @description: 客户用户中心微服务调用接口实现
 * @company: hugeinfo
 * @author: liyj
 * @time: 2021-11-05 16:51:48
 * @version: 1.0.0
 */
@Slf4j
@Component
public class CustClientImpl {
 
    private CustClient custClient;
 
    @Autowired
    public CustClientImpl(CustClient custClient) {
        this.custClient = custClient;
    }
 
    /**
     * ObjectMapper工具类
     */
    private ObjectMapper objectMapper = new ObjectMapper();
 
    /**
     * 微服务调用-数据迁移-批量新增
     * @param targetTableList 批量数据
     * @return
     */
    public CtUserDTO saveTableList(List<TargetCtUnit> targetTableList){
        try{
            ReturnBO returnBo = custClient.saveTableList(targetTableList);
            if (ReturnConsts.OK == returnBo.getCode()){
                CtUserDTO loginUser = objectMapper.convertValue(returnBo.getData(), CtUserDTO.class);
                return loginUser;
            }else{
                log.error("Client外服务接口[CustClientImpl.saveTableList]请求异常:" + returnBo.getMsg(), returnBo.getMsg());
                throw new ClientException("CustClientImpl.saveTableList", returnBo.getMsg());
            }
        }catch (Exception e){
            log.error("service方法[CustClientImpl.saveTableList]调用异常:"+e, e);
            throw new ServiceException("CustClientImpl.saveTableList", e);
        }
    }
 
    /**
     * 微服务调用-数据迁移-批量新增
     * @param targetTableList 批量数据
     * @return
     */
    public CtUserDTO saveTableList1(List<TargetCtAccount> targetTableList){
        try{
            ReturnBO returnBo = custClient.saveTableList1(targetTableList);
            if (ReturnConsts.OK == returnBo.getCode()){
                CtUserDTO loginUser = objectMapper.convertValue(returnBo.getData(), CtUserDTO.class);
                return loginUser;
            }else{
                log.error("Client外服务接口[CustClientImpl.saveTableList1]请求异常:" + returnBo.getMsg(), returnBo.getMsg());
                throw new ClientException("CustClientImpl.saveTableList1", returnBo.getMsg());
            }
        }catch (Exception e){
            log.error("service方法[CustClientImpl.saveTableList1]调用异常:"+e, e);
            throw new ServiceException("CustClientImpl.saveTableList1", e);
        }
    }
}