package com.cpop.clockin.business.controller;

import com.cpop.clockin.business.dto.StaffClassesDto;
import com.cpop.clockin.business.service.StaffClassesService;
import com.cpop.clockin.business.vo.StaffClassesVo;
import com.cpop.core.base.R;
import com.mybatisflex.core.paginate.Page;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import com.cpop.clockin.business.entity.StaffClasses;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.io.Serializable;
import java.util.List;

/**
 * 员工-班次关联表 控制层。
 *
 * @author Yxz
 * @since 2024-01-23
 */
@RestController
@Api(tags = "员工-班次关联表接口")
@RequestMapping("/backstage/staffClasses")
public class StaffClassesController {

    @Autowired
    private StaffClassesService staffClassesService;

    /**
     * 添加员工-班次关联表。
     *
     * @author: Yxz
     * @date: 2024/1/24 20:54
     * @param: [staffClassesDto]
     * @return: com.cpop.core.base.R<java.lang.Void>
     **/
    @PostMapping("/save")
    @ApiOperation("保存员工-班次关联表")
    public R<Void> save(@RequestBody @ApiParam("员工-班次保存Dto") StaffClassesDto staffClassesDto) {
        staffClassesService.saveAll(staffClassesDto);
        return R.ok();
    }


    /**
     * 根据主键更新员工-班次关联表。
     *
     * @author: Yxz
     * @date: 2024/1/24 20:54
     * @param: [staffClassesDto]
     * @return: com.cpop.core.base.R<java.lang.Void>
     **/
    @PutMapping("/update")
    @ApiOperation("更新员工-班次关联表")
    public R<Void> update(@RequestBody @ApiParam("员工-班次修改Dto") StaffClassesDto staffClassesDto) {
        staffClassesService.updateAll(staffClassesDto);
        return R.ok();
    }

    /**
     * 查询所有员工-班次关联表。
     *
     * @return 所有数据
     */
    @GetMapping("/list")
    @ApiOperation("查询员工班次信息")
    public R<List<StaffClassesVo>> list() {
        return R.ok(staffClassesService.getStaffClassesVolist());
    }


    /**
     * 根据员工-班次关联表主键获取详细信息。
     *
     * @param id 员工-班次关联表主键
     * @return 员工-班次关联表详情
     */
    @GetMapping("/getInfo/{id}")
    @ApiOperation("根据主键获取员工-班次关联表")
    public R<StaffClasses> getInfo(@PathVariable @ApiParam("员工-班次关联表主键") Serializable id) {
        return R.ok(staffClassesService.getById(id));
    }

    /**
     * 分页查询员工-班次关联表。
     *
     * @author: Yxz
     * @date: 2024/1/24 20:55
     * @param: [staffName]
     * @return: com.cpop.core.base.R<com.mybatisflex.core.paginate.Page<com.cpop.clockin.business.vo.StaffClassesVo>>
     **/
    @GetMapping("/page")
    @ApiOperation("分页查询员工-班次信息")
    public R<Page<StaffClassesVo>> page( @ApiParam("员工名称") @RequestParam(value = "staffName", required = false)String staffName) {

        return R.ok(staffClassesService.selectPage(staffName));
    }

}
