package com.ruoyi.project.invoice.controller;

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.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.invoice.domain.TInvoiceWorkcontent;
import com.ruoyi.project.invoice.service.ITInvoiceWorkcontentService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 预约作业内容Controller
 *
 * @author ruoyi
 * @date 2022-08-26
 */
@RestController
@RequestMapping("/invoice/workcontent")
public class TInvoiceWorkcontentController extends BaseController
{
    @Autowired
    private ITInvoiceWorkcontentService tInvoiceWorkcontentService;

    /**
     * 查询预约作业内容列表
     */
    @PreAuthorize("@ss.hasPermi('invoice:workcontent:list')")
    @GetMapping("/list")
    public TableDataInfo list(TInvoiceWorkcontent tInvoiceWorkcontent)
    {
        startPage();
        List<TInvoiceWorkcontent> list = tInvoiceWorkcontentService.selectTInvoiceWorkcontentList(tInvoiceWorkcontent);
        return getDataTable(list);
    }

    /**
     * 导出预约作业内容列表
     */
    @PreAuthorize("@ss.hasPermi('invoice:workcontent:export')")
    @Log(title = "预约作业内容", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TInvoiceWorkcontent tInvoiceWorkcontent)
    {
        List<TInvoiceWorkcontent> list = tInvoiceWorkcontentService.selectTInvoiceWorkcontentList(tInvoiceWorkcontent);
        ExcelUtil<TInvoiceWorkcontent> util = new ExcelUtil<TInvoiceWorkcontent>(TInvoiceWorkcontent.class);
        return util.exportExcel(list, "workcontent");
    }

    /**
     * 获取预约作业内容详细信息
     */
    @PreAuthorize("@ss.hasPermi('invoice:bookingworkticket:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tInvoiceWorkcontentService.selectTInvoiceWorkcontentById(id));
    }

    /**
     * 根据关联的ID获取预约作业内容详细信息
     */
    @GetMapping(value = "/getWorkcontentBybookingticketId{bookingticketId}")
    public AjaxResult getInfoBybookingticketId(@PathVariable("bookingticketId") Long bookingticketId)
    {
        return AjaxResult.success(tInvoiceWorkcontentService.selectTInvoiceWorkcontentBybookingticketId(bookingticketId));
    }

    /**
     * 新增预约作业内容
     */
    @PreAuthorize("@ss.hasPermi('invoice:workcontent:add')")
    @Log(title = "预约作业内容", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TInvoiceWorkcontent tInvoiceWorkcontent)
    {
        return toAjax(tInvoiceWorkcontentService.insertTInvoiceWorkcontent(tInvoiceWorkcontent));
    }


    /**
     * 修改预约作业内容
     */
    @PreAuthorize("@ss.hasPermi('invoice:bookingworkticket:edit')")
    @Log(title = "预约作业内容", businessType = BusinessType.UPDATE)
    @PutMapping

    public AjaxResult edit(@RequestBody TInvoiceWorkcontent tInvoiceWorkcontent)
    {
        return toAjax(tInvoiceWorkcontentService.updateTInvoiceWorkcontent(tInvoiceWorkcontent));
    }

    /**
     * 删除预约作业内容
     */
    @PreAuthorize("@ss.hasPermi('invoice:workcontent:remove')")
    @Log(title = "预约作业内容", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tInvoiceWorkcontentService.deleteTInvoiceWorkcontentByIds(ids));
    }
}
