package com.zehong.web.controller.risk;

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.TIssueRectification;
import com.zehong.system.service.ITIssueRectificationService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;

/**
 * 风险点隐患及异常情况Controller
 *
 * @author zehong
 * @date 2026-03-20
 */
@RestController
@RequestMapping("/system/rectification")
public class TIssueRectificationController extends BaseController
{
    @Autowired
    private ITIssueRectificationService tIssueRectificationService;

    /**
     * 查询风险点隐患及异常情况列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TIssueRectification tIssueRectification)
    {
        startPage();
        List<TIssueRectification> list = tIssueRectificationService.selectTIssueRectificationList(tIssueRectification);
        return getDataTable(list);
    }

    /**
     * 导出风险点隐患及异常情况列表
     */
    @Log(title = "风险点隐患及异常情况", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TIssueRectification tIssueRectification)
    {
        List<TIssueRectification> list = tIssueRectificationService.selectTIssueRectificationList(tIssueRectification);
        ExcelUtil<TIssueRectification> util = new ExcelUtil<TIssueRectification>(TIssueRectification.class);
        return util.exportExcel(list, "风险点隐患及异常情况数据");
    }

    /**
     * 获取风险点隐患及异常情况详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tIssueRectificationService.selectTIssueRectificationById(id));
    }

    /**
     * 新增风险点隐患及异常情况
     */
    @Log(title = "风险点隐患及异常情况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TIssueRectification tIssueRectification)
    {
        return toAjax(tIssueRectificationService.insertTIssueRectification(tIssueRectification));
    }

    /**
     * 修改风险点隐患及异常情况
     */
    @Log(title = "风险点隐患及异常情况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TIssueRectification tIssueRectification)
    {
        return toAjax(tIssueRectificationService.updateTIssueRectification(tIssueRectification));
    }

    /**
     * 删除风险点隐患及异常情况
     */
    @Log(title = "风险点隐患及异常情况", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tIssueRectificationService.deleteTIssueRectificationByIds(ids));
    }
}