package com.xjrsoft.module.student.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xjrsoft.common.model.result.R;
import com.xjrsoft.common.page.ConventPage;
import com.xjrsoft.common.page.PageOutput;
import com.xjrsoft.module.student.dto.StudentLeavePageDto;
import com.xjrsoft.module.student.service.IStudentLeaveService;
import com.xjrsoft.module.student.vo.StudentLeavePageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/student" + "/leave")
@Api(value = "/student" + "/leave", tags = "学生请假")
@AllArgsConstructor
public class StudentLeaveController {

    private final IStudentLeaveService studentLeaveService;

    @GetMapping(value = "/page")
    @ApiOperation(value = "学生请假列表(分页)")
    @SaCheckPermission("studentleave:detail")
    public R page(@Valid StudentLeavePageDto dto) {
        IPage<StudentLeavePageVo> page = studentLeaveService.getLeavePage(new Page<>(dto.getLimit(), dto.getSize()), dto);

        PageOutput<StudentLeavePageVo> pageOutput = ConventPage.getPageOutput(page, StudentLeavePageVo.class);
        return R.ok(pageOutput);
    }
}
