package com.ruoyi.web.controller.work;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WorkOrderFj;
import com.ruoyi.system.service.IWorkOrderFjService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工单_附件Controller
 * 
 * @author ruoyi
 * @date 2025-05-12
 */
@RestController
@RequestMapping("/work/fj")
public class WorkOrderFjController extends BaseController
{
    @Autowired
    private IWorkOrderFjService workOrderFjService;

    /**
     * 查询工单_附件列表
     */
    @PreAuthorize("@ss.hasPermi('work:fj:list')")
    @GetMapping("/list")
    public TableDataInfo list(WorkOrderFj workOrderFj)
    {
        startPage();
        List<WorkOrderFj> list = workOrderFjService.selectWorkOrderFjList(workOrderFj);
        return getDataTable(list);
    }

    /**
     * 导出工单_附件列表
     */
    @PreAuthorize("@ss.hasPermi('work:fj:export')")
    @Log(title = "工单_附件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WorkOrderFj workOrderFj)
    {
        List<WorkOrderFj> list = workOrderFjService.selectWorkOrderFjList(workOrderFj);
        ExcelUtil<WorkOrderFj> util = new ExcelUtil<WorkOrderFj>(WorkOrderFj.class);
        util.exportExcel(response, list, "工单_附件数据");
    }

    /**
     * 获取工单_附件详细信息
     */
    @PreAuthorize("@ss.hasPermi('work:fj:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(workOrderFjService.selectWorkOrderFjById(id));
    }

    /**
     * 新增工单_附件
     */
    @PreAuthorize("@ss.hasPermi('work:fj:add')")
    @Log(title = "工单_附件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WorkOrderFj workOrderFj)
    {
        return toAjax(workOrderFjService.insertWorkOrderFj(workOrderFj));
    }

    /**
     * 修改工单_附件
     */
    @PreAuthorize("@ss.hasPermi('work:fj:edit')")
    @Log(title = "工单_附件", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody WorkOrderFj workOrderFj)
    {
        return toAjax(workOrderFjService.updateWorkOrderFj(workOrderFj));
    }

    /**
     * 删除工单_附件
     */
    @PreAuthorize("@ss.hasPermi('work:fj:remove')")
    @Log(title = "工单_附件", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(workOrderFjService.deleteWorkOrderFjByIds(ids));
    }
}
