package com.jjt.wkEmp.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
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.jjt.common.annotation.Log;
import com.jjt.common.core.controller.BaseController;
import com.jjt.common.core.domain.AjaxResult;
import com.jjt.common.enums.BusinessType;
import com.jjt.wkEmp.domain.TwinWkEmpRota;
import com.jjt.wkEmp.service.ITwinWkEmpRotaService;
import com.jjt.common.utils.poi.ExcelUtil;
import com.jjt.common.core.page.TableDataInfo;

/**
 * 经编车间员工排班Controller
 *
 * @author wukai
 * @date 2025-04-28
 */
@Api(tags="经编车间员工排班")
@RestController
@RequestMapping("/wkEmp/rota")
public class TwinWkEmpRotaController extends BaseController{
    @Resource
    private ITwinWkEmpRotaService twinWkEmpRotaService;

    /**
     * 查询经编车间员工排班列表
     */
    @ApiOperation("查询经编车间员工排班列表")
    //@PreAuthorize("@ss.hasPermi('wkEmp:rota:list')")
    @GetMapping("/list")
    public TableDataInfo list(TwinWkEmpRota twinWkEmpRota)
    {
        startPage();
        List<TwinWkEmpRota> list = twinWkEmpRotaService.selectTwinWkEmpRotaList(twinWkEmpRota);
        return getDataTable(list);
    }

    /**
     * 导出经编车间员工排班列表
     */
    @ApiOperation("导出经编车间员工排班列表")
    //@PreAuthorize("@ss.hasPermi('wkEmp:rota:export')")
    @Log(title = "经编车间员工排班", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TwinWkEmpRota twinWkEmpRota)
    {
        List<TwinWkEmpRota> list = twinWkEmpRotaService.selectTwinWkEmpRotaList(twinWkEmpRota);
        ExcelUtil<TwinWkEmpRota> util = new ExcelUtil<TwinWkEmpRota>(TwinWkEmpRota.class);
        util.exportExcel(response, list, "经编车间员工排班数据");
    }

    /**
     * 获取经编车间员工排班详细信息
     */
    @ApiOperation("获取经编车间员工排班详细信息")
    //@PreAuthorize("@ss.hasPermi('wkEmp:rota:query')")
    @GetMapping(value = "/{shiftId}")
    public AjaxResult getInfo(@PathVariable("shiftId") Long shiftId)
    {
        return success(twinWkEmpRotaService.selectTwinWkEmpRotaByShiftId(shiftId));
    }

    /**
     * 新增经编车间员工排班
     */
    @ApiOperation("新增经编车间员工排班")
    //@PreAuthorize("@ss.hasPermi('wkEmp:rota:add')")
    @Log(title = "经编车间员工排班", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TwinWkEmpRota twinWkEmpRota)
    {
        return toAjax(twinWkEmpRotaService.insertTwinWkEmpRota(twinWkEmpRota));
    }

    /**
     * 修改经编车间员工排班
     */
    @ApiOperation("修改经编车间员工排班")
    //@PreAuthorize("@ss.hasPermi('wkEmp:rota:edit')")
    @Log(title = "经编车间员工排班", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TwinWkEmpRota twinWkEmpRota)
    {
        return toAjax(twinWkEmpRotaService.updateTwinWkEmpRota(twinWkEmpRota));
    }

    /**
     * 删除经编车间员工排班
     */
    @ApiOperation("删除经编车间员工排班")
    //@PreAuthorize("@ss.hasPermi('wkEmp:rota:remove')")
    @Log(title = "经编车间员工排班", businessType = BusinessType.DELETE)
	@DeleteMapping("/{shiftIds}")
    public AjaxResult remove(@PathVariable Long[] shiftIds)
    {
        return toAjax(twinWkEmpRotaService.deleteTwinWkEmpRotaByShiftIds(shiftIds));
    }
}
