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

import java.util.List;

import com.benyun.project.third.longxiang.domain.BySynMaterialMsg;
import com.benyun.project.third.longxiang.service.IBySynMaterialMsgService;
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.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 2023-12-08
 */
@Controller
@RequestMapping("/system/msg")
public class BySynMaterialMsgController extends BaseController
{
    private String prefix = "system/third/msg";

    @Autowired
    private IBySynMaterialMsgService bySynMaterialMsgService;

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

    /**
     * 查询同步物料回执信息列表
     */
    @RequiresPermissions("system:msg:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BySynMaterialMsg bySynMaterialMsg)
    {
        startPage();
        List<BySynMaterialMsg> list = bySynMaterialMsgService.selectBySynMaterialMsgList(bySynMaterialMsg);
        return getDataTable(list);
    }

    /**
     * 导出同步物料回执信息列表
     */
    @RequiresPermissions("system:msg:export")
    @Log(title = "同步物料回执信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BySynMaterialMsg bySynMaterialMsg)
    {
        List<BySynMaterialMsg> list = bySynMaterialMsgService.selectBySynMaterialMsgList(bySynMaterialMsg);
        ExcelUtil<BySynMaterialMsg> util = new ExcelUtil<BySynMaterialMsg>(BySynMaterialMsg.class);
        return util.exportExcel(list, "同步物料回执信息数据");
    }

    /**
     * 新增同步物料回执信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存同步物料回执信息
     */
    @RequiresPermissions("system:msg:add")
    @Log(title = "同步物料回执信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BySynMaterialMsg bySynMaterialMsg)
    {
        return toAjax(bySynMaterialMsgService.insertBySynMaterialMsg(bySynMaterialMsg));
    }

    /**
     * 修改同步物料回执信息
     */
    @RequiresPermissions("system:msg:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        BySynMaterialMsg bySynMaterialMsg = bySynMaterialMsgService.selectBySynMaterialMsgById(id);
        mmap.put("bySynMaterialMsg", bySynMaterialMsg);
        return prefix + "/edit";
    }

    /**
     * 修改保存同步物料回执信息
     */
    @RequiresPermissions("system:msg:edit")
    @Log(title = "同步物料回执信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BySynMaterialMsg bySynMaterialMsg)
    {
        return toAjax(bySynMaterialMsgService.updateBySynMaterialMsg(bySynMaterialMsg));
    }

    /**
     * 删除同步物料回执信息
     */
    @RequiresPermissions("system:msg:remove")
    @Log(title = "同步物料回执信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(bySynMaterialMsgService.deleteBySynMaterialMsgByIds(ids));
    }
}
