using IMCS.CCS.Entitys;
using IMCS.CCS.Model;
using IMCS.CCS.Service;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace IMCS.CCS.Controllers
{
///
/// 定时任务控制器
///
public class TasksController : AppBaseController
{
public TasksController(ITaskService service) : base(service)
{
}
///
/// 获取列表
///
///
///
[HttpGet("find-list/{projectId?}")]
public async Task FindListAsync([FromRoute] Guid? projectId)
=> this.ResultOk(await _service.FindListAsync(projectId));
///
/// 保存数据
///
///
///
[HttpPost("save")]
public async Task SaveAsync(Tasks form)
=> this.ResultOk(await _service.SaveAsync(form));
///
/// 删除数据
///
///
///
[HttpDelete("delete/{id}")]
public async Task DeleteAsync(Guid id)
=> this.ResultOk(await _service.DeleteAsync(id));
///
/// 根据Id 查询表单数据
///
///
///
[HttpGet("find/{id}")]
public async Task FindByIdAsync([FromRoute] Guid id)
=> this.ResultOk(await _service.FindByIdAsync(id));
///
/// 根据任务id 运行任务调度
///
///
///
[HttpPost("run")]
public async Task RunAsync([FromBody] List ids)
{
foreach (var item in ids)
{
await _service.RunByIdAsync(item);
}
return this.ResultOk(true);
}
///
/// 根据任务id 关闭任务调度
///
///
///
[HttpPost("close")]
public async Task CloseAsync([FromBody] List ids)
{
foreach (var item in ids)
{
await _service.CloseByIdAsync(item);
}
return this.ResultOk(true);
}
}
}