package com.ruoyi.project.shiftmgr.controller;

import java.util.Date;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.shiftmgr.domain.TShiftDailyInstDetail;
import com.ruoyi.project.shiftmgr.service.ITShiftDailyInstDetailService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 每日生产指令Controller
 *
 * @author ruoyi
 * @date 2022-08-03
 */
@RestController
@RequestMapping("/shiftmgr/detail")
public class TShiftDailyInstDetailController extends BaseController
{
    @Autowired
    private ITShiftDailyInstDetailService tShiftDailyInstDetailService;

    /**
     * 查询每日生产指令列表
     */
    @PreAuthorize("@ss.hasPermi('shiftmgr:detail:list')")
    @GetMapping("/list")
    public TableDataInfo list(TShiftDailyInstDetail tShiftDailyInstDetail)
    {
        startPage();
        List<TShiftDailyInstDetail> list = tShiftDailyInstDetailService.selectTShiftDailyInstDetailList(tShiftDailyInstDetail);
        return getDataTable(list);
    }

    /**
     * 导出每日生产指令列表
     */
    @PreAuthorize("@ss.hasPermi('shiftmgr:detail:export')")
    @Log(title = "每日生产指令", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TShiftDailyInstDetail tShiftDailyInstDetail)
    {
        List<TShiftDailyInstDetail> list = tShiftDailyInstDetailService.selectTShiftDailyInstDetailList(tShiftDailyInstDetail);
        ExcelUtil<TShiftDailyInstDetail> util = new ExcelUtil<TShiftDailyInstDetail>(TShiftDailyInstDetail.class);
        return util.exportExcel(list, "detail");
    }

    /**
     * 获取每日生产指令详细信息
     */
    @PreAuthorize("@ss.hasPermi('shiftmgr:detail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tShiftDailyInstDetailService.selectTShiftDailyInstDetailById(id));
    }

    /**
     * 新增每日生产指令
     */
    @PreAuthorize("@ss.hasPermi('shiftmgr:detail:add')")
    @Log(title = "每日生产指令", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TShiftDailyInstDetail tShiftDailyInstDetail)
    {
        tShiftDailyInstDetail.setCreaterCode(getUserId());
        tShiftDailyInstDetail.setCreatedate(new Date());
        return toAjax(tShiftDailyInstDetailService.insertTShiftDailyInstDetail(tShiftDailyInstDetail));
    }

    /**
     * 修改每日生产指令
     */
    @PreAuthorize("@ss.hasPermi('shiftmgr:detail:edit')")
    @Log(title = "每日生产指令", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TShiftDailyInstDetail tShiftDailyInstDetail)
    {
        tShiftDailyInstDetail.setUpdaterCode(getUserId());
        tShiftDailyInstDetail.setUpdatedate(new Date());
        return toAjax(tShiftDailyInstDetailService.updateTShiftDailyInstDetail(tShiftDailyInstDetail));
    }

    /**
     * 删除每日生产指令
     */
    @PreAuthorize("@ss.hasPermi('shiftmgr:detail:remove')")
    @Log(title = "每日生产指令", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tShiftDailyInstDetailService.deleteTShiftDailyInstDetailByIds(ids));
    }
}
