SyncController.java 6.34 KB
package cn.com.glsx.entmicro.controller;

import cn.com.glsx.entmicro.request.synchronization.SyncCustomerBaseRequest;
import cn.com.glsx.entmicro.request.synchronization.SyncCustomerRequest;
import cn.com.glsx.entmicro.request.synchronization.SyncDepartmentRequest;
import cn.com.glsx.entmicro.request.synchronization.SyncStaffRequest;
import cn.com.glsx.entmicro.service.SycService;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.rop.response.RopResponse;
import com.rop.annotation.NeedInSessionType;
import com.rop.annotation.ServiceMethod;
import com.rop.annotation.ServiceMethodBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author Lichongyuan
 * @Description: 同步服务
 * @date 2021/10/19 16:00
 */
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.YES)
@Api("同步服务")
@Slf4j
public class SyncController {

    @Autowired
    private SycService sycService;

    /**
     * 同步部门
     *
     * @param syncDepartmentRequest
     * @return
     */
    @ServiceMethod(method = "entmicro.api.synchro.syncDepartment", needInSession = NeedInSessionType.YES)
    @ApiOperation("同步部门")
    public RopResponse<Boolean> syncDepartment(SyncDepartmentRequest syncDepartmentRequest) {
        try {
            sycService.sycDepartment(syncDepartmentRequest);
            return RopResponse.success(true);
        } catch (RpcServiceException e) {
            log.info("=======SyncController__invoke__syncDepartment__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 同步员工
     *
     * @param syncStaffRequest
     * @return
     */
    @ServiceMethod(method = "entmicro.api.synchro.synStaff", needInSession = NeedInSessionType.YES)
    @ApiOperation("同步员工")
    public RopResponse<Boolean> synStaff(SyncStaffRequest syncStaffRequest) {
        try {
            sycService.sycStaff(syncStaffRequest);
            return RopResponse.success(true);
        } catch (RpcServiceException e) {
            log.info("=======SyncController__invoke__synStaff__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 同步客户
     *
     * @param syncCustomerRequest
     * @return
     */
    @ServiceMethod(method = "entmicro.api.synchro.syncCustomer", needInSession = NeedInSessionType.YES)
    @ApiOperation("同步客户")
    public RopResponse<Boolean> syncCustomer(SyncCustomerRequest syncCustomerRequest) {
        try {
            sycService.sycCustomer(syncCustomerRequest);
            return RopResponse.success(true);
        } catch (RpcServiceException e) {
            log.info("=======SyncController__invoke__syncCustomer__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 同步客户群
     *
     * @param syncCustomerBaseRequest
     * @return
     */
    @ServiceMethod(method = "entmicro.api.synchro.syncCustomerBase", needInSession = NeedInSessionType.YES)
    @ApiOperation("同步客户群")
    public RopResponse<Boolean> syncCustomerBase(SyncCustomerBaseRequest syncCustomerBaseRequest) {
        try {
            sycService.sycCustomerBase(syncCustomerBaseRequest);
            return RopResponse.success(true);
        } catch (RpcServiceException e) {
            log.info("=======SyncController__invoke__syncCustomerBase__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 同步标签
     *
     * @param syncCustomerBaseRequest
     * @return
     */
    @ServiceMethod(method = "entmicro.api.synchro.syncTag", needInSession = NeedInSessionType.YES)
    @ApiOperation("同步客户群")
    public RopResponse<Boolean> syncTag(SyncCustomerBaseRequest syncCustomerBaseRequest) {
        try {
            sycService.syncTag(syncCustomerBaseRequest);
            return RopResponse.success(true);
        } catch (RpcServiceException e) {
            log.info("=======SyncController__invoke__syncCustomerBase__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 维格表同步指定门店企微客户
     *
     * @param request
     * @return
     */
    @ServiceMethod(method = "entmicro.api.synchro.syncCustomer2Vika", needInSession = NeedInSessionType.YES)
    @ApiOperation("维格表同步指定门店企微客户")
    public RopResponse<Boolean> syncCustomer2Vika(SyncDepartmentRequest request) {
        try {
            return RopResponse.success(sycService.syncCustomer2Vika(request));
        } catch (RpcServiceException e) {
            log.info("=======SyncController__invoke__syncCustomer2Vika__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 同步客户企微类型标签
     *
     * @param request
     * @return
     */
    @ServiceMethod(method = "entmicro.api.synchro.syncCustomerTypeTagHandle", needInSession = NeedInSessionType.NO)
    @ApiOperation("同步客户企微类型标签")
    public RopResponse<Boolean> syncCustomerTypeTagHandle(SyncCustomerRequest request) {
        try {
            return RopResponse.success(sycService.syncCustomerTypeTagHandle(request));
        } catch (RpcServiceException e) {
            log.info("=======SyncController__invoke__syncCustomerTypeTagHandle__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 同步客户备注数据到cdp
     *
     * @param request
     * @return
     */
    @ServiceMethod(method = "entmicro.api.synchro.syncCustomerRemarkToCdp", needInSession = NeedInSessionType.NO)
    @ApiOperation("同步客户备注数据到cdp")
    public RopResponse<Boolean> syncCustomerRemarkToCdp(SyncCustomerRequest request) {
        try {
            return RopResponse.success(sycService.syncCustomerRemarkToCdp(request));
        } catch (RpcServiceException e) {
            log.info("=======SyncController__invoke__syncCustomerRemarkToCdp__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }
}