package com.sundot.airport.web.controller.check;

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

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sundot.airport.common.annotation.Log;
import com.sundot.airport.common.core.controller.BaseController;
import com.sundot.airport.common.core.domain.AjaxResult;
import com.sundot.airport.common.enums.BusinessType;
import com.sundot.airport.check.domain.CheckProjectItem;
import com.sundot.airport.check.service.ICheckProjectItemService;
import com.sundot.airport.common.utils.poi.ExcelUtil;
import com.sundot.airport.common.core.page.TableDataInfo;

/**
 * 检查单和检查记录和问题整改的检查项明细Controller
 *
 * @author ruoyi
 * @date 2025-07-11
 */
@RestController
@RequestMapping("/check/projectItem")
public class CheckProjectItemController extends BaseController {
    @Autowired
    private ICheckProjectItemService checkProjectItemService;

    /**
     * 查询检查单和检查记录和问题整改的检查项明细列表
     */
    @PreAuthorize("@ss.hasPermi('check:projectItem:list')")
    @GetMapping("/list")
    public TableDataInfo list(CheckProjectItem checkProjectItem) {
        startPage();
        List<CheckProjectItem> list = checkProjectItemService.selectCheckProjectItemList(checkProjectItem);
        return getDataTable(list);
    }

    /**
     * 导出检查单和检查记录和问题整改的检查项明细列表
     */
    @PreAuthorize("@ss.hasPermi('check:projectItem:export')")
    @Log(title = "检查单和检查记录和问题整改的检查项明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CheckProjectItem checkProjectItem) {
        List<CheckProjectItem> list = checkProjectItemService.selectCheckProjectItemList(checkProjectItem);
        ExcelUtil<CheckProjectItem> util = new ExcelUtil<CheckProjectItem>(CheckProjectItem.class);
        util.exportExcel(response, list, "检查单和检查记录和问题整改的检查项明细数据");
    }

    /**
     * 获取检查单和检查记录和问题整改的检查项明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('check:projectItem:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(checkProjectItemService.selectCheckProjectItemById(id));
    }

    /**
     * 新增检查单和检查记录和问题整改的检查项明细
     */
    @PreAuthorize("@ss.hasPermi('check:projectItem:add')")
    @Log(title = "检查单和检查记录和问题整改的检查项明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CheckProjectItem checkProjectItem) {
        return toAjax(checkProjectItemService.insertCheckProjectItem(checkProjectItem));
    }

    /**
     * 修改检查单和检查记录和问题整改的检查项明细
     */
    @PreAuthorize("@ss.hasPermi('check:projectItem:edit')")
    @Log(title = "检查单和检查记录和问题整改的检查项明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CheckProjectItem checkProjectItem) {
        return toAjax(checkProjectItemService.updateCheckProjectItem(checkProjectItem));
    }

    /**
     * 删除检查单和检查记录和问题整改的检查项明细
     */
    @PreAuthorize("@ss.hasPermi('check:projectItem:remove')")
    @Log(title = "检查单和检查记录和问题整改的检查项明细", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(checkProjectItemService.deleteCheckProjectItemByIds(ids));
    }
}
