package cn.iocoder.yudao.module.configure.controller.admin.inspectionitem;

import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.*;

import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;

import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;

import cn.iocoder.yudao.module.configure.controller.admin.inspectionitem.vo.*;
import cn.iocoder.yudao.module.configure.dal.dataobject.inspectionitem.InspectionItemDO;
import cn.iocoder.yudao.module.configure.convert.inspectionitem.InspectionItemConvert;
import cn.iocoder.yudao.module.configure.service.inspectionitem.InspectionItemService;

@Api(tags = "管理后台 - 检测报告模板检测项目")
@RestController
@RequestMapping("/configure/inspection-item")
@Validated
public class InspectionItemController {

    @Resource
    private InspectionItemService inspectionItemService;

    @GetMapping("/get")
    @ApiOperation("获得检测报告模板检测项目")
    @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
    @PreAuthorize("@ss.hasPermission('configure:inspection-item:query')")
    public CommonResult<InspectionItemRespVO> getInspectionItem(@RequestParam("id") Long id) {
        InspectionItemDO inspectionItem = inspectionItemService.getInspectionItem(id);
        return success(InspectionItemConvert.INSTANCE.convert(inspectionItem));
    }

    @GetMapping("/page")
    @ApiOperation("获得检测报告模板检测项目分页")
    @PreAuthorize("@ss.hasPermission('configure:inspection-item:query')")
    public CommonResult<PageResult<InspectionItemRespVO>> getInspectionItemPage(@Valid InspectionItemPageReqVO pageVO) {
        PageResult<InspectionItemDO> pageResult = inspectionItemService.getInspectionItemPage(pageVO);
        return success(InspectionItemConvert.INSTANCE.convertPage(pageResult));
    }

}
