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.TBdStationtype;
import com.ruoyi.nanjing.service.ITBdStationtypeService;
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/StationType")
public class TBdStationtypeController extends BaseController
{
    private String prefix = "nanjing/StationType";

    @Autowired
    private ITBdStationtypeService tBdStationtypeService;

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

    /**
     * 查询工位类型列表
     */
    @RequiresPermissions("nanjing:StationType:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TBdStationtype tBdStationtype)
    {
        startPage();
        List<TBdStationtype> list = tBdStationtypeService.selectTBdStationtypeList(tBdStationtype);
        return getDataTable(list);
    }

    /**
     * 导出工位类型列表
     */
    @RequiresPermissions("nanjing:StationType:export")
    @Log(title = "工位类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TBdStationtype tBdStationtype)
    {
        List<TBdStationtype> list = tBdStationtypeService.selectTBdStationtypeList(tBdStationtype);
        ExcelUtil<TBdStationtype> util = new ExcelUtil<TBdStationtype>(TBdStationtype.class);
        return util.exportExcel(list, "StationType");
    }

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

    /**
     * 新增保存工位类型
     */
    @RequiresPermissions("nanjing:StationType:add")
    @Log(title = "工位类型", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TBdStationtype tBdStationtype)
    {
        return toAjax(tBdStationtypeService.insertTBdStationtype(tBdStationtype));
    }

    /**
     * 修改工位类型
     */
    @GetMapping("/edit/{ID}")
    public String edit(@PathVariable("ID") Long ID, ModelMap mmap)
    {
        TBdStationtype tBdStationtype = tBdStationtypeService.selectTBdStationtypeById(ID);
        mmap.put("tBdStationtype", tBdStationtype);
        return prefix + "/edit";
    }

    /**
     * 修改保存工位类型
     */
    @RequiresPermissions("nanjing:StationType:edit")
    @Log(title = "工位类型", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TBdStationtype tBdStationtype)
    {
        return toAjax(tBdStationtypeService.updateTBdStationtype(tBdStationtype));
    }

    /**
     * 删除工位类型
     */
    @RequiresPermissions("nanjing:StationType:remove")
    @Log(title = "工位类型", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tBdStationtypeService.deleteTBdStationtypeByIds(ids));
    }
}
