OperationController.java 5 KB
package cn.com.glsx.entmicro.controller;

import cn.com.glsx.entmicro.request.operation.*;
import cn.com.glsx.entmicro.response.operation.OperationCodeRopResponse;
import cn.com.glsx.entmicro.response.operation.OperationDetailRopResponse;
import cn.com.glsx.entmicro.response.operation.OperationPageRopResponse;
import cn.com.glsx.entmicro.service.operation.OperationService;
import cn.com.glsx.entmicro.utils.Pagination;
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;


/**
 * @ClassName OperationController
 * @Description 运营专家Controller
 * @Author lichongyuan
 * @Date 2022/5/9
 */
@Slf4j
@Api("运营专家配置接口")
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.NO)
public class OperationController {

    @Autowired
    private OperationService operationService;

    /**
     * 运营专家分页接口
     *
     * @param request 搜索入参
     * @return
     */
    @ServiceMethod(method = "entmicro.api.operation.page", needInSession = NeedInSessionType.YES)
    @ApiOperation("运营专家分页接口")
    public RopResponse<Pagination<OperationPageRopResponse>> getPage(OperationSearchRopRequest request) {
        try {
            return RopResponse.success(operationService.getPage(request));
        } catch (RpcServiceException e) {
            log.info("=======OperationController_getMassPage_invoke__getPage__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 新增运营配置
     *
     * @param request 搜索入参
     * @return
     */
    @ServiceMethod(method = "entmicro.api.operation.save", needInSession = NeedInSessionType.YES)
    @ApiOperation("新增运营配置")
    public RopResponse<Boolean> save(OperationSaveRopRequest request) {
        try {
            operationService.save(request);
            return RopResponse.success(true);
        } catch (RpcServiceException e) {
            log.info("=======OperationController_invoke__save__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 修改运营配置(禁用)
     *
     * @param request 搜索入参
     * @return
     */
    @ServiceMethod(method = "entmicro.api.operation.update", needInSession = NeedInSessionType.YES)
    @ApiOperation("修改运营配置(禁用)")
    public RopResponse<Boolean> update(OperationSaveRopRequest request) {
        try {
            operationService.update(request);
            return RopResponse.success(true);
        } catch (RpcServiceException e) {
            log.info("=======OperationController_invoke__update__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 删除运营配置
     *
     * @param request 搜索入参
     * @return
     */
    @ServiceMethod(method = "entmicro.api.operation.delete", needInSession = NeedInSessionType.YES)
    @ApiOperation("删除运营配置")
    public RopResponse<Boolean> delete(OperationDeleteRopRequest request) {
        try {
            operationService.delete(request);
            return RopResponse.success(true);
        } catch (RpcServiceException e) {
            log.info("=======OperationController_invoke__delete__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 配置详情
     *
     * @param request 搜索入参
     * @return
     */
    @ServiceMethod(method = "entmicro.api.operation.detail", needInSession = NeedInSessionType.YES)
    @ApiOperation("配置详情")
    public RopResponse<OperationDetailRopResponse> getDetail(OperationDetailRopRequest request) {
        try {
            return RopResponse.success(operationService.getDetail(request));
        } catch (RpcServiceException e) {
            log.info("=======OperationController_invoke__delete__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 下单获取二维码
     *
     * @param request 搜索入参
     * @return
     */
    @ServiceMethod(method = "entmicro.api.operation.code", needInSession = NeedInSessionType.NO)
    @ApiOperation("下单获取二维码")
    public RopResponse<OperationCodeRopResponse> getQRCode(OperationDetailRopRequest request) {
        try {
            return RopResponse.success(operationService.getOperationCode(request));
        } catch (RpcServiceException e) {
            log.info("=======OperationController_invoke__delete__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }
}