package com.ktg.iscs.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ktg.common.annotation.Log;
import com.ktg.common.core.controller.BaseController;
import com.ktg.common.enums.BusinessType;
import com.ktg.common.pojo.CommonResult;
import com.ktg.common.utils.poi.ExcelUtil;
import com.ktg.iscs.domain.IsCheckTask;
import com.ktg.iscs.service.IIsCheckTaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 检查任务Controller
 *
 * @author cgj
 * @date 2024-12-12
 */
@Api(tags = "检查任务")
@RestController
@RequestMapping("/iscs/task")
public class IsCheckTaskController extends BaseController
{
    @Autowired
    private IIsCheckTaskService isCheckTaskService;

    /**
     * 查询检查任务分页
     */
    @ApiOperation("查询检查任务-分页")
    @Parameters({
            @Parameter(name = "page", description = "Page"),
            @Parameter(name = "isCheckTask", description = "实体参数")
    })
    @PreAuthorize("@ss.hasPermi('iscs:task:list')")
    @GetMapping("/getIsCheckTaskPage")
    public CommonResult<Page<IsCheckTask>> getIsCheckTaskPage(Page<IsCheckTask> page, IsCheckTask isCheckTask)
    {
        Page<IsCheckTask> result = isCheckTaskService.page(page, Wrappers.<IsCheckTask>lambdaQuery()
                .orderByDesc(IsCheckTask::getCheckId));
        return CommonResult.success(result);
    }

    /**
     * 导出检查任务列表
     */
    @ApiOperation("导出检查任务列表")
    @Parameter(name = "isCheckTask", description = "实体参数")
    @PreAuthorize("@ss.hasPermi('iscs:task:export')")
    @Log(title = "检查任务", businessType = BusinessType.EXPORT)
    @PostMapping("/exportIsCheckTask")
    public void exportIsCheckTask(HttpServletResponse response, IsCheckTask isCheckTask)
    {
        List<IsCheckTask> list = isCheckTaskService.selectIsCheckTaskList(isCheckTask);
        ExcelUtil<IsCheckTask> util = new ExcelUtil<IsCheckTask>(IsCheckTask.class);
        util.exportExcel(response, list, "检查任务数据");
    }

    /**
     * 获取检查任务详细信息
     */
    @ApiOperation("获取检查任务详细信息")
    @Parameter(name = "checkId", description = "checkId")
    @PreAuthorize("@ss.hasPermi('iscs:task:query')")
    @GetMapping(value = "/selectIsCheckTaskById")
    public CommonResult<IsCheckTask> selectIsCheckTaskById(Long checkId)
    {
        return CommonResult.success(isCheckTaskService.selectIsCheckTaskByCheckId(checkId));
    }

}
