定时任务点击报错 Request failed with status code 404

提问 已结
3 223

1 month ago

定时任务点击报错 Request failed with status code 404
{message: 'Request failed with status code 404', name: 'AxiosError', code: 'ERR_BAD_REQUEST', config: {…}, request: XMLHttpRequest, …

回帖
maku 1 month ago (已采纳)

404,表示后端没有接口,是不是没有使用定时任务的模块,具体可以查看文档,有说明

zhangyongkang  (楼主) 1 month ago

@maku 有模块的,前端调不到后端接口上```java
package net.maku.quartz.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import net.maku.framework.common.page.PageResult;
import net.maku.framework.common.utils.Result;
import net.maku.quartz.convert.ScheduleJobConvert;
import net.maku.quartz.entity.ScheduleJobEntity;
import net.maku.quartz.query.ScheduleJobQuery;
import net.maku.quartz.service.ScheduleJobService;
import net.maku.quartz.utils.CronUtils;
import net.maku.quartz.vo.ScheduleJobVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**

  • 定时任务

  • @author 阿沐 babamu@126.com
    */
    @RestController
    @RequestMapping("schedule")
    @Tag(name="定时任务")
    @AllArgsConstructor
    public class ScheduleJobController {
    private final ScheduleJobService scheduleJobService;

    @GetMapping("page")
    @Operation(summary = "分页")
    @PreAuthorize("hasAuthority('schedule:page')")
    public Result<PageResult> page(@Valid ScheduleJobQuery query){
    PageResult page = scheduleJobService.page(query);

      return Result.ok(page);
    

    }

    @GetMapping("{id}")
    @Operation(summary = "信息")
    @PreAuthorize("hasAuthority('schedule:info')")
    public Result get(@PathVariable("id") Long id){
    ScheduleJobEntity entity = scheduleJobService.getById(id);

      return Result.ok(ScheduleJobConvert.INSTANCE.convert(entity));
    

    }

    @PostMapping
    @Operation(summary = "保存")
    @PreAuthorize("hasAuthority('schedule:save')")
    public Result save(@RequestBody ScheduleJobVO vo){
    if (!CronUtils.isValid(vo.getCronExpression())) {
    return Result.error("操作失败,Cron表达式不正确");
    }

      scheduleJobService.save(vo);
    
      return Result.ok();
    

    }

    @PutMapping
    @Operation(summary = "修改")
    @PreAuthorize("hasAuthority('schedule:update')")
    public Result update(@RequestBody @Valid ScheduleJobVO vo) {
    if (!CronUtils.isValid(vo.getCronExpression())) {
    return Result.error("操作失败,Cron表达式不正确");
    }

      scheduleJobService.update(vo);
    
      return Result.ok();
    

    }

    @DeleteMapping
    @Operation(summary = "删除")
    @PreAuthorize("hasAuthority('schedule:delete')")
    public Result delete(@RequestBody List idList){
    scheduleJobService.delete(idList);

      return Result.ok();
    

    }

    @PutMapping("run")
    @Operation(summary = "立即执行")
    @PreAuthorize("hasAuthority('schedule:run')")
    public Result run(@RequestBody ScheduleJobVO vo){
    scheduleJobService.run(vo);

      return Result.ok();
    

    }

    @PutMapping("change-status")
    @Operation(summary = "修改状态")
    @PreAuthorize("hasAuthority('schedule:update')")
    public Result changeStatus(@RequestBody ScheduleJobVO vo){
    scheduleJobService.changeStatus(vo);

      return Result.ok();
    

    }
    }

zhangyongkang  (楼主) 1 month ago

@maku 只有这一个接口是有问题的

温馨通道
回贴总榜