package com.zehong.web.controller.safe;

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

/**
 * 工业流程图Controller
 * 
 * @author zehong
 * @date 2026-07-15
 */
@RestController
@RequestMapping("/safe/process")
public class TTechnologyProcessController extends BaseController
{
    @Autowired
    private ITTechnologyProcessService tTechnologyProcessService;

    /**
     * 查询工业流程图列表
     */
    //@PreAuthorize("@ss.hasPermi('safe:process:list')")
    @GetMapping("/list")
    public TableDataInfo list(TTechnologyProcess tTechnologyProcess)
    {
        startPage();
        List<TTechnologyProcess> list = tTechnologyProcessService.selectTTechnologyProcessList(tTechnologyProcess);
        return getDataTable(list);
    }

    /**
     * 导出工业流程图列表
     */
    //@PreAuthorize("@ss.hasPermi('safe:process:export')")
    @Log(title = "工业流程图", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TTechnologyProcess tTechnologyProcess)
    {
        List<TTechnologyProcess> list = tTechnologyProcessService.selectTTechnologyProcessList(tTechnologyProcess);
        ExcelUtil<TTechnologyProcess> util = new ExcelUtil<TTechnologyProcess>(TTechnologyProcess.class);
        return util.exportExcel(list, "工业流程图数据");
    }

    /**
     * 获取工业流程图详细信息
     */
    //@PreAuthorize("@ss.hasPermi('safe:process:query')")
    @GetMapping(value = "/{processId}")
    public AjaxResult getInfo(@PathVariable("processId") Long processId)
    {
        return AjaxResult.success(tTechnologyProcessService.selectTTechnologyProcessById(processId));
    }

    /**
     * 新增工业流程图
     */
    //@PreAuthorize("@ss.hasPermi('safe:process:add')")
    @Log(title = "工业流程图", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TTechnologyProcess tTechnologyProcess)
    {
        return toAjax(tTechnologyProcessService.insertTTechnologyProcess(tTechnologyProcess));
    }

    /**
     * 修改工业流程图
     */
    //@PreAuthorize("@ss.hasPermi('safe:process:edit')")
    @Log(title = "工业流程图", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TTechnologyProcess tTechnologyProcess)
    {
        return toAjax(tTechnologyProcessService.updateTTechnologyProcess(tTechnologyProcess));
    }

    /**
     * 删除工业流程图
     */
    //@PreAuthorize("@ss.hasPermi('safe:process:remove')")
    @Log(title = "工业流程图", businessType = BusinessType.DELETE)
	@DeleteMapping("/{processIds}")
    public AjaxResult remove(@PathVariable Long[] processIds)
    {
        return toAjax(tTechnologyProcessService.deleteTTechnologyProcessByIds(processIds));
    }
}
