package com.zehong.web.controller.safe;

import com.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.core.page.TableDataInfo;
import com.zehong.common.enums.BusinessType;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.system.domain.TSafeInspectLedger;
import com.zehong.system.service.ITSafeInspectLedgerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 安全检查台账Controller
 * 
 * @author zehong
 * @date 2026-03-27
 */
@RestController
@RequestMapping("/safe/inspect")
public class TSafeInspectLedgerController extends BaseController
{
    @Autowired
    private ITSafeInspectLedgerService tSafeInspectLedgerService;

    /**
     * 查询安全检查台账列表
     */
    //@PreAuthorize("@ss.hasPermi('system:ledger:list')")
    @GetMapping("/list")
    public TableDataInfo list(TSafeInspectLedger tSafeInspectLedger)
    {
        startPage();
        List<TSafeInspectLedger> list = tSafeInspectLedgerService.selectTSafeInspectLedgerList(tSafeInspectLedger);
        return getDataTable(list);
    }

    /**
     * 导出安全检查台账列表
     */
    //@PreAuthorize("@ss.hasPermi('system:ledger:export')")
    @Log(title = "安全检查台账", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TSafeInspectLedger tSafeInspectLedger)
    {
        List<TSafeInspectLedger> list = tSafeInspectLedgerService.selectTSafeInspectLedgerList(tSafeInspectLedger);
        ExcelUtil<TSafeInspectLedger> util = new ExcelUtil<TSafeInspectLedger>(TSafeInspectLedger.class);
        return util.exportExcel(list, "安全检查台账数据");
    }

    /**
     * 获取安全检查台账详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:ledger:query')")
    @GetMapping(value = "/{inspectId}")
    public AjaxResult getInfo(@PathVariable("inspectId") Long inspectId)
    {
        return AjaxResult.success(tSafeInspectLedgerService.selectTSafeInspectLedgerById(inspectId));
    }

    /**
     * 新增安全检查台账
     */
    //@PreAuthorize("@ss.hasPermi('system:ledger:add')")
    @Log(title = "安全检查台账", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TSafeInspectLedger tSafeInspectLedger)
    {
        return toAjax(tSafeInspectLedgerService.insertTSafeInspectLedger(tSafeInspectLedger));
    }

    /**
     * 修改安全检查台账
     */
    //@PreAuthorize("@ss.hasPermi('system:ledger:edit')")
    @Log(title = "安全检查台账", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TSafeInspectLedger tSafeInspectLedger)
    {
        return toAjax(tSafeInspectLedgerService.updateTSafeInspectLedger(tSafeInspectLedger));
    }

    /**
     * 删除安全检查台账
     */
    //@PreAuthorize("@ss.hasPermi('system:ledger:remove')")
    @Log(title = "安全检查台账", businessType = BusinessType.DELETE)
	@DeleteMapping("/{inspectIds}")
    public AjaxResult remove(@PathVariable Long[] inspectIds)
    {
        return toAjax(tSafeInspectLedgerService.deleteTSafeInspectLedgerByIds(inspectIds));
    }
}
