package com.jjt.emp.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.emp.domain.TwinEmpDetail;
import com.jjt.emp.service.ITwinEmpDetailService;
import com.jjt.common.utils.poi.ExcelUtil;
import com.jjt.common.core.page.TableDataInfo;

/**
 * 员工排班明细Controller
 *
 * @author wukai
 * @date 2025-01-18
 */
@Api(tags="员工排班明细")
@RestController
@RequestMapping("/emp/empDetail")
public class TwinEmpDetailController extends BaseController{
    @Resource
    private ITwinEmpDetailService twinEmpDetailService;

    /**
     * 查询员工排班明细列表
     */
    @ApiOperation("查询员工排班明细列表")
    //@PreAuthorize("@ss.hasPermi('emp:empDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(TwinEmpDetail twinEmpDetail)
    {
        startPage();
        List<TwinEmpDetail> list = twinEmpDetailService.selectTwinEmpDetailList(twinEmpDetail);
        return getDataTable(list);
    }

    /**
     * 导出员工排班明细列表
     */
    @ApiOperation("导出员工排班明细列表")
    //@PreAuthorize("@ss.hasPermi('emp:empDetail:export')")
    @Log(title = "员工排班明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TwinEmpDetail twinEmpDetail)
    {
        List<TwinEmpDetail> list = twinEmpDetailService.selectTwinEmpDetailList(twinEmpDetail);
        ExcelUtil<TwinEmpDetail> util = new ExcelUtil<TwinEmpDetail>(TwinEmpDetail.class);
        util.exportExcel(response, list, "员工排班明细数据");
    }

    /**
     * 获取员工排班明细详细信息
     */
    @ApiOperation("获取员工排班明细详细信息")
    //@PreAuthorize("@ss.hasPermi('emp:empDetail:query')")
    @GetMapping(value = "/{detailId}")
    public AjaxResult getInfo(@PathVariable("detailId") Long detailId)
    {
        return success(twinEmpDetailService.selectTwinEmpDetailByDetailId(detailId));
    }

    /**
     * 新增员工排班明细
     */
    @ApiOperation("新增员工排班明细")
    //@PreAuthorize("@ss.hasPermi('emp:empDetail:add')")
    @Log(title = "员工排班明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TwinEmpDetail twinEmpDetail)
    {
        return toAjax(twinEmpDetailService.insertTwinEmpDetail(twinEmpDetail));
    }

    /**
     * 修改员工排班明细
     */
    @ApiOperation("修改员工排班明细")
    //@PreAuthorize("@ss.hasPermi('emp:empDetail:edit')")
    @Log(title = "员工排班明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TwinEmpDetail twinEmpDetail)
    {
        return toAjax(twinEmpDetailService.updateTwinEmpDetail(twinEmpDetail));
    }

    /**
     * 删除员工排班明细
     */
    @ApiOperation("删除员工排班明细")
    //@PreAuthorize("@ss.hasPermi('emp:empDetail:remove')")
    @Log(title = "员工排班明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{detailIds}")
    public AjaxResult remove(@PathVariable Long[] detailIds)
    {
        return toAjax(twinEmpDetailService.deleteTwinEmpDetailByDetailIds(detailIds));
    }
}
