package com.bocloud.ims.booter.controller.resource;

import com.bocloud.cmp.driver.common.TaskMsgDriver;
import com.bocloud.cmp.model.TaskMsgModel;
import com.bocloud.common.model.BocloudResult;
import com.bocloud.common.utils.Common;
import com.bocloud.ims.entity.resource.CloudVendor;
import com.bocloud.ims.interfaces.resource.TaskMsgService;
import com.bocloud.ims.repository.resource.CloudVendorRepository;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 平台任务
 *
 * @author wangyu
 * @version 5.0.0-SNAPSHOT
 * @since 2021/4/17
 */
@Api(value = "平台任务管理", tags = "平台任务管理")
@RestController
@RequestMapping("/v1/task-message")
@Slf4j
public class TaskMsgController {

    @Autowired
    private TaskMsgService taskMsgService;

    @ApiOperation(tags = { "CMC", "CSC" }, value = "查询平台任务列表", httpMethod = "GET")
    @GetMapping("/{vendorId}")
    public BocloudResult<List<TaskMsgModel>> list(@PathVariable(value = Common.VENDORID) Long vendorId) {
        try {
            return taskMsgService.list(vendorId);
        } catch (Exception e) {
            log.error("Get error message:{}", e);
            return new BocloudResult<>(false, "查询失败");
        }
    }
}
