2024-09-02 09:00:50 +08:00
|
|
|
|
using Bunny.Dao.Model.Result;
|
2024-08-14 23:57:43 +08:00
|
|
|
|
using Bunny.Service.IService;
|
2024-09-02 09:31:34 +08:00
|
|
|
|
using Microsoft.AspNetCore.Components;
|
2024-08-14 23:57:43 +08:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
|
|
namespace Bunny.WebApi.Controllers;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Quartz 示例相关
|
|
|
|
|
/// </summary>
|
2024-09-02 09:31:34 +08:00
|
|
|
|
[Microsoft.AspNetCore.Mvc.Route("/api/[controller]/[action]")]
|
|
|
|
|
public class JobInitController : ControllerBase
|
2024-08-14 23:57:43 +08:00
|
|
|
|
{
|
2024-09-02 09:31:34 +08:00
|
|
|
|
[Inject] public required IJobService JobService { get; set; }
|
|
|
|
|
|
2024-08-14 23:57:43 +08:00
|
|
|
|
/// <summary>
|
2024-08-15 16:23:34 +08:00
|
|
|
|
/// 1. 开启一个简单的工作
|
2024-08-14 23:57:43 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public Result<string> StartSimpleJob()
|
|
|
|
|
{
|
2024-09-02 09:31:34 +08:00
|
|
|
|
JobService.StartSimpleJob();
|
2024-08-15 16:23:34 +08:00
|
|
|
|
return Result<string>.Success("将名称生成放在jobDetail中,可以再运行时获取到");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 2. 将jobDetail放在触发器中
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public Result<string> PutJobDetail4Trigger()
|
|
|
|
|
{
|
2024-09-02 09:31:34 +08:00
|
|
|
|
JobService.PutJobDetail4Trigger();
|
2024-08-15 16:23:34 +08:00
|
|
|
|
return Result<string>.Success("将jobDetail中的一些信息放在触发器中,简化写法");
|
2024-08-14 23:57:43 +08:00
|
|
|
|
}
|
2024-08-15 16:37:31 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 3. 设置每日时间表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpHead]
|
|
|
|
|
public Result<string> SetJobWithDaily()
|
|
|
|
|
{
|
2024-09-02 09:31:34 +08:00
|
|
|
|
JobService.SetJobWithDaily();
|
2024-08-15 16:37:31 +08:00
|
|
|
|
return Result<string>.Success();
|
|
|
|
|
}
|
2024-08-14 23:57:43 +08:00
|
|
|
|
}
|