package com.iailab.module.model.mcs.sche.controller.admin;

import com.iailab.framework.common.pojo.CommonResult;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.common.util.object.BeanUtils;
import com.iailab.module.model.mcs.sche.entity.StScheduleRecordEntity;
import com.iailab.module.model.mcs.sche.vo.StScheduleRecordPageReqVO;
import com.iailab.module.model.mcs.sche.vo.StScheduleRecordRespVO;
import com.iailab.module.model.mcs.sche.service.StScheduleRecordService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

import static com.iailab.framework.common.pojo.CommonResult.success;

/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年12月25日
 */
@Tag(name = "模型服务 - 调度记录")
@RestController
@RequestMapping("/model/sche/record")
public class StScheduleRecordController {

    @Autowired
    private StScheduleRecordService stScheduleRecordService;

    @GetMapping("/get")
    @Operation(summary = "获得调度记录")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('sche:record:query')")
    public CommonResult<StScheduleRecordRespVO> getInfo(@RequestParam("id") String id) {
        StScheduleRecordRespVO respVO = stScheduleRecordService.getInfo(id);
        return success(respVO);
    }

    @GetMapping("/page")
    @Operation(summary = "获得调度记录分页")
    @PreAuthorize("@ss.hasPermission('sche:record:query')")
    public CommonResult<PageResult<StScheduleRecordRespVO>> getPage(@Valid StScheduleRecordPageReqVO pageVO) {
        PageResult<StScheduleRecordEntity> pageResult = stScheduleRecordService.page(pageVO);
        return success(BeanUtils.toBean(pageResult, StScheduleRecordRespVO.class));
    }
}