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.CheckUser;
import com.sundot.airport.check.service.ICheckUserService;
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/checkUser")
public class CheckUserController extends BaseController {
    @Autowired
    private ICheckUserService checkUserService;

    /**
     * 查询检查单检查人员和检查记录责任人和检查记录及问题整改检查项责任人列表
     */
    @PreAuthorize("@ss.hasPermi('check:checkUser:list')")
    @GetMapping("/list")
    public TableDataInfo list(CheckUser checkUser) {
        startPage();
        List<CheckUser> list = checkUserService.selectCheckUserList(checkUser);
        return getDataTable(list);
    }

    /**
     * 导出检查单检查人员和检查记录责任人和检查记录及问题整改检查项责任人列表
     */
    @PreAuthorize("@ss.hasPermi('check:checkUser:export')")
    @Log(title = "检查单检查人员和检查记录责任人和检查记录及问题整改检查项责任人", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CheckUser checkUser) {
        List<CheckUser> list = checkUserService.selectCheckUserList(checkUser);
        ExcelUtil<CheckUser> util = new ExcelUtil<CheckUser>(CheckUser.class);
        util.exportExcel(response, list, "检查单检查人员和检查记录责任人和检查记录及问题整改检查项责任人数据");
    }

    /**
     * 获取检查单检查人员和检查记录责任人和检查记录及问题整改检查项责任人详细信息
     */
    @PreAuthorize("@ss.hasPermi('check:checkUser:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(checkUserService.selectCheckUserById(id));
    }

    /**
     * 新增检查单检查人员和检查记录责任人和检查记录及问题整改检查项责任人
     */
    @PreAuthorize("@ss.hasPermi('check:checkUser:add')")
    @Log(title = "检查单检查人员和检查记录责任人和检查记录及问题整改检查项责任人", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CheckUser checkUser) {
        return toAjax(checkUserService.insertCheckUser(checkUser));
    }

    /**
     * 修改检查单检查人员和检查记录责任人和检查记录及问题整改检查项责任人
     */
    @PreAuthorize("@ss.hasPermi('check:checkUser:edit')")
    @Log(title = "检查单检查人员和检查记录责任人和检查记录及问题整改检查项责任人", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CheckUser checkUser) {
        return toAjax(checkUserService.updateCheckUser(checkUser));
    }

    /**
     * 删除检查单检查人员和检查记录责任人和检查记录及问题整改检查项责任人
     */
    @PreAuthorize("@ss.hasPermi('check:checkUser:remove')")
    @Log(title = "检查单检查人员和检查记录责任人和检查记录及问题整改检查项责任人", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(checkUserService.deleteCheckUserByIds(ids));
    }
}
