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.TSafeMeetingLedger;
import com.zehong.system.service.ITSafeMeetingLedgerService;
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/meeting")
public class TSafeMeetingLedgerController extends BaseController
{
    @Autowired
    private ITSafeMeetingLedgerService tSafeMeetingLedgerService;

    /**
     * 查询安全例会台账列表
     */
    //@PreAuthorize("@ss.hasPermi('system:ledger:list')")
    @GetMapping("/list")
    public TableDataInfo list(TSafeMeetingLedger tSafeMeetingLedger)
    {
        startPage();
        List<TSafeMeetingLedger> list = tSafeMeetingLedgerService.selectTSafeMeetingLedgerList(tSafeMeetingLedger);
        return getDataTable(list);
    }

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

    /**
     * 获取安全例会台账详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:ledger:query')")
    @GetMapping(value = "/{meetingId}")
    public AjaxResult getInfo(@PathVariable("meetingId") Long meetingId)
    {
        return AjaxResult.success(tSafeMeetingLedgerService.selectTSafeMeetingLedgerById(meetingId));
    }

    /**
     * 新增安全例会台账
     */
    //@PreAuthorize("@ss.hasPermi('system:ledger:add')")
    @Log(title = "安全例会台账", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TSafeMeetingLedger tSafeMeetingLedger)
    {
        return toAjax(tSafeMeetingLedgerService.insertTSafeMeetingLedger(tSafeMeetingLedger));
    }

    /**
     * 修改安全例会台账
     */
    //@PreAuthorize("@ss.hasPermi('system:ledger:edit')")
    @Log(title = "安全例会台账", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TSafeMeetingLedger tSafeMeetingLedger)
    {
        return toAjax(tSafeMeetingLedgerService.updateTSafeMeetingLedger(tSafeMeetingLedger));
    }

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