package com.unis.reserveLayout.modular.qualityInspectionOrg.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.unis.common.annotation.CommonLog;
import com.unis.common.pojo.CommonResult;
import com.unis.common.pojo.CommonValidList;
import com.unis.reserveLayout.modular.qualityInspectionOrg.entity.BusinessQcQualityInspection;
import com.unis.reserveLayout.modular.qualityInspectionOrg.entity.BusinessQcQualityInspectionItem;
import com.unis.reserveLayout.modular.qualityInspectionOrg.entity.QualityInspectionOrg;
import com.unis.reserveLayout.modular.qualityInspectionOrg.entity.QualityInspectionWholeDetail;
import com.unis.reserveLayout.modular.qualityInspectionOrg.param.QualityInspectionOrgIdParam;
import com.unis.reserveLayout.modular.qualityInspectionOrg.param.QualityInspectionOrgPageParam;
import com.unis.reserveLayout.modular.qualityInspectionOrg.param.QualityInspectionPageParam;
import com.unis.reserveLayout.modular.qualityInspectionOrg.param.QualityInspectionReportPageParam;
import com.unis.reserveLayout.modular.qualityInspectionOrg.service.QualityInspectionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import java.util.List;

/**
 * @author qingsong.han
 * @description:
 * @create 2024-06-11 17:17
 */
@Api(tags = "质检数据录入")
@ApiSupport(author = "UNIS_TEAM", order = 2)
@RestController
@Validated
@RequestMapping("/qualityInspection")
public class QualityInspectionController {
    @Resource
    private QualityInspectionService qualityInspectionService;

    @ApiOperationSupport(order = 1)
    @ApiOperation("质检数据录入-分页")
    @GetMapping("/pageList")
    public CommonResult<Page<BusinessQcQualityInspection>> pageList(QualityInspectionPageParam pageParam) {
        return CommonResult.data(qualityInspectionService.pageList(pageParam));
    }

    @ApiOperationSupport(order = 2)
    @ApiOperation("质检数据录入-添加")
    @CommonLog("粮食质量管理-添加-质检数据录入")
    @PostMapping("/add")
    public CommonResult<String> add(@RequestBody @Valid BusinessQcQualityInspection param) {
        qualityInspectionService.add(param);
        return CommonResult.ok();
    }

    @ApiOperationSupport(order = 3)
    @ApiOperation("质检数据录入-修改")
    @CommonLog("粮食质量管理-修改-质检数据录入")
    @PostMapping("/edit")
    public CommonResult<String> edit(@RequestBody @Valid BusinessQcQualityInspection param) {
        qualityInspectionService.edit(param);
        return CommonResult.ok();
    }

    @ApiOperationSupport(order = 4)
    @ApiOperation("质检数据录入-删除")
    @CommonLog("删除粮食质量管理-质检数据录入")
    @PostMapping("/delete/{id}")
    public CommonResult<String> delete(@PathVariable("id") Integer id) {
        qualityInspectionService.delete(id);
        return CommonResult.ok();
    }

    @ApiOperationSupport(order = 5)
    @ApiOperation("质检数据录入-详情")
    @GetMapping("/detail/{id}")
    public CommonResult<BusinessQcQualityInspection> detail(@PathVariable("id") Integer id) {
        return CommonResult.data(qualityInspectionService.detail(id));
    }

    @ApiOperationSupport(order = 6)
    @ApiOperation("质检报表查询-分页")
    @GetMapping("/reportPageList")
    public CommonResult<Page<BusinessQcQualityInspection>> reportPageList(QualityInspectionReportPageParam pageParam) {
        return CommonResult.data(qualityInspectionService.reportPageList(pageParam));
    }

}
