OpenController.java 8.44 KB
package cn.com.glsx.merchants.controller;

import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.rop.response.RopResponse;
import cn.com.glsx.merchants.request.merchant.MerchantSaveOpenRequest;
import cn.com.glsx.merchants.request.merchant.OpenMerchantPageRequest;
import cn.com.glsx.merchants.request.merchant.OpenMerchantRequest;
import cn.com.glsx.merchants.request.open.RelaevanceMerRequest;
import cn.com.glsx.merchants.request.user.OpenUserRequest;
import cn.com.glsx.merchants.response.AccountTypeTreeRopResponse;
import cn.com.glsx.merchants.response.MerchantRopResponse;
import cn.com.glsx.merchants.response.OpenUserResponse;
import cn.com.glsx.merchants.service.OpenService;
import cn.com.glsx.merchants.util.Pagination;
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 zhouhaibao
 * @version 1.0
 * @description: TODO
 * @date 2021/9/17 9:41
 */
@Slf4j
@Api("对外开发接口")
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.NO)
public class OpenController {
    @Autowired
    private OpenService openService;

    @ServiceMethod(method = "cn.com.glsx.merchants.open.findMerchantDetailByMerchantNo", needInSession = NeedInSessionType.NO)
    @ApiOperation("根据商户号查询商户详情")
    public RopResponse<MerchantRopResponse> findMerchantDetailByMerchantNo(OpenMerchantRequest openMerchantRequest) {
        try {
            MerchantRopResponse merchantRopResponse = openService.findMerchantDetailByMerchantNo(openMerchantRequest);
            return RopResponse.success(merchantRopResponse);
        } catch (RpcServiceException e) {
            log.info("=======OpenController__invoke__findMerchantDetailByMerchantNo__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "cn.com.glsx.merchants.open.findSuperlativeMerchant", needInSession = NeedInSessionType.NO)
    @ApiOperation("根据商户号最上级工厂商户号")
    public RopResponse<Integer> findSuperlativeMerchant(OpenMerchantRequest openMerchantRequest) {
        try {
            Integer superlativeMerchant = openService.findSuperlativeMerchant(openMerchantRequest);
            return RopResponse.success(superlativeMerchant);
        } catch (RpcServiceException e) {
            log.info("=======OpenController__invoke__findSuperlativeMerchant__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }


    @ServiceMethod(method = "cn.com.glsx.merchants.open.findSuperiorList", needInSession = NeedInSessionType.NO)
    @ApiOperation("根据商户查询商户上级列表")
    public RopResponse<List<MerchantRopResponse>> findSuperiorList(OpenMerchantRequest openMerchantRequest) {
        try {
            List<MerchantRopResponse> superiorList = openService.findSuperiorList(openMerchantRequest);
            return RopResponse.success(superiorList);
        } catch (RpcServiceException e) {
            log.info("=======OpenController__invoke__findSuperiorList__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "cn.com.glsx.merchants.open.findMerchantList", needInSession = NeedInSessionType.NO)
    @ApiOperation("根据商户名称和渠道类型查询商户列表")
    public RopResponse<List<MerchantRopResponse>> findMerchantList(OpenMerchantRequest openMerchantRequest) {
        try {
            List<MerchantRopResponse> superiorList = openService.findMerchantList(openMerchantRequest);
            return RopResponse.success(superiorList);
        } catch (RpcServiceException e) {
            log.info("=======OpenController__invoke__findSuperiorList__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "cn.com.glsx.merchants.open.findSubordinateListByPage", needInSession = NeedInSessionType.NO)
    @ApiOperation("根据商户查询商户下级列表")
    public RopResponse<Pagination<MerchantRopResponse>> findSubordinateListByPage(OpenMerchantPageRequest openMerchantRequest) {
        try {
            Pagination<MerchantRopResponse> subordinateListByPage = openService.findSubordinateListByPage(openMerchantRequest);
            return RopResponse.success(subordinateListByPage);
        } catch (RpcServiceException e) {
            log.info("=======OpenController__invoke__findSubordinateListByPage__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "cn.com.glsx.merchants.open.checkBussinessAccount", needInSession = NeedInSessionType.NO)
    @ApiOperation("用户登录校验")
    public RopResponse<OpenUserResponse> checkBussinessAccount(OpenUserRequest openUserRequest) {
        try {
            OpenUserResponse openUserResponse = openService.checkBussinessAccount(openUserRequest);
            return RopResponse.success(openUserResponse);
        } catch (RpcServiceException e) {
            log.info("=======OpenController__invoke__checkBussinessAccount__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "cn.com.glsx.merchants.open.findDataPermission", needInSession = NeedInSessionType.NO)
    @ApiOperation("用户数据权限获取")
    public RopResponse<List<Integer>> findDataPermission(OpenUserRequest openUserRequest) {
        try {
            List<Integer> dataPermission = openService.findDataPermission(openUserRequest);
            return RopResponse.success(dataPermission);
        } catch (RpcServiceException e) {
            log.info("=======OpenController__invoke__findDataPermission__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "cn.com.glsx.merchants.open.findMenuFunPermission", needInSession = NeedInSessionType.NO)
    @ApiOperation("用户菜单权限获取")
    public RopResponse<List<AccountTypeTreeRopResponse>> findMenuFunPermission(OpenUserRequest openUserRequest) {
        try {
            List<AccountTypeTreeRopResponse> menuFunPermission = openService.findMenuFunPermission(openUserRequest);
            return RopResponse.success(menuFunPermission);
        } catch (RpcServiceException e) {
            log.info("=======OpenController__invoke__findMenuFunPermission__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }


    /**
     * 保存或者更新商户信息接口(对外)
     *
     * @param merchantSaveRequest 入参
     * @return
     */
    @ServiceMethod(method = "cn.com.glsx.merchants.open.saveMerchant", needInSession = NeedInSessionType.NO)
    @ApiOperation("保存或者更新商户信息接口(对外)")
    public RopResponse<Integer> saveMerchant(MerchantSaveOpenRequest merchantSaveRequest) {
        try {
            Integer merchant = openService.saveMerchant(merchantSaveRequest);
            return RopResponse.success(merchant);
        } catch (RpcServiceException e) {
            log.info("=======OpenController__invoke__saveMerchant__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 企微关联商户
     *
     * @param relaevanceMerRequest 入参
     * @return
     */
    @ServiceMethod(method = "cn.com.glsx.merchants.open.relevanceMerchant", needInSession = NeedInSessionType.NO)
    @ApiOperation("企微关联商户")
    public RopResponse<Boolean> relevanceMerchant(RelaevanceMerRequest relaevanceMerRequest) {
        try {
            Boolean merchant = openService.relevanceMerchant(relaevanceMerRequest);
            return RopResponse.success(merchant);
        } catch (RpcServiceException e) {
            log.info("=======OpenController__invoke__relevanceMerchant__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

}