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.BaseShiftdetailInfo;
import com.ruoyi.baseinfo.service.IBaseShiftdetailInfoService;
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-28
 */
@Controller
@RequestMapping("/baseinfo/shiftdetailinfo")
public class BaseShiftdetailInfoController extends BaseController
{
    private String prefix = "baseinfo/shiftdetailinfo";

    @Autowired
    private IBaseShiftdetailInfoService baseShiftdetailInfoService;

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

    /**
     * 查询交接班详情信息列表
     */
    @RequiresPermissions("baseinfo:shiftdetailinfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BaseShiftdetailInfo baseShiftdetailInfo)
    {
        startPage();
        List<BaseShiftdetailInfo> list = baseShiftdetailInfoService.selectBaseShiftdetailInfoList(baseShiftdetailInfo);
        return getDataTable(list);
    }

    /**
     * 导出交接班详情信息列表
     */
    @RequiresPermissions("baseinfo:shiftdetailinfo:export")
    @Log(title = "交接班详情信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BaseShiftdetailInfo baseShiftdetailInfo)
    {
        List<BaseShiftdetailInfo> list = baseShiftdetailInfoService.selectBaseShiftdetailInfoList(baseShiftdetailInfo);
        ExcelUtil<BaseShiftdetailInfo> util = new ExcelUtil<BaseShiftdetailInfo>(BaseShiftdetailInfo.class);
        return util.exportExcel(list, "shiftdetailinfo");
    }

    /**
     * 新增交接班详情信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存交接班详情信息
     */
    @RequiresPermissions("baseinfo:shiftdetailinfo:add")
    @Log(title = "交接班详情信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BaseShiftdetailInfo baseShiftdetailInfo)
    {
        return toAjax(baseShiftdetailInfoService.insertBaseShiftdetailInfo(baseShiftdetailInfo));
    }

    /**
     * 修改交接班详情信息
     */
    @GetMapping("/edit/{shiftNo}")
    public String edit(@PathVariable("shiftNo") String shiftNo, ModelMap mmap)
    {
        BaseShiftdetailInfo baseShiftdetailInfo = baseShiftdetailInfoService.selectBaseShiftdetailInfoById(shiftNo);
        mmap.put("baseShiftdetailInfo", baseShiftdetailInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存交接班详情信息
     */
    @RequiresPermissions("baseinfo:shiftdetailinfo:edit")
    @Log(title = "交接班详情信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BaseShiftdetailInfo baseShiftdetailInfo)
    {
        return toAjax(baseShiftdetailInfoService.updateBaseShiftdetailInfo(baseShiftdetailInfo));
    }

    /**
     * 删除交接班详情信息
     */
    @RequiresPermissions("baseinfo:shiftdetailinfo:remove")
    @Log(title = "交接班详情信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(baseShiftdetailInfoService.deleteBaseShiftdetailInfoByIds(ids));
    }
}
