package com.benyun.project.third.kingdeeStockconfig.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.kingdeeStockconfig.domain.KingdeeStockConfig;
import com.benyun.project.third.kingdeeStockconfig.service.IKingdeeStockConfigService;
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/kingdeeStockconfig")
public class KingdeeStockConfigController extends BaseController
{
    private String prefix = "system/third/kingdeeStockconfig";

    @Autowired
    private IKingdeeStockConfigService kingdeeStockConfigService;

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

    /**
     * 查询金蝶仓库配置信息列表
     */
    @RequiresPermissions("system:kingdeeStockconfig:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(KingdeeStockConfig kingdeeStockConfig)
    {
        startPage();
        List<KingdeeStockConfig> list = kingdeeStockConfigService.selectKingdeeStockConfigList(kingdeeStockConfig);
        return getDataTable(list);
    }

    /**
     * 导出金蝶仓库配置信息列表
     */
    @RequiresPermissions("system:kingdeeStockconfig:export")
    @Log(title = "金蝶仓库配置信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(KingdeeStockConfig kingdeeStockConfig)
    {
        List<KingdeeStockConfig> list = kingdeeStockConfigService.selectKingdeeStockConfigList(kingdeeStockConfig);
        ExcelUtil<KingdeeStockConfig> util = new ExcelUtil<KingdeeStockConfig>(KingdeeStockConfig.class);
        return util.exportExcel(list, "金蝶仓库配置信息数据");
    }

    /**
     * 新增金蝶仓库配置信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存金蝶仓库配置信息
     */
    @RequiresPermissions("system:kingdeeStockconfig:add")
    @Log(title = "金蝶仓库配置信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(KingdeeStockConfig kingdeeStockConfig)
    {
        return toAjax(kingdeeStockConfigService.insertKingdeeStockConfig(kingdeeStockConfig));
    }

    /**
     * 修改金蝶仓库配置信息
     */
    @RequiresPermissions("system:kingdeeStockconfig:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        KingdeeStockConfig kingdeeStockConfig = kingdeeStockConfigService.selectKingdeeStockConfigById(id);
        mmap.put("kingdeeStockConfig", kingdeeStockConfig);
        return prefix + "/edit";
    }

    /**
     * 修改保存金蝶仓库配置信息
     */
    @RequiresPermissions("system:kingdeeStockconfig:edit")
    @Log(title = "金蝶仓库配置信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(KingdeeStockConfig kingdeeStockConfig)
    {
        return toAjax(kingdeeStockConfigService.updateKingdeeStockConfig(kingdeeStockConfig));
    }

    /**
     * 删除金蝶仓库配置信息
     */
    @RequiresPermissions("system:kingdeeStockconfig:remove")
    @Log(title = "金蝶仓库配置信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(kingdeeStockConfigService.deleteKingdeeStockConfigByIds(ids));
    }


    /**
     * 同步金蝶仓库配置信息
     */
    @Log(title = "同步金蝶仓库配置信息", businessType = BusinessType.UPDATE)
    @PostMapping( "/sync")
    @ResponseBody
    public AjaxResult sync()
    {
        return toAjax(kingdeeStockConfigService.syncKingdeeStockConfig());
    }
}
