package com.ruoyi.project.shiftmgr.controller;

import java.util.Date;
import java.util.List;

import com.ruoyi.project.system.domain.SysUser;
import com.ruoyi.project.system.service.ISysUserService;
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.TShiftDevelopment;
import com.ruoyi.project.shiftmgr.service.ITShiftDevelopmentService;
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-07-29
 */
@RestController
@RequestMapping("/shiftmgr/development")
public class TShiftDevelopmentController extends BaseController
{
    @Autowired
    private ITShiftDevelopmentService tShiftDevelopmentService;

    /**
     * 查询班组建设列表
     */
    @PreAuthorize("@ss.hasPermi('shiftmgr:development:list')")
    @GetMapping("/list")
    public TableDataInfo list(TShiftDevelopment tShiftDevelopment)
    {
        startPage();
        List<TShiftDevelopment> list = tShiftDevelopmentService.selectTShiftDevelopmentList(tShiftDevelopment);
        return getDataTable(list);
    }

    /**
     * 导出班组建设列表
     */
    @PreAuthorize("@ss.hasPermi('shiftmgr:development:export')")
    @Log(title = "班组建设", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TShiftDevelopment tShiftDevelopment)
    {
        List<TShiftDevelopment> list = tShiftDevelopmentService.selectTShiftDevelopmentList(tShiftDevelopment);
        ExcelUtil<TShiftDevelopment> util = new ExcelUtil<TShiftDevelopment>(TShiftDevelopment.class);
        return util.exportExcel(list, "development");
    }

    /**
     * 获取班组建设详细信息
     */
    @PreAuthorize("@ss.hasPermi('shiftmgr:development:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tShiftDevelopmentService.selectTShiftDevelopmentById(id));
    }

    /**
     * 新增班组建设
     */
    @PreAuthorize("@ss.hasPermi('shiftmgr:development:add')")
    @Log(title = "班组建设", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TShiftDevelopment tShiftDevelopment)
    {
        tShiftDevelopment.setCreaterCode(getUserId());
        tShiftDevelopment.setCreatedate(new Date());
        return toAjax(tShiftDevelopmentService.insertTShiftDevelopment(tShiftDevelopment));
    }

    /**
     * 修改班组建设
     */
    @PreAuthorize("@ss.hasPermi('shiftmgr:development:edit')")
    @Log(title = "班组建设", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TShiftDevelopment tShiftDevelopment)
    {
        tShiftDevelopment.setUpdaterCode(getUserId());
        tShiftDevelopment.setUpdatedate(new Date());
        return toAjax(tShiftDevelopmentService.updateTShiftDevelopment(tShiftDevelopment));
    }

    /**
     * 删除班组建设
     */
    @PreAuthorize("@ss.hasPermi('shiftmgr:development:remove')")
    @Log(title = "班组建设", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tShiftDevelopmentService.deleteTShiftDevelopmentByIds(ids));
    }
}
