package com.zehong.web.controller.checktask;

import java.util.List;
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.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.enums.BusinessType;
import com.zehong.system.domain.TDangerApprovalRecord;
import com.zehong.system.service.ITDangerApprovalRecordService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;

/**
 * 隐患审核记录Controller
 * 
 * @author zehong
 * @date 2026-07-17
 */
@RestController
@RequestMapping("/danger/approval")
public class TDangerApprovalRecordController extends BaseController
{
    @Autowired
    private ITDangerApprovalRecordService tDangerApprovalRecordService;

    /**
     * 查询隐患审核记录列表
     */
   // @PreAuthorize("@ss.hasPermi('danger:approval:list')")
    @GetMapping("/list")
    public TableDataInfo list(TDangerApprovalRecord tDangerApprovalRecord)
    {
        startPage();
        List<TDangerApprovalRecord> list = tDangerApprovalRecordService.selectTDangerApprovalRecordList(tDangerApprovalRecord);
        return getDataTable(list);
    }


    /**
     * 获取所有隐患审核记录
     * @param tDangerApprovalRecord 参数
     * @return
     */
    @GetMapping("/dangerApprovalListInfo")
    public AjaxResult dangerApprovalListInfo(TDangerApprovalRecord tDangerApprovalRecord) {
        List<TDangerApprovalRecord> list = tDangerApprovalRecordService.selectTDangerApprovalRecordList(tDangerApprovalRecord);
        return AjaxResult.success(list);
    }

    /**
     * 导出隐患审核记录列表
     */
   // @PreAuthorize("@ss.hasPermi('danger:approval:export')")
    @Log(title = "隐患审核记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TDangerApprovalRecord tDangerApprovalRecord)
    {
        List<TDangerApprovalRecord> list = tDangerApprovalRecordService.selectTDangerApprovalRecordList(tDangerApprovalRecord);
        ExcelUtil<TDangerApprovalRecord> util = new ExcelUtil<TDangerApprovalRecord>(TDangerApprovalRecord.class);
        return util.exportExcel(list, "隐患审核记录数据");
    }

    /**
     * 获取隐患审核记录详细信息
     */
    //@PreAuthorize("@ss.hasPermi('danger:approval:query')")
    @GetMapping(value = "/{approvalId}")
    public AjaxResult getInfo(@PathVariable("approvalId") Long approvalId)
    {
        return AjaxResult.success(tDangerApprovalRecordService.selectTDangerApprovalRecordById(approvalId));
    }

    /**
     * 新增隐患审核记录
     */
    //@PreAuthorize("@ss.hasPermi('danger:approval:add')")
    @Log(title = "隐患审核记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TDangerApprovalRecord tDangerApprovalRecord)
    {
        return toAjax(tDangerApprovalRecordService.insertTDangerApprovalRecord(tDangerApprovalRecord));
    }

    /**
     * 修改隐患审核记录
     */
    //@PreAuthorize("@ss.hasPermi('danger:approval:edit')")
    @Log(title = "隐患审核记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TDangerApprovalRecord tDangerApprovalRecord)
    {
        return toAjax(tDangerApprovalRecordService.updateTDangerApprovalRecord(tDangerApprovalRecord));
    }

    /**
     * 删除隐患审核记录
     */
    //@PreAuthorize("@ss.hasPermi('danger:approval:remove')")
    @Log(title = "隐患审核记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{approvalIds}")
    public AjaxResult remove(@PathVariable Long[] approvalIds)
    {
        return toAjax(tDangerApprovalRecordService.deleteTDangerApprovalRecordByIds(approvalIds));
    }
}
