serv\web-学习历史修改
This commit is contained in:
@@ -73,7 +73,7 @@ public class CrontabController {
|
||||
* @since 2025-10-25
|
||||
*/
|
||||
@GetMapping("/task/{taskId}")
|
||||
public ResultDomain<TbCrontabTask> getTaskById(@PathVariable String taskId) {
|
||||
public ResultDomain<TbCrontabTask> getTaskById(@PathVariable(value = "taskId") String taskId) {
|
||||
return crontabService.getTaskById(taskId);
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ public class CrontabController {
|
||||
* @since 2025-10-25
|
||||
*/
|
||||
@PostMapping("/task/start/{taskId}")
|
||||
public ResultDomain<TbCrontabTask> startTask(@PathVariable String taskId) {
|
||||
public ResultDomain<TbCrontabTask> startTask(@PathVariable(value = "taskId") String taskId) {
|
||||
return crontabService.startTask(taskId);
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ public class CrontabController {
|
||||
* @since 2025-10-25
|
||||
*/
|
||||
@PostMapping("/task/pause/{taskId}")
|
||||
public ResultDomain<TbCrontabTask> pauseTask(@PathVariable String taskId) {
|
||||
public ResultDomain<TbCrontabTask> pauseTask(@PathVariable(value = "taskId") String taskId) {
|
||||
return crontabService.pauseTask(taskId);
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ public class CrontabController {
|
||||
* @since 2025-10-25
|
||||
*/
|
||||
@PostMapping("/task/execute/{taskId}")
|
||||
public ResultDomain<TbCrontabTask> executeTaskOnce(@PathVariable String taskId) {
|
||||
public ResultDomain<TbCrontabTask> executeTaskOnce(@PathVariable(value = "taskId") String taskId) {
|
||||
return crontabService.executeTaskOnce(taskId);
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ public class CrontabController {
|
||||
* @since 2025-10-25
|
||||
*/
|
||||
@GetMapping("/log/task/{taskId}")
|
||||
public ResultDomain<TbCrontabLog> getLogsByTaskId(@PathVariable String taskId) {
|
||||
public ResultDomain<TbCrontabLog> getLogsByTaskId(@PathVariable(value = "taskId") String taskId) {
|
||||
return crontabService.getLogsByTaskId(taskId);
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ public class CrontabController {
|
||||
* @since 2025-10-25
|
||||
*/
|
||||
@GetMapping("/log/{logId}")
|
||||
public ResultDomain<TbCrontabLog> getLogById(@PathVariable String logId) {
|
||||
public ResultDomain<TbCrontabLog> getLogById(@PathVariable(value = "logId") String logId) {
|
||||
return crontabService.getLogById(logId);
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ public class CrontabController {
|
||||
* @since 2025-10-25
|
||||
*/
|
||||
@DeleteMapping("/log/clean/{days}")
|
||||
public ResultDomain<Integer> cleanLogs(@PathVariable Integer days) {
|
||||
public ResultDomain<Integer> cleanLogs(@PathVariable(value = "days") Integer days) {
|
||||
return crontabService.cleanLogs(days);
|
||||
}
|
||||
|
||||
|
||||
@@ -100,5 +100,14 @@ public interface CrontabTaskMapper extends BaseMapper<TbCrontabTask> {
|
||||
* @since 2025-10-25
|
||||
*/
|
||||
TbCrontabTask selectTaskByBeanAndMethod(@Param("beanName") String beanName, @Param("methodName") String methodName);
|
||||
|
||||
/**
|
||||
* @description 查询任务总数
|
||||
* @param filter 过滤条件
|
||||
* @return int 任务总数
|
||||
* @author yslg
|
||||
* @since 2025-10-25
|
||||
*/
|
||||
int countSelectTask(@Param("filter") TbCrontabTask filter);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.xyzh.api.crontab.CrontabService;
|
||||
import org.xyzh.common.core.domain.ResultDomain;
|
||||
import org.xyzh.common.core.page.PageDomain;
|
||||
import org.xyzh.common.core.page.PageParam;
|
||||
import org.xyzh.common.dto.crontab.TbCrontabTask;
|
||||
import org.xyzh.common.dto.crontab.TbCrontabLog;
|
||||
@@ -215,7 +216,14 @@ public class CrontabServiceImpl implements CrontabService {
|
||||
}
|
||||
|
||||
List<TbCrontabTask> list = taskMapper.selectTaskPage(filter, pageParam);
|
||||
resultDomain.success("查询成功", list);
|
||||
int total = taskMapper.countSelectTask(filter);
|
||||
|
||||
PageDomain<TbCrontabTask> pageDomain = new PageDomain<>();
|
||||
pageDomain.setDataList(list);
|
||||
pageParam.setTotalElements(total);
|
||||
pageParam.setTotalPages((int) Math.ceil((double) total / pageParam.getPageSize()));
|
||||
pageDomain.setPageParam(pageParam);
|
||||
resultDomain.success("查询成功", pageDomain);
|
||||
} catch (Exception e) {
|
||||
logger.error("分页查询定时任务异常: ", e);
|
||||
resultDomain.fail("分页查询定时任务异常: " + e.getMessage());
|
||||
|
||||
@@ -33,6 +33,33 @@
|
||||
|
||||
<!-- 查询条件 -->
|
||||
<sql id="Base_Where_Clause">
|
||||
<where>
|
||||
deleted = 0
|
||||
<if test="taskId != null and taskId != ''">
|
||||
AND task_id = #{taskId}
|
||||
</if>
|
||||
<if test="taskName != null and taskName != ''">
|
||||
AND task_name LIKE CONCAT('%', #{taskName}, '%')
|
||||
</if>
|
||||
<if test="taskGroup != null and taskGroup != ''">
|
||||
AND task_group = #{taskGroup}
|
||||
</if>
|
||||
<if test="beanName != null and beanName != ''">
|
||||
AND bean_name = #{beanName}
|
||||
</if>
|
||||
<if test="methodName != null and methodName != ''">
|
||||
AND method_name = #{methodName}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<if test="deleted != null">
|
||||
AND deleted = #{deleted}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<sql id="Filter_Where_Clause">
|
||||
<where>
|
||||
<if test="filter != null">
|
||||
<if test="filter.ID != null and filter.ID != ''">
|
||||
@@ -144,7 +171,7 @@
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_crontab_task
|
||||
<include refid="Base_Where_Clause" />
|
||||
<include refid="Filter_Where_Clause" />
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
@@ -153,7 +180,7 @@
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_crontab_task
|
||||
<include refid="Base_Where_Clause" />
|
||||
<include refid="Filter_Where_Clause" />
|
||||
ORDER BY create_time DESC
|
||||
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
|
||||
</select>
|
||||
@@ -185,4 +212,11 @@
|
||||
AND deleted = 0
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- countSelectTask -->
|
||||
|
||||
<select id="countSelectTask">
|
||||
SELECT COUNT(1) FROM tb_crontab_task
|
||||
<include refid="Filter_Where_Clause" />
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user