huminmin
10 天以前 d2038a623e02c2d7bb6b95a908832c0432adf2f0
src/main/java/com/ruoyi/staff/controller/StaffSchedulingController.java
@@ -1,13 +1,22 @@
package com.ruoyi.staff.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.compensationperformance.pojo.CompensationPerformance;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.staff.dto.SaveStaffSchedulingDto;
import com.ruoyi.staff.dto.StaffSchedulingDto;
import com.ruoyi.staff.service.StaffSchedulingService;
import com.ruoyi.staff.vo.SearchSchedulingVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
@@ -19,31 +28,62 @@
@RestController
@RequestMapping("/staff/staffScheduling")
@RequiredArgsConstructor
@Api(tags = "排班")
public class StaffSchedulingController {
    private final StaffSchedulingService staffSchedulingService;
    @PostMapping("/listPage")
    @ApiOperation("排班分页查询")
    @Log(title = "排班分页查询", businessType = BusinessType.OTHER)
    public AjaxResult listPage(@RequestBody SearchSchedulingVo vo){
       return AjaxResult.success(staffSchedulingService.listPage(vo));
    }
    @PostMapping("/save")
    @ApiOperation("保存排班")
    @Log(title = "保存排班", businessType = BusinessType.UPDATE)
    public AjaxResult save(@RequestBody @Validated SaveStaffSchedulingDto saveStaffSchedulingDto){
        staffSchedulingService.saveStaffScheduling(saveStaffSchedulingDto);
        return AjaxResult.success();
    }
    @DeleteMapping("/delByIds")
    @ApiOperation("批量删除排班")
    @Log(title = "批量删除排班", businessType = BusinessType.DELETE)
    public AjaxResult delByIds(@RequestBody List<Integer> ids){
        staffSchedulingService.removeByIds(ids);
        return AjaxResult.success();
    }
    @DeleteMapping("/del/{id}")
    @ApiOperation("删除排班")
    @Log(title = "删除排班", businessType = BusinessType.DELETE)
    public AjaxResult del(@PathVariable("id") Integer id){
        staffSchedulingService.removeById(id);
        return AjaxResult.success();
    }
    /**
     * 获取当前用户最新排班记录
     */
    @GetMapping("/getCurrentUserLatestScheduling")
    @ApiOperation("获取当前用户最新排班记录")
    @Log(title = "获取当前用户最新排班记录", businessType = BusinessType.OTHER)
    public AjaxResult getCurrentUserLatestScheduling(){
        return AjaxResult.success(staffSchedulingService.getCurrentUserLatestScheduling());
    }
    @Log(title = "导出人员排班列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出人员排班列表")
    public void export(HttpServletResponse response ) {
        SearchSchedulingVo vo = new SearchSchedulingVo();
        vo.setCurrent(-1);
        vo.setSize(-1);
        IPage<StaffSchedulingDto> list = staffSchedulingService.listPage(vo);
        ExcelUtil<StaffSchedulingDto> util = new ExcelUtil<StaffSchedulingDto>(StaffSchedulingDto.class);
        util.exportExcel(response, list.getRecords(), "导出人员排班列表");
    }
}