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.BaseShiftInfo;
import com.ruoyi.baseinfo.service.IBaseShiftInfoService;
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-20
 */
@Controller
@RequestMapping("/baseinfo/shiftinfo")
public class BaseShiftInfoController extends BaseController
{
    private String prefix = "baseinfo/shiftinfo";

    @Autowired
    private IBaseShiftInfoService baseShiftInfoService;

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

    /**
     * 查询班次基础信息列表
     */
    @RequiresPermissions("baseinfo:shiftinfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BaseShiftInfo baseShiftInfo)
    {
        startPage();
        List<BaseShiftInfo> list = baseShiftInfoService.selectBaseShiftInfoList(baseShiftInfo);
        return getDataTable(list);
    }

    /**
     * 导出班次基础信息列表
     */
    @RequiresPermissions("baseinfo:shiftinfo:export")
    @Log(title = "班次基础信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BaseShiftInfo baseShiftInfo)
    {
        List<BaseShiftInfo> list = baseShiftInfoService.selectBaseShiftInfoList(baseShiftInfo);
        ExcelUtil<BaseShiftInfo> util = new ExcelUtil<BaseShiftInfo>(BaseShiftInfo.class);
        return util.exportExcel(list, "shiftinfo");
    }

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

    /**
     * 新增保存班次基础信息
     */
    @RequiresPermissions("baseinfo:shiftinfo:add")
    @Log(title = "班次基础信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BaseShiftInfo baseShiftInfo)
    {
        return toAjax(baseShiftInfoService.insertBaseShiftInfo(baseShiftInfo));
    }

    /**
     * 修改班次基础信息
     */
    @GetMapping("/edit/{objid}")
    public String edit(@PathVariable("objid") Long objid, ModelMap mmap)
    {
        BaseShiftInfo baseShiftInfo = baseShiftInfoService.selectBaseShiftInfoById(objid);
        mmap.put("baseShiftInfo", baseShiftInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存班次基础信息
     */
    @RequiresPermissions("baseinfo:shiftinfo:edit")
    @Log(title = "班次基础信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BaseShiftInfo baseShiftInfo)
    {
        return toAjax(baseShiftInfoService.updateBaseShiftInfo(baseShiftInfo));
    }

    /**
     * 删除班次基础信息
     */
    @RequiresPermissions("baseinfo:shiftinfo:remove")
    @Log(title = "班次基础信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(baseShiftInfoService.deleteBaseShiftInfoByIds(ids));
    }
}
