package com.ruoyi.web.controller.baseinfo;

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.baseinfo.domain.BaseWorkingprocedureInfo;
import com.ruoyi.baseinfo.service.IBaseWorkingprocedureInfoService;
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 CaesarBao
 * @date 2020-10-22
 */
@Controller
@RequestMapping("/baseinfo/workingprocedureinfo")
public class BaseWorkingprocedureInfoController extends BaseController
{
    private String prefix = "baseinfo/workingprocedureinfo";

    @Autowired
    private IBaseWorkingprocedureInfoService baseWorkingprocedureInfoService;

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

    /**
     * 查询工序基础信息列表
     */
    @RequiresPermissions("baseinfo:workingprocedureinfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BaseWorkingprocedureInfo baseWorkingprocedureInfo)
    {
        startPage();
        List<BaseWorkingprocedureInfo> list = baseWorkingprocedureInfoService.selectBaseWorkingprocedureInfoList(baseWorkingprocedureInfo);
        return getDataTable(list);
    }

    /**
     * 导出工序基础信息列表
     */
    @RequiresPermissions("baseinfo:workingprocedureinfo:export")
    @Log(title = "工序基础信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BaseWorkingprocedureInfo baseWorkingprocedureInfo)
    {
        List<BaseWorkingprocedureInfo> list = baseWorkingprocedureInfoService.selectBaseWorkingprocedureInfoList(baseWorkingprocedureInfo);
        ExcelUtil<BaseWorkingprocedureInfo> util = new ExcelUtil<BaseWorkingprocedureInfo>(BaseWorkingprocedureInfo.class);
        return util.exportExcel(list, "workingprocedureinfo");
    }

    /**
     * 新增工序基础信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存工序基础信息
     */
    @RequiresPermissions("baseinfo:workingprocedureinfo:add")
    @Log(title = "工序基础信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BaseWorkingprocedureInfo baseWorkingprocedureInfo)
    {
        return toAjax(baseWorkingprocedureInfoService.insertBaseWorkingprocedureInfo(baseWorkingprocedureInfo));
    }

    /**
     * 修改工序基础信息
     */
    @GetMapping("/edit/{objid}")
    public String edit(@PathVariable("objid") Long objid, ModelMap mmap)
    {
        BaseWorkingprocedureInfo baseWorkingprocedureInfo = baseWorkingprocedureInfoService.selectBaseWorkingprocedureInfoById(objid);
        mmap.put("baseWorkingprocedureInfo", baseWorkingprocedureInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存工序基础信息
     */
    @RequiresPermissions("baseinfo:workingprocedureinfo:edit")
    @Log(title = "工序基础信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BaseWorkingprocedureInfo baseWorkingprocedureInfo)
    {
        return toAjax(baseWorkingprocedureInfoService.updateBaseWorkingprocedureInfo(baseWorkingprocedureInfo));
    }

    /**
     * 删除工序基础信息
     */
    @RequiresPermissions("baseinfo:workingprocedureinfo:remove")
    @Log(title = "工序基础信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(baseWorkingprocedureInfoService.deleteBaseWorkingprocedureInfoByIds(ids));
    }
}
