CommonController.java 6.17 KB
package cn.com.glsx.entmicro.controller;

import cn.com.glsx.entmicro.request.common.*;
import cn.com.glsx.entmicro.request.entmicro.RelevanceRopEntmicroBaseRequest;
import cn.com.glsx.entmicro.response.common.DictDataResponse;
import cn.com.glsx.entmicro.response.common.MerchantBaseInfoRopResponse;
import cn.com.glsx.entmicro.response.common.MerchantTreeOpenResponse;
import cn.com.glsx.entmicro.service.CommonService;
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;

import java.util.List;

/**
 * @author fengzhi
 * @version 1.0
 * @description: 客户群模块接口
 * @date 2021/9/23 16:52
 */
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.YES)
@Api("公共服务接口")
@Slf4j
public class CommonController {

    @Autowired
    private CommonService commonService;


    /**
     * 字典列表
     *
     * @param dictDataRequest 搜索入参
     * @return
     */
    @ServiceMethod(method = "entmicro.api.common.dictdata.list", needInSession = NeedInSessionType.NO)
    @ApiOperation("字典列表")
    public RopResponse<List<DictDataResponse>> findAllByDictType(DictDataRequest dictDataRequest) {
        try {
            return RopResponse.success(commonService.findAllByDictType(dictDataRequest.getDictType()));
        } catch (RpcServiceException e) {
            log.info("=======CustomerBaseController__invoke__getCustomerBasePage__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 根据商户号查询商户树
     *
     * @param merchantTreeOpenRequest 搜索入参
     * @return
     */
    @ServiceMethod(method = "entmicro.api.common.findMerchantTreeByMerchantNo.list", needInSession = NeedInSessionType.YES)
    @ApiOperation("根据商户号查询商户树")
    public RopResponse<List<MerchantTreeOpenResponse>> findMerchantTreeByMerchantNo(MerchantTreeOpenRequest merchantTreeOpenRequest) {
        try {
            return RopResponse.success(commonService.findMerchantTreeByMerchantNo(merchantTreeOpenRequest));
        } catch (RpcServiceException e) {
            log.info("=======CustomerBaseController__invoke__findMerchantTreeByMerchantNo__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 商户关联企微
     *
     * @param relevanceRopEntmicroBaseRequest 搜索入参
     * @return
     */
    @ServiceMethod(method = "entmicro.api.common.relevanceEntmicro.list", needInSession = NeedInSessionType.YES)
    @ApiOperation("商户关联企微")
    public RopResponse<Boolean> relevanceEntmicro(RelevanceRopEntmicroBaseRequest relevanceRopEntmicroBaseRequest) {
        try {
            return RopResponse.success(commonService.relevanceEntmicro(relevanceRopEntmicroBaseRequest));
        } catch (RpcServiceException e) {
            log.info("=======CustomerBaseController__invoke__relevanceEntmicro__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 查询账户的登录次数
     *
     * @param loginRequest 入参
     * @return
     */
    @ServiceMethod(method = "entmicro.api.common.findLoginCount", needInSession = NeedInSessionType.YES)
    @ApiOperation("查询账户的登录次数")
    public RopResponse<Boolean> findLoginCount(LoginRequest loginRequest) {
        try {
            return RopResponse.success(commonService.findLoginCount(loginRequest));
        } catch (RpcServiceException e) {
            log.info("=======CustomerBaseController__invoke__findLoginCount__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 根据商户号查询商户信息
     *
     * @param merchantTreeOpenRequest 搜索入参
     * @return
     */
    @ServiceMethod(method = "entmicro.api.common.findMerchantInfoByMerchantNo.list", needInSession = NeedInSessionType.YES)
    @ApiOperation("根据商户号查询商户信息")
    public RopResponse<MerchantBaseInfoRopResponse> findMerchantInfoByMerchantNo(MerchantTreeOpenRequest merchantTreeOpenRequest) {
        try {
            return RopResponse.success(commonService.findMerchantInfoByMerchantNo(merchantTreeOpenRequest));
        } catch (RpcServiceException e) {
            log.info("=======CustomerBaseController__invoke__findMerchantInfoByMerchantNo__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 用户授权企微
     *
     * @param entmicroAuthorizeRequest 搜索入参
     * @return
     */
    @ServiceMethod(method = "entmicro.api.common.authorizeEntmicro.list", needInSession = NeedInSessionType.YES)
    @ApiOperation("用户授权企微")
    public RopResponse<Boolean> authorizeEntmicro(EntmicroAuthorizeRequest entmicroAuthorizeRequest) {
        try {
            return RopResponse.success(commonService.authorizeEntmicro(entmicroAuthorizeRequest));
        } catch (RpcServiceException e) {
            log.info("=======CustomerBaseController__invoke__authorizeEntmicro__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 导入excel匹配信息
     *
     * @param request 搜索入参
     * @return
     */
    @ServiceMethod(method = "entmicro.api.common.input.excel", needInSession = NeedInSessionType.YES)
    @ApiOperation("导入excel匹配手机号")
    public RopResponse<Boolean> inputExcelInfo(InputExcelRopRequest request) {
        try {
            return RopResponse.success(commonService.inputExcelInfo(request));
        } catch (RpcServiceException e) {
            log.info("=======CustomerBaseController__invoke__inputExcelInfo__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }
}