package com.ruoyi.web.controller.nanjing;

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.nanjing.domain.TBdSubstation;
import com.ruoyi.nanjing.service.ITBdSubstationService;
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 limy
 * @date 2021-01-22
 */
@Controller
@RequestMapping("/nanjing/SubStation")
public class TBdSubstationController extends BaseController
{
    private String prefix = "nanjing/SubStation";

    @Autowired
    private ITBdSubstationService tBdSubstationService;

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

    /**
     * 查询工位管理列表
     */
    @RequiresPermissions("nanjing:SubStation:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TBdSubstation tBdSubstation)
    {
        startPage();
        List<TBdSubstation> list = tBdSubstationService.selectTBdSubstationList(tBdSubstation);
        return getDataTable(list);
    }

    /**
     * 导出工位管理列表
     */
    @RequiresPermissions("nanjing:SubStation:export")
    @Log(title = "工位管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TBdSubstation tBdSubstation)
    {
        List<TBdSubstation> list = tBdSubstationService.selectTBdSubstationList(tBdSubstation);
        ExcelUtil<TBdSubstation> util = new ExcelUtil<TBdSubstation>(TBdSubstation.class);
        return util.exportExcel(list, "SubStation");
    }

    /**
     * 新增工位管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存工位管理
     */
    @RequiresPermissions("nanjing:SubStation:add")
    @Log(title = "工位管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TBdSubstation tBdSubstation)
    {
        return toAjax(tBdSubstationService.insertTBdSubstation(tBdSubstation));
    }

    /**
     * 修改工位管理
     */
    @GetMapping("/edit/{ID}")
    public String edit(@PathVariable("ID") Long ID, ModelMap mmap)
    {
        TBdSubstation tBdSubstation = tBdSubstationService.selectTBdSubstationById(ID);
        mmap.put("tBdSubstation", tBdSubstation);
        return prefix + "/edit";
    }

    /**
     * 修改保存工位管理
     */
    @RequiresPermissions("nanjing:SubStation:edit")
    @Log(title = "工位管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TBdSubstation tBdSubstation)
    {
        return toAjax(tBdSubstationService.updateTBdSubstation(tBdSubstation));
    }

    /**
     * 删除工位管理
     */
    @RequiresPermissions("nanjing:SubStation:remove")
    @Log(title = "工位管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tBdSubstationService.deleteTBdSubstationByIds(ids));
    }
}
