You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
2.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.aurora.controller;
import com.aurora.annotation.OptLog;
import com.aurora.model.dto.JobLogDTO;
import com.aurora.model.vo.ResultVO;
import com.aurora.service.JobLogService;
import com.aurora.model.vo.JobLogSearchVO;
import com.aurora.model.dto.PageResultDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import static com.aurora.constant.OptTypeConstant.DELETE;
@Api(tags = "定时任务日志模块")
@RestController
public class JobLogController {
@Autowired
private JobLogService jobLogService;//调用Service层的日志业务方法
@ApiOperation("获取定时任务的日志列表")
@GetMapping("/admin/jobLogs")
public ResultVO<PageResultDTO<JobLogDTO>> listJobLogs(JobLogSearchVO jobLogSearchVO) {
//JobLogSearchVO jobLogSearchVO封装日志的查询条件比如任务ID、执行状态、时间范围等
return ResultVO.ok(jobLogService.listJobLogs(jobLogSearchVO));
}
@OptLog(optType = DELETE)
@ApiOperation("删除定时任务的日志")
@DeleteMapping("/admin/jobLogs")
public ResultVO<?> deleteJobLogs(@RequestBody List<Integer> ids) {
jobLogService.deleteJobLogs(ids);
return ResultVO.ok();
}
@OptLog(optType = DELETE)
@ApiOperation("清除定时任务的日志")
@DeleteMapping("/admin/jobLogs/clean")
//返回值ResultVO<?>:仅返回操作成功的状态,无具体业务数据
public ResultVO<?> cleanJobLogs() {
jobLogService.cleanJobLogs();
return ResultVO.ok();
}
@ApiOperation("获取定时任务日志的所有组名")//用于后台查询日志时筛选分组
@GetMapping("/admin/jobLogs/jobGroups")
//返回值ResultVO<?>:返回包含所有日志关联任务分组名称的结果(通常是字符串列表)
public ResultVO<?> listJobLogGroups() {
return ResultVO.ok(jobLogService.listJobLogGroups());
}
}