package com.ruoyi.project.ticket.controller;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.ticket.domain.TDelayPermitOther;
import com.ruoyi.project.ticket.service.ITDelayPermitOtherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 延期票附属对象Controller
 *
 * @author ruoyi
 * @date 2021-12-23
 */
@RestController
@RequestMapping("/ehs/other")
public class TDelayPermitOtherController extends BaseController
{
    @Autowired
    private ITDelayPermitOtherService tDelayPermitOtherService;

    /**
     * 查询延期票附属对象列表
     */
    @PreAuthorize("@ss.hasPermi('ehs:other:list')")
    @GetMapping("/list")
    public TableDataInfo list(TDelayPermitOther tDelayPermitOther)
    {
        startPage();
        List<TDelayPermitOther> list = tDelayPermitOtherService.selectTDelayPermitOtherList(tDelayPermitOther);
        return getDataTable(list);
    }

    /**
     * 导出延期票附属对象列表
     */
    @PreAuthorize("@ss.hasPermi('ehs:other:export')")
    @Log(title = "延期票附属对象", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TDelayPermitOther tDelayPermitOther)
    {
        List<TDelayPermitOther> list = tDelayPermitOtherService.selectTDelayPermitOtherList(tDelayPermitOther);
        ExcelUtil<TDelayPermitOther> util = new ExcelUtil<TDelayPermitOther>(TDelayPermitOther.class);
        return util.exportExcel(list, "other");
    }

    /**
     * 获取延期票附属对象详细信息
     */
    @PreAuthorize("@ss.hasPermi('ehs:other:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tDelayPermitOtherService.selectTDelayPermitOtherById(id));
    }

    /**
     * 新增延期票附属对象
     */
    @PreAuthorize("@ss.hasPermi('ehs:other:add')")
    @Log(title = "延期票附属对象", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TDelayPermitOther tDelayPermitOther)
    {
        return toAjax(tDelayPermitOtherService.insertTDelayPermitOther(tDelayPermitOther));
    }

    /**
     * 修改延期票附属对象
     */
    @PreAuthorize("@ss.hasPermi('ehs:other:edit')")
    @Log(title = "延期票附属对象", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TDelayPermitOther tDelayPermitOther)
    {
        return toAjax(tDelayPermitOtherService.updateTDelayPermitOther(tDelayPermitOther));
    }

    /**
     * 删除延期票附属对象
     */
    @PreAuthorize("@ss.hasPermi('ehs:other:remove')")
    @Log(title = "延期票附属对象", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tDelayPermitOtherService.deleteTDelayPermitOtherByIds(ids));
    }
}
