package com.njzscloud.common.sichen.controller;

import com.njzscloud.common.core.utils.R;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.common.sichen.pojo.entity.TaskExecuteLogEntity;
import com.njzscloud.common.sichen.pojo.param.SearchTaskExecuteLogParam;
import com.njzscloud.common.sichen.service.TaskExecuteLogService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 任务执行日志表
 */
@Slf4j
@RestController
@RequestMapping("/task_execute_log")
@RequiredArgsConstructor
public class TaskExecuteLogController {
    private final TaskExecuteLogService taskExecuteLogService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody TaskExecuteLogEntity taskExecuteLogEntity) {
        taskExecuteLogService.add(taskExecuteLogEntity);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody TaskExecuteLogEntity taskExecuteLogEntity) {
        taskExecuteLogService.modify(taskExecuteLogEntity);
        return R.success();
    }

    /**
     * 删除
     */
    @PostMapping("/del")
    public R<?> del(@RequestBody List<Long> ids) {
        taskExecuteLogService.del(ids);
        return R.success();
    }

    /**
     * 详情
     */
    @GetMapping("/detail")
    public R<TaskExecuteLogEntity> detail(@RequestParam("id") Long id) {
        return R.success(taskExecuteLogService.detail(id));
    }

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<TaskExecuteLogEntity>> paging(PageParam pageParam, SearchTaskExecuteLogParam searchTaskExecuteLogParam) {
        return R.success(taskExecuteLogService.paging(pageParam, searchTaskExecuteLogParam));
    }
}
