package com.inspur.web.controller.work;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.inspur.common.annotation.Anonymous;
import com.inspur.domain.ElevatorWorkNode;
import com.inspur.service.IElevatorWorkNodeService;
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.inspur.common.annotation.Log;
import com.inspur.common.core.controller.BaseController;
import com.inspur.common.core.domain.AjaxResult;
import com.inspur.common.enums.BusinessType;
import com.inspur.common.utils.poi.ExcelUtil;
import com.inspur.common.core.page.TableDataInfo;

/**
 * 工单节点信息Controller
 *
 * @author inspur
 * @date 2024-09-18
 */
@RestController
@RequestMapping("/work/node")
public class ElevatorWorkNodeController extends BaseController
{
    @Autowired
    private IElevatorWorkNodeService elevatorWorkNodeService;

    /**
     * 查询工单节点信息列表
     */
    // @PreAuthorize("@ss.hasPermi('work:node:list')")
    @GetMapping("/list")
    @Anonymous
    public TableDataInfo list(ElevatorWorkNode elevatorWorkNode)
    {
        startPage();
        List<ElevatorWorkNode> list = elevatorWorkNodeService.selectElevatorWorkNodeList(elevatorWorkNode);
        return getDataTable(list);
    }

    /**
     * 导出工单节点信息列表
     */
    @PreAuthorize("@ss.hasPermi('work:node:export')")
    @Log(title = "工单节点信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ElevatorWorkNode elevatorWorkNode)
    {
        List<ElevatorWorkNode> list = elevatorWorkNodeService.selectElevatorWorkNodeList(elevatorWorkNode);
        ExcelUtil<ElevatorWorkNode> util = new ExcelUtil<ElevatorWorkNode>(ElevatorWorkNode.class);
        util.exportExcel(response, list, "工单节点信息数据");
    }

    /**
     * 获取工单节点信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('work:node:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(elevatorWorkNodeService.selectElevatorWorkNodeById(id));
    }

    /**
     * 新增工单节点信息
     */
    @PreAuthorize("@ss.hasPermi('work:node:add')")
    @Log(title = "工单节点信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ElevatorWorkNode elevatorWorkNode)
    {
        return toAjax(elevatorWorkNodeService.insertElevatorWorkNode(elevatorWorkNode));
    }

    /**
     * 修改工单节点信息
     */
    @PreAuthorize("@ss.hasPermi('work:node:edit')")
    @Log(title = "工单节点信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ElevatorWorkNode elevatorWorkNode)
    {
        return toAjax(elevatorWorkNodeService.updateElevatorWorkNode(elevatorWorkNode));
    }

    /**
     * 删除工单节点信息
     */
    @PreAuthorize("@ss.hasPermi('work:node:remove')")
    @Log(title = "工单节点信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(elevatorWorkNodeService.deleteElevatorWorkNodeByIds(ids));
    }
}
