package org.jeecg.modules.dynamicStaticAnalysis.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.dynamicStaticAnalysis.dto.AnalysisBatchSaveOrUpdateDTO;
import org.jeecg.modules.dynamicStaticAnalysis.dto.CheckBatchDTO;
import org.jeecg.modules.dynamicStaticAnalysis.entity.AnalysisBatch;
import org.jeecg.modules.dynamicStaticAnalysis.service.IAnalysisBatchService;
import org.jeecg.modules.dynamicStaticAnalysis.vo.CheckBatchVO;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 动静态分析-分析批次表 前端控制器
 * </p>
 *
 * @author hkl
 * @since 2023-07-26
 */
@RestController
@RequestMapping("/dynamicStaticAnalysis/analysisBatch")
@Api("动静态分析-分析批次")
public class AnalysisBatchController extends JeecgController<AnalysisBatch, IAnalysisBatchService> {

    @AutoLog(value = "动静态分析-分析批次-获取检查数据")
    @ApiOperation(value = "动静态分析-分析批次-获取检查数据", notes = "动静态分析-分析批次-获取检查数据")
    @GetMapping(value = "/getCheckData")
    public Result<IPage<CheckBatchVO>> getCheckData(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                    CheckBatchDTO dto) {
        Page<CheckBatchVO> pageData = new Page<>(pageNo, pageSize);
        pageData = this.service.getCheckData(pageData, dto);

        return Result.OK(pageData);
    }


    @AutoLog(value = "动静态分析-分析批次-获取列表数据")
    @ApiOperation(value = "动静态分析-分析批次-获取列表数据", notes = "动静态分析-分析批次-获取列表数据")
    @GetMapping(value = "/listRecord")
    public Result<IPage<CheckBatchVO>> listRecord(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                    CheckBatchDTO dto) {
        Page<CheckBatchVO> pageData = new Page<>(pageNo, pageSize);
        pageData = this.service.getCheckData(pageData, dto);

        return Result.OK(pageData);
    }


    @AutoLog(value = "动静态分析-分析批次-新增分析批次")
    @ApiOperation(value = "动静态分析-分析批次-新增分析批次", notes = "动静态分析-分析批次-新增分析批次")
    @PostMapping(value = "/saveRecord")
    public Result<String> saveRecord(@RequestBody AnalysisBatchSaveOrUpdateDTO dto) {

        this.service.saveRecord(dto);

        return Result.OK("操作成功");
    }


    @AutoLog(value = "动静态分析-分析批次-新增分析批次")
    @ApiOperation(value = "动静态分析-分析批次-新增分析批次", notes = "动静态分析-分析批次-新增分析批次")
    @PostMapping(value = "/updateRecord")
    public Result<String> updateRecord(@RequestBody AnalysisBatchSaveOrUpdateDTO dto) {

        this.service.updateRecord(dto);

        return Result.OK("操作成功");
    }
}
