BatchMessagingController.java 8.62 KB
package cn.com.glsx.entmicro.controller.wechatcloudcontrol;

import cn.com.glsx.entmicro.dto.activityreport.ScrmActivityReportLogDTO;
import cn.com.glsx.entmicro.model.response.wechatcloudcontrol.batchmessaging.BatchMessagingGroupResponse;
import cn.com.glsx.entmicro.request.wechatcloudcontrol.ActivityReportLog.ActivityReportLogSearchRopRequest;
import cn.com.glsx.entmicro.request.wechatcloudcontrol.batchmessaging.*;
import cn.com.glsx.entmicro.response.wechatcloudcontrol.batchmessaging.BatchMessagingMerchantVO;
import cn.com.glsx.entmicro.response.wechatcloudcontrol.batchmessaging.BatchMessagingRecordVO;
import cn.com.glsx.entmicro.response.wechatcloudcontrol.batchmessaging.BatchMessagingRecordOfSendVO;
import cn.com.glsx.entmicro.service.wechatcloudcontrol.BatchMessagingService;
import cn.com.glsx.entmicro.utils.Pagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.rop.response.RopResponse;
import cn.com.glsx.worktool.model.response.ScrmWorktoolGroupResponse;
import cn.com.glsx.worktool.remote.GroupRemote;
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 javax.annotation.Resource;
import java.util.List;

/**
 * @author chizw
 * @version ver.1.0.0
 * @Description
 * @create 2022/9/19 15:06
 */
@Slf4j
@Api("企微接入 - 企微群发")
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.YES)
public class BatchMessagingController {

    @Resource
    private BatchMessagingService batchMessagingService;

    @Autowired
    private GroupRemote groupRemote;

    @ServiceMethod(method = "entmicro.api.wechatcloudcontrol.nosession.batchmessaging.create", needInSession = NeedInSessionType.NO)
    @ApiOperation("企微高级群发任务创建")
    public RopResponse<Boolean> createBatchMessagingNoSessionTask(BatchMessagingCreateRopRequest request) {
        try {
            return RopResponse.success(batchMessagingService.createBatchMessagingTask(request));
        } catch (RpcServiceException e) {
            log.info("=======BatchMessagingController_createBatchMessagingTask_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.wechatcloudcontrol.batchmessaging.create")
    @ApiOperation("企微高级群发任务创建")
    public RopResponse<Boolean> createBatchMessagingTask(BatchMessagingCreateRopRequest request) {
        try {
            return RopResponse.success(batchMessagingService.createBatchMessagingTask(request));
        } catch (RpcServiceException e) {
            log.info("=======BatchMessagingController_createBatchMessagingTask_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.wechatcloudcontrol.batchmessaging.customercount")
    @ApiOperation("企微高级群发查看预计群发人数")
    public RopResponse<Integer> estimateCustomerCount(BatchMessagingCreateRopRequest request) {
        try {
            return RopResponse.success(batchMessagingService.getEstimateCustomerCount(request));
        } catch (RpcServiceException e) {
            log.info("=======BatchMessagingController_estimateCustomerCount_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.wechatcloudcontrol.batchmessaging.create.merchant")
    @ApiOperation("企微高级群发创建门店列表")
    public RopResponse<List<BatchMessagingMerchantVO>> queryBatchMessagingCreateMerchant(BatchMessagingMerchantRopRequest request) {
        try {
            return RopResponse.success(batchMessagingService.findBatchMessagingMerchantList(request));
        } catch (RpcServiceException e) {
            log.info("=======BatchMessagingController_queryBatchMessagingCreateMerchant_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.wechatcloudcontrol.batchmessaging.record")
    @ApiOperation("企微高级群发记录")
    public RopResponse<Pagination<BatchMessagingRecordVO>> queryBatchMessagingRecord(BatchMessagingRecordRopRequest request) {
        try {
            return RopResponse.success(batchMessagingService.queryBatchMessaging(request));
        } catch (RpcServiceException e) {
            log.info("=======BatchMessagingController_queryBatchMessagingRecord_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.wechatcloudcontrol.batchmessaging.record.send")
    @ApiOperation("企微高级群发发送记录")
    public RopResponse<Pagination<BatchMessagingRecordOfSendVO>> queryBatchMessagingRecordOfSend(BatchMessagingRecordOfSendRopRequest request) {
        try {
            return RopResponse.success(batchMessagingService.queryBatchMessagingOfSend(request));
        } catch (RpcServiceException e) {
            log.info("=======BatchMessagingController_queryBatchMessagingRecordOfSend_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.wechatcloudcontrol.batchmessaging.group.list")
    @ApiOperation("企微高级群聊列表")
    public RopResponse<List<BatchMessagingGroupResponse>> getBatchMessagingGroupList(BatchMessagingUserRopRequest request) {
        try {
            return RopResponse.success(batchMessagingService.getBatchMessagingGroupList(request));
        } catch (RpcServiceException e) {
            log.info("=======BatchMessagingController_getBatchMessagingGroupList_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.wechatcloudcontrol.batchmessaging.group.list.nosession", needInSession = NeedInSessionType.NO)
    @ApiOperation("企微高级群聊列表")
    public RopResponse<List<BatchMessagingGroupResponse>> getBatchMessagingGroupListNoSeesion(BatchMessagingUserRopRequest request) {
        try {
            return RopResponse.success(batchMessagingService.getBatchMessagingGroupList(request));
        } catch (RpcServiceException e) {
            log.info("=======BatchMessagingController_getBatchMessagingGroupList_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.wechatcloudcontrol.batchmessaging.send.stop")
    @ApiOperation("群发记录停止发送")
    public RopResponse<Boolean> stopBatchMessagingSend(BatchMessagingRecordOfSendRopRequest request) {
        try {
            return RopResponse.success(batchMessagingService.stopBatchMessagingSend(request));
        } catch (RpcServiceException e) {
            log.info("=======BatchMessagingController_stopBatchMessagingSend_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.wechatcloudcontrol.activityreport.log.page")
    @ApiOperation("查询喜报战报推送日志分页列表")
    public RopResponse<Pagination<ScrmActivityReportLogDTO>> getActivityReportLogPage(ActivityReportLogSearchRopRequest request) {
        try {
            return RopResponse.success(batchMessagingService.getActivityReportLogPage(request));
        } catch (RpcServiceException e) {
            log.info("=======BatchMessagingController_getActivityReportLogPage_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.wechatcloudcontrol.activityreport.worktool.grouplist")
    @ApiOperation("查询worktool群列表")
    public RopResponse<RpcResponse<List<ScrmWorktoolGroupResponse>>> worktoolGroupList(WorkToolGroupListRopRequest workToolGroupListRopRequest) {
        try {
            return RopResponse.success(groupRemote.groupList(workToolGroupListRopRequest.getCloudId()));
        } catch (RpcServiceException e) {
            log.info("=======BatchMessagingController_getActivityReportLogPage_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }
}