package com.benyun.project.third.TransferDirect.controller;

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.benyun.framework.aspectj.lang.annotation.Log;
import com.benyun.framework.aspectj.lang.enums.BusinessType;
import com.benyun.project.third.TransferDirect.domain.KingdeeTransferDirect;
import com.benyun.project.third.TransferDirect.service.IKingdeeTransferDirectService;
import com.benyun.framework.web.controller.BaseController;
import com.benyun.framework.web.domain.AjaxResult;
import com.benyun.common.utils.poi.ExcelUtil;
import com.benyun.framework.web.page.TableDataInfo;

/**
 * 金蝶直接调拨单Controller
 *
 * @author benyun
 * @date 2024-01-04
 */
@Controller
@RequestMapping("/system/TransferDirect")
public class KingdeeTransferDirectController extends BaseController
{
    private String prefix = "system/third/TransferDirect";

    @Autowired
    private IKingdeeTransferDirectService kingdeeTransferDirectService;

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

    /**
     * 查询金蝶直接调拨单列表
     */
    @RequiresPermissions("system:TransferDirect:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(KingdeeTransferDirect kingdeeTransferDirect)
    {
        startPage();
        List<KingdeeTransferDirect> list = kingdeeTransferDirectService.selectKingdeeTransferDirectList(kingdeeTransferDirect);
        return getDataTable(list);
    }

    /**
     * 导出金蝶直接调拨单列表
     */
    @RequiresPermissions("system:TransferDirect:export")
    @Log(title = "金蝶直接调拨单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(KingdeeTransferDirect kingdeeTransferDirect)
    {
        List<KingdeeTransferDirect> list = kingdeeTransferDirectService.selectKingdeeTransferDirectList(kingdeeTransferDirect);
        ExcelUtil<KingdeeTransferDirect> util = new ExcelUtil<KingdeeTransferDirect>(KingdeeTransferDirect.class);
        return util.exportExcel(list, "金蝶直接调拨单数据");
    }

    /**
     * 新增金蝶直接调拨单
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存金蝶直接调拨单
     */
    @RequiresPermissions("system:TransferDirect:add")
    @Log(title = "金蝶直接调拨单", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(KingdeeTransferDirect kingdeeTransferDirect)
    {
        return toAjax(kingdeeTransferDirectService.insertKingdeeTransferDirect(kingdeeTransferDirect));
    }

    /**
     * 修改金蝶直接调拨单
     */
    @RequiresPermissions("system:TransferDirect:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        KingdeeTransferDirect kingdeeTransferDirect = kingdeeTransferDirectService.selectKingdeeTransferDirectById(id);
        mmap.put("kingdeeTransferDirect", kingdeeTransferDirect);
        return prefix + "/edit";
    }

    /**
     * 修改保存金蝶直接调拨单
     */
    @RequiresPermissions("system:TransferDirect:edit")
    @Log(title = "金蝶直接调拨单", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(KingdeeTransferDirect kingdeeTransferDirect)
    {
        return toAjax(kingdeeTransferDirectService.updateKingdeeTransferDirect(kingdeeTransferDirect));
    }

    /**
     * 删除金蝶直接调拨单
     */
    @RequiresPermissions("system:TransferDirect:remove")
    @Log(title = "金蝶直接调拨单", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(kingdeeTransferDirectService.deleteKingdeeTransferDirectByIds(ids));
    }
}
