ChannelCodeController.java 9.06 KB
package cn.com.glsx.entmicro.controller;

import cn.com.glsx.entmicro.request.code.*;
import cn.com.glsx.entmicro.response.code.*;
import cn.com.glsx.entmicro.service.ChannelCodeService;
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;

import java.util.List;

/**
 * @author Lichongyuan
 * @Description: 渠道活码
 * @date 2021/11/14 10:27
 */
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.YES)
@Api("渠道活码服务")
@Slf4j
public class ChannelCodeController {

    @Autowired
    private ChannelCodeService channelCodeService;

    /**
     * 新增渠道活码
     *
     * @param saveChannelCodeRequest
     * @return
     */
    @ServiceMethod(method = "entmicro.api.code.saveChannelCode", needInSession = NeedInSessionType.YES)
    @ApiOperation("新增渠道活码")
    public RopResponse<Boolean> saveChannelCode(SaveChannelCodeRequest saveChannelCodeRequest) {
        try {
            channelCodeService.saveChannelCode(saveChannelCodeRequest);
            return RopResponse.success(true);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__saveChannelCode__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 编辑渠道活码
     *
     * @param updateChannelCodeRequest
     * @return
     */
    @ServiceMethod(method = "entmicro.api.code.updateChannelCode", needInSession = NeedInSessionType.YES)
    @ApiOperation("编辑渠道活码")
    public RopResponse<Boolean> updateChannelCode(UpdateChannelCodeRequest updateChannelCodeRequest) {
        try {
            channelCodeService.updateChannelCode(updateChannelCodeRequest);
            return RopResponse.success(true);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__updateChannelCode__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 删除渠道活码
     *
     * @param deleteChannelCodeRequest
     * @return
     */
    @ServiceMethod(method = "entmicro.api.code.deleteChannelCode", needInSession = NeedInSessionType.YES)
    @ApiOperation("删除渠道活码")
    public RopResponse<Boolean> deleteChannelCode(DeleteChannelCodeRequest deleteChannelCodeRequest) {
        try {
            channelCodeService.deleteChannelCode(deleteChannelCodeRequest);
            return RopResponse.success(true);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__deleteChannelCode__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 渠道活码分页列表
     *
     * @param searchChannelCodeRequest
     * @return
     */
    @ServiceMethod(method = "entmicro.api.code.listChannelCodeByPage", needInSession = NeedInSessionType.YES)
    @ApiOperation("渠道活码分页列表")
    public RopResponse<Pagination<ListChannelCodeByPageResponse>> listChannelCodeByPage(SearchChannelCodeRequest searchChannelCodeRequest) {
        try {
            Pagination<ListChannelCodeByPageResponse> codeByPage = channelCodeService.listChannelCodeByPage(searchChannelCodeRequest);
            return RopResponse.success(codeByPage);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__listChannelCodeByPage__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 获取活码详情
     *
     * @param detailChanelCodeRequest
     * @return
     */
    @ServiceMethod(method = "entmicro.api.code.detailChannelCode", needInSession = NeedInSessionType.YES)
    @ApiOperation("获取活码详情")
    public RopResponse<DetailChannelCodeResponse> detailChannelCode(DetailChanelCodeRequest detailChanelCodeRequest) {
        try {
            DetailChannelCodeResponse detailChannelCodeResponse = channelCodeService.detailChannelCode(detailChanelCodeRequest);
            return RopResponse.success(detailChannelCodeResponse);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__detailChannelCode__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 当前活码员工列表
     *
     * @param getChannelCodeStaffListRequest
     * @return
     */
    @ServiceMethod(method = "entmicro.api.code.getChannelCodeStaffList", needInSession = NeedInSessionType.YES)
    @ApiOperation("当前活码员工列表")
    public RopResponse<Pagination<GetChannelCodeStaffListResponse>> getChannelCodeStaffList(GetChannelCodeStaffListRequest getChannelCodeStaffListRequest) {
        try {
            Pagination<GetChannelCodeStaffListResponse> channelStaffList = channelCodeService.getChannelStaffList(getChannelCodeStaffListRequest);
            return RopResponse.success(channelStaffList);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__getChannelCodeStaffList__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 渠道活码列表 企微端
     *
     * @param searchEntmicroChannelCodeRequest
     * @return
     */
    @ServiceMethod(method = "entmicro.api.code.listEntmicroChannelCodeList", needInSession = NeedInSessionType.YES)
    @ApiOperation("渠道活码列表 企微端")
    public RopResponse<List<ListEntmicroChannelCodeRopResponse>> listEntmicroChannelCodeList(SearchEntmicroChannelCodeRequest searchEntmicroChannelCodeRequest) {
        try {
            List<ListEntmicroChannelCodeRopResponse> responses = channelCodeService.listEntmicroChannelCodeList(searchEntmicroChannelCodeRequest);
            return RopResponse.success(responses);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__listEntmicroChannelCodeList__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }


    /**
     * 无忧服务渠道活码分页列表
     *
     * @param searchChannelCodeRequest
     * @return
     */
    @ServiceMethod(method = "entmicro.api.code.getFreeChannelCode", needInSession = NeedInSessionType.YES)
    @ApiOperation("无忧服务渠道活码分页列表")
    public RopResponse<Pagination<ListChannelCodeByPageResponse>> getFreeChannelCode(SearchChannelCodeRequest searchChannelCodeRequest) {
        try {
            Pagination<ListChannelCodeByPageResponse> codeByPage = channelCodeService.getFreeChannelCode(searchChannelCodeRequest);
            return RopResponse.success(codeByPage);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__getFreeChannelCode__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 渠道我的活码列表 企微端
     *
     * @param searchEntmicroChannelCodeRequest
     * @return
     */
    @ServiceMethod(method = "entmicro.api.code.listStaffEntmicroChannelCodeList", needInSession = NeedInSessionType.YES)
    @ApiOperation("渠道我的活码列表 企微端")
    public RopResponse<List<ListEntmicroChannelCodeRopResponse>> listStaffEntmicroChannelCodeList(SearchEntmicroChannelCodeRequest searchEntmicroChannelCodeRequest) {
        try {
            List<ListEntmicroChannelCodeRopResponse> responses = channelCodeService.listStaffEntmicroChannelCodeList(searchEntmicroChannelCodeRequest);
            return RopResponse.success(responses);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__listStaffEntmicroChannelCodeList__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 获取当前门店已配置了活码的员工(仅服务商账号)
     * @param request
     * @return
     */
    @ServiceMethod(method = "entmicro.api.code.getCodeStaffList", needInSession = NeedInSessionType.YES)
    @ApiOperation("获取当前门店已配置了活码的员工(仅服务商账号)")
    public RopResponse<List<DracChannelCodeStaffRopResponse>> getCodeStaffList(DracChannelCodeStaffRopRequest request) {
        try {
            List<DracChannelCodeStaffRopResponse> codeStaffList = channelCodeService.getCodeStaffList(request);
            return RopResponse.success(codeStaffList);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__getCodeStaffList__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }
}