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.TBdLinetype;
import com.ruoyi.nanjing.service.ITBdLinetypeService;
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/LineType")
public class TBdLinetypeController extends BaseController
{
    private String prefix = "nanjing/LineType";

    @Autowired
    private ITBdLinetypeService tBdLinetypeService;

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

    /**
     * 查询主支线管理列表
     */
    @RequiresPermissions("nanjing:LineType:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TBdLinetype tBdLinetype)
    {
        startPage();
        List<TBdLinetype> list = tBdLinetypeService.selectTBdLinetypeList(tBdLinetype);
        return getDataTable(list);
    }

    /**
     * 导出主支线管理列表
     */
    @RequiresPermissions("nanjing:LineType:export")
    @Log(title = "主支线管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TBdLinetype tBdLinetype)
    {
        List<TBdLinetype> list = tBdLinetypeService.selectTBdLinetypeList(tBdLinetype);
        ExcelUtil<TBdLinetype> util = new ExcelUtil<TBdLinetype>(TBdLinetype.class);
        return util.exportExcel(list, "LineType");
    }

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

    /**
     * 新增保存主支线管理
     */
    @RequiresPermissions("nanjing:LineType:add")
    @Log(title = "主支线管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TBdLinetype tBdLinetype)
    {
        return toAjax(tBdLinetypeService.insertTBdLinetype(tBdLinetype));
    }

    /**
     * 修改主支线管理
     */
    @GetMapping("/edit/{LineID}")
    public String edit(@PathVariable("LineID") Long LineID, ModelMap mmap)
    {
        TBdLinetype tBdLinetype = tBdLinetypeService.selectTBdLinetypeById(LineID);
        mmap.put("tBdLinetype", tBdLinetype);
        return prefix + "/edit";
    }

    /**
     * 修改保存主支线管理
     */
    @RequiresPermissions("nanjing:LineType:edit")
    @Log(title = "主支线管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TBdLinetype tBdLinetype)
    {
        return toAjax(tBdLinetypeService.updateTBdLinetype(tBdLinetype));
    }

    /**
     * 删除主支线管理
     */
    @RequiresPermissions("nanjing:LineType:remove")
    @Log(title = "主支线管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tBdLinetypeService.deleteTBdLinetypeByIds(ids));
    }
}
