package com.dxhy.core.job.controller;

import com.dxhy.common.controller.AbstractController;
import com.dxhy.common.utils.PageUtils;
import com.dxhy.common.utils.R;
import com.dxhy.core.job.entity.ScheduleJobLogEntity;
import com.dxhy.core.job.service.ScheduleJobLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 定时任务日志
 *
 * @author user
 */
@RestController
@RequestMapping("/sys/scheduleLog")
@Slf4j

public class ScheduleJobLogController{
    @Resource
    private ScheduleJobLogService scheduleJobLogService;

    /**
     * 定时任务日志列表
     */
    @RequestMapping("/list")
    public ResponseEntity<?> list(@RequestBody Map<String, Object> params) {
        PageUtils page = scheduleJobLogService.queryPage(params);

        return ResponseEntity.ok(R.ok().put("page", page));
    }

    /**
     * 定时任务日志信息
     */
    @RequestMapping("/info/{logId}")
    public ResponseEntity<?> info(@PathVariable("logId") Long logId) {
        ScheduleJobLogEntity log = scheduleJobLogService.queryById(logId);

        return ResponseEntity.ok(R.ok().put("log", log));
    }
}
