package com.ruoyi.web.controller.business;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.TEbsOrderBak;
import com.ruoyi.business.service.ITEbsOrderBakService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 流水历史表Controller
 *
 * @author wms
 * @date 2025-02-26
 */
@Controller
@RequestMapping("/business/tEbsOrderbak")
public class TEbsOrderBakController extends BaseController
{
    private String prefix = "business/tEbsOrderbak";

    @Autowired
    private ITEbsOrderBakService tEbsOrderBakService;

    @RequiresPermissions("business:tEbsOrderbak:view")
    @GetMapping()
    public String tEbsOrderbak()
    {
        return prefix + "/tEbsOrderbak";
    }

    /**
     * 查询流水历史表列表
     */
    @RequiresPermissions("business:tEbsOrderbak:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TEbsOrderBak tEbsOrderBak)
    {
        startPage();
        List<TEbsOrderBak> list = tEbsOrderBakService.selectTEbsOrderBakList(tEbsOrderBak);
        return getDataTable(list);
    }

    /**
     * 导出流水历史表列表
     */
    @RequiresPermissions("business:tEbsOrderbak:export")
    @Log(title = "流水历史表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TEbsOrderBak tEbsOrderBak)
    {
        List<TEbsOrderBak> list = tEbsOrderBakService.selectTEbsOrderBakList(tEbsOrderBak);
        ExcelUtil<TEbsOrderBak> util = new ExcelUtil<TEbsOrderBak>(TEbsOrderBak.class);
        return util.exportExcel(list, "流水历史表数据");
    }

    /**
     * 新增流水历史表
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存流水历史表
     */
    @RequiresPermissions("business:tEbsOrderbak:add")
    @Log(title = "流水历史表", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TEbsOrderBak tEbsOrderBak)
    {
        return toAjax(tEbsOrderBakService.insertTEbsOrderBak(tEbsOrderBak));
    }

    /**
     * 修改流水历史表
     */
    @RequiresPermissions("business:tEbsOrderbak:edit")
    @GetMapping("/edit/{phasegment1}")
    public String edit(@PathVariable("phasegment1") String phasegment1, ModelMap mmap)
    {
        TEbsOrderBak tEbsOrderBak = tEbsOrderBakService.selectTEbsOrderBakByPhasegment1(phasegment1);
        mmap.put("tEbsOrderBak", tEbsOrderBak);
        return prefix + "/edit";
    }

    /**
     * 修改保存流水历史表
     */
    @RequiresPermissions("business:tEbsOrderbak:edit")
    @Log(title = "流水历史表", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TEbsOrderBak tEbsOrderBak)
    {
        return toAjax(tEbsOrderBakService.updateTEbsOrderBak(tEbsOrderBak));
    }

    /**
     * 删除流水历史表
     */
    @RequiresPermissions("business:tEbsOrderbak:remove")
    @Log(title = "流水历史表", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tEbsOrderBakService.deleteTEbsOrderBakByPhasegment1s(ids));
    }
}
