package cn.lihongjie.coal.cronJobLog.controller;

import cn.lihongjie.coal.annotation.SysLog;
import cn.lihongjie.coal.base.dto.CommonQuery;
import cn.lihongjie.coal.base.dto.IdRequest;
import cn.lihongjie.coal.cronJobLog.dto.CreateCronJobLogDto;
import cn.lihongjie.coal.cronJobLog.dto.CronJobLogDto;
import cn.lihongjie.coal.cronJobLog.dto.UpdateCronJobLogDto;
import cn.lihongjie.coal.cronJobLog.service.CronJobLogService;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/cronJobLog")
@SysLog(
    module = "定时任务日志"
)
@Slf4j
public class CronJobLogController {
  @Autowired
  private CronJobLogService service;

  @PostMapping("/create")
  public CronJobLogDto create(@RequestBody CreateCronJobLogDto request) {
    return this.service.create(request)
        ;
  }

  @PostMapping("/update")
  public CronJobLogDto update(@RequestBody UpdateCronJobLogDto request) {
    return this.service.update(request)
        ;
  }

  @PostMapping("/delete")
  public Object delete(@RequestBody IdRequest request) {
    this.service.delete(request);
        return true
        ;
  }

  @PostMapping("/getById")
  public CronJobLogDto getById(@RequestBody IdRequest request) {
    return this.service.getById(request.getId())
        ;
  }

  @PostMapping("/list")
  public Page<CronJobLogDto> list(@RequestBody CommonQuery request) {
    return this.service.list(request)
        ;
  }
}
