MerchantMissionController.java 9.51 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.mission.*;
import cn.com.glsx.merchants.response.EntmicroResponse;
import cn.com.glsx.merchants.service.MerchantMissionService;
import cn.com.glsx.merchants.util.Pagination;
import cn.com.glsx.stoassistant.model.response.mission.PlatformMerchantMissionInfoResponse;
import cn.com.glsx.stoassistant.model.response.mission.PlatformMerchantMissionListResponse;
import cn.com.glsx.stoassistant.model.response.mission.PlatformMerchantStaffMissionDetailResponse;
import com.alibaba.fastjson.JSONObject;
import com.rop.AbstractRopRequest;
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.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;

import java.util.List;

/**
 * @ClassName MerchantStaffScoreController
 * @Description
 * @Author lichongyuan
 * @Date 2022/10/14
 */
@Slf4j
@Api("任务管理接口")
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.NO)
public class MerchantMissionController {

    @Autowired
    private MerchantMissionService merchantMissionService;

    @Autowired
    private Environment environment;

    /**
     * 任务创建
     *
     * @param createdMissionRopRequest 入参
     * @return
     */
    @ServiceMethod(method = "merchants.api.mission.createMission", needInSession = NeedInSessionType.NO)
    @ApiOperation("任务创建")
    public RopResponse<Boolean> createMission(CreatedMissionRopRequest createdMissionRopRequest) {
        try {
            return RopResponse.success(merchantMissionService.createMission(createdMissionRopRequest));
        } catch (RpcServiceException e) {
            log.info("=======MerchantMissionController__invoke__createMission__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 任务更新
     *
     * @param updateMissionRopRequest 入参
     * @return
     */
    @ServiceMethod(method = "merchants.api.mission.updateMission", needInSession = NeedInSessionType.NO)
    @ApiOperation("任务更新")
    public RopResponse<Boolean> updateMission(UpdateMissionRopRequest updateMissionRopRequest) {
        try {
            return RopResponse.success(merchantMissionService.updateMission(updateMissionRopRequest));
        } catch (RpcServiceException e) {
            log.info("=======MerchantMissionController__invoke__updateMission__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 任务状态更新
     *
     * @param updateStatusMissionRopRequest 入参
     * @return
     */
    @ServiceMethod(method = "merchants.api.mission.updateStatusMission", needInSession = NeedInSessionType.NO)
    @ApiOperation("任务状态更新")
    public RopResponse<Boolean> updateMission(UpdateStatusMissionRopRequest updateStatusMissionRopRequest) {
        try {
            return RopResponse.success(merchantMissionService.updateStatusMission(updateStatusMissionRopRequest));
        } catch (RpcServiceException e) {
            log.info("=======MerchantMissionController__invoke__updateMission__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 任务详情
     *
     * @param missionDetailRopRequest 入参
     * @return
     */
    @ServiceMethod(method = "merchants.api.mission.findMissionDeail", needInSession = NeedInSessionType.NO)
    @ApiOperation("任务详情")
    public RopResponse<PlatformMerchantMissionInfoResponse> findMissionDeail(MissionDetailRopRequest missionDetailRopRequest) {
        try {
            return RopResponse.success(merchantMissionService.findMissionDeail(missionDetailRopRequest));
        } catch (RpcServiceException e) {
            log.info("=======MerchantMissionController__invoke__findMissionDeail__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 任务列表查询
     *
     * @param missionDetailRopRequest 入参
     * @return
     */
    @ServiceMethod(method = "merchants.api.mission.findMissionList", needInSession = NeedInSessionType.NO)
    @ApiOperation("任务列表查询")
    public RopResponse<Pagination<PlatformMerchantMissionInfoResponse>> findMissionList(MissionPageRopRequest missionDetailRopRequest) {
        try {
            Pagination<PlatformMerchantMissionInfoResponse> productResponsePagination = merchantMissionService.findMissionList(missionDetailRopRequest);
            return RopResponse.success(productResponsePagination);
        } catch (RpcServiceException e) {
            log.info("=======MerchantMissionController__invoke__findMissionList__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 员工任务列表查询
     *
     * @param missionStaffPageRopRequest 入参
     * @return
     */
    @ServiceMethod(method = "merchants.api.mission.findStaffMissionPageList", needInSession = NeedInSessionType.NO)
    @ApiOperation("员工任务列表查询")
    public RopResponse<Pagination<PlatformMerchantStaffMissionDetailResponse>> findStaffMissionPageList(MissionStaffPageRopRequest missionStaffPageRopRequest) {
        try {
            Pagination<PlatformMerchantStaffMissionDetailResponse> productResponsePagination = merchantMissionService.findStaffMissionPageList(missionStaffPageRopRequest);
            return RopResponse.success(productResponsePagination);
        } catch (RpcServiceException e) {
            log.info("=======MerchantMissionController__invoke__findStaffMissionPageList__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }


    /**
     * 复制员工任务链接
     *
     * @param missionStaffLinkRequest 入参
     * @return
     */
    @ServiceMethod(method = "merchants.api.mission.getStaffMissionLink", needInSession = NeedInSessionType.NO)
    @ApiOperation("复制员工任务链接")
    public RopResponse<String> getStaffMissionLink(MissionStaffLinkRequest missionStaffLinkRequest) {
        try {
            String staffMissionLink = merchantMissionService.getStaffMissionLink(missionStaffLinkRequest);
            String context=environment.getProperty("merchants.api.mission.context");
            if(!StringUtils.isEmpty(context)){
                staffMissionLink=context+" "+staffMissionLink;
            }
            return RopResponse.success(staffMissionLink);
        } catch (RpcServiceException e) {
            log.info("=======MerchantMissionController__invoke__getStaffMissionLink__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 查询任务总数
     *
     * @param abstractRopRequest 入参
     * @return
     */
    @ServiceMethod(method = "merchants.api.mission.staticMission", needInSession = NeedInSessionType.NO)
    @ApiOperation("查询任务总数")
    public RopResponse<PlatformMerchantMissionListResponse> staticMission(AbstractRopRequest abstractRopRequest) {
        try {
            return RopResponse.success(merchantMissionService.staticMission(abstractRopRequest));
        } catch (RpcServiceException e) {
            log.info("=======MerchantMissionController__invoke__staticMission__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }


    /**
     * 查询发送的企微
     *
     * @param abstractRopRequest 入参
     * @return
     */
    @ServiceMethod(method = "merchants.api.mission.findEntmicroList", needInSession = NeedInSessionType.NO)
    @ApiOperation("查询发送的企微")
    public RopResponse<List<EntmicroResponse>> findEntmicroList(AbstractRopRequest abstractRopRequest) {
        try {
            String json=environment.getProperty("entmicro.list");
            List<EntmicroResponse> entmicroResponses = JSONObject.parseArray(json, EntmicroResponse.class);
            return RopResponse.success(entmicroResponses);
        } catch (RpcServiceException e) {
            log.info("=======MerchantMissionController__invoke__staticMission__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 手动推送任务卡片
     *
     * @param missionAutoRequest 入参
     * @return
     */
    @ServiceMethod(method = "merchants.api.mission.autoReminderProcess", needInSession = NeedInSessionType.NO)
    @ApiOperation("手动推送任务卡片")
    public RopResponse<Boolean> autoReminderProcess(MissionAutoRequest missionAutoRequest) {
        try {
            return RopResponse.success(merchantMissionService.autoReminderProcess(missionAutoRequest));
        } catch (RpcServiceException e) {
            log.info("=======MerchantMissionController__invoke__staticMission__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }
}