package com.jjt.wkEmp.controller;

import com.jjt.common.annotation.Log;
import com.jjt.common.core.controller.BaseController;
import com.jjt.common.core.domain.AjaxResult;
import com.jjt.common.core.page.TableDataInfo;
import com.jjt.common.enums.BusinessType;
import com.jjt.common.utils.poi.ExcelUtil;
import com.jjt.wkEmp.domain.TwinWkEmpSync;
import com.jjt.wkEmp.service.ITwinWkEmpSyncService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

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

/**
 * 经编车间排班同步记录Controller
 *
 * @author wukai
 * @date 2025-04-28
 */
@Api(tags = "经编车间排班同步记录")
@RestController
@RequestMapping("/wkEmp/sync")
public class TwinWkEmpSyncController extends BaseController {
    @Resource
    private ITwinWkEmpSyncService twinWkEmpSyncService;

    /**
     * 查询经编车间排班同步记录列表
     */
    @ApiOperation("查询经编车间排班同步记录列表")
    //@PreAuthorize("@ss.hasPermi('wkEmp:sync:list')")
    @GetMapping("/list")
    public TableDataInfo list(TwinWkEmpSync twinWkEmpSync) {
        startPage();
        List<TwinWkEmpSync> list = twinWkEmpSyncService.selectTwinWkEmpSyncList(twinWkEmpSync);
        return getDataTable(list);
    }

    /**
     * 导出经编车间排班同步记录列表
     */
    @ApiOperation("导出经编车间排班同步记录列表")
    //@PreAuthorize("@ss.hasPermi('wkEmp:sync:export')")
    @Log(title = "经编车间排班同步记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TwinWkEmpSync twinWkEmpSync) {
        List<TwinWkEmpSync> list = twinWkEmpSyncService.selectTwinWkEmpSyncList(twinWkEmpSync);
        ExcelUtil<TwinWkEmpSync> util = new ExcelUtil<TwinWkEmpSync>(TwinWkEmpSync.class);
        util.exportExcel(response, list, "经编车间排班同步记录数据");
    }

    /**
     * 获取经编车间排班同步记录详细信息
     */
    @ApiOperation("获取经编车间排班同步记录详细信息")
    //@PreAuthorize("@ss.hasPermi('wkEmp:sync:query')")
    @GetMapping(value = "/{syncId}")
    public AjaxResult getInfo(@PathVariable("syncId") Long syncId) {
        return success(twinWkEmpSyncService.selectTwinWkEmpSyncBySyncId(syncId));
    }

    /**
     * 新增经编车间排班同步记录
     */
    @ApiOperation("新增经编车间排班同步记录")
    //@PreAuthorize("@ss.hasPermi('wkEmp:sync:add')")
    @Log(title = "经编车间排班同步记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TwinWkEmpSync twinWkEmpSync) {
        return toAjax(twinWkEmpSyncService.insertTwinWkEmpSync(twinWkEmpSync));
    }
    @ApiOperation("清空记录")
    @PostMapping("/clean")
    public AjaxResult clean() {
        twinWkEmpSyncService.clean();
        return success();
    }


    /**
     * 修改经编车间排班同步记录
     */
    @ApiOperation("修改经编车间排班同步记录")
    //@PreAuthorize("@ss.hasPermi('wkEmp:sync:edit')")
    @Log(title = "经编车间排班同步记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TwinWkEmpSync twinWkEmpSync) {
        return toAjax(twinWkEmpSyncService.updateTwinWkEmpSync(twinWkEmpSync));
    }

    /**
     * 删除经编车间排班同步记录
     */
    @ApiOperation("删除经编车间排班同步记录")
    //@PreAuthorize("@ss.hasPermi('wkEmp:sync:remove')")
    @Log(title = "经编车间排班同步记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{syncIds}")
    public AjaxResult remove(@PathVariable Long[] syncIds) {
        return toAjax(twinWkEmpSyncService.deleteTwinWkEmpSyncBySyncIds(syncIds));
    }
}
