package com.xjrsoft.module.student.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xjrsoft.common.model.result.RT;
import com.xjrsoft.common.page.ConventPage;
import com.xjrsoft.common.page.PageOutput;
import com.xjrsoft.module.student.dto.SchoolRollStudentPageDto;
import com.xjrsoft.module.student.service.ISchoolRollStudentService;
import com.xjrsoft.module.student.vo.SchoolRollStudentPageVo;
import com.xjrsoft.module.student.vo.SchoolRollStudentVo;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
* @title: 学籍异动学生
* @Author dzx
* @Date: 2023-11-30
* @Version 1.0
*/
@RestController
@RequestMapping("/student" + "/schoolRollStudent")
@Api(value = "/student"  + "/schoolRollStudent",tags = "学籍异动学生代码")
@AllArgsConstructor
public class SchoolRollStudentController {


    private final ISchoolRollStudentService schoolRollStudentService;

    @GetMapping(value = "/page")
    @ApiOperation(value="学籍异动学生列表(分页)")
    @SaCheckPermission("schoolrollstudent:detail")
    public RT<PageOutput<SchoolRollStudentPageVo>> page(@Valid SchoolRollStudentPageDto dto){
        Page<SchoolRollStudentPageVo> page = schoolRollStudentService.getPage(new Page<>(dto.getLimit(), dto.getSize()), dto);
        PageOutput<SchoolRollStudentPageVo> pageOutput = ConventPage.getPageOutput(page, SchoolRollStudentPageVo.class);
        return RT.ok(pageOutput);
    }

    @GetMapping(value = "/info")
    @ApiOperation(value="根据id查询学籍异动学生信息")
    @SaCheckPermission("schoolrollstudent:detail")
    public RT<SchoolRollStudentVo> info(@RequestParam Long id){
        SchoolRollStudentVo schoolRollStudent = schoolRollStudentService.getInfo(id);
        if (schoolRollStudent == null) {
           return RT.error("找不到此数据！");
        }
        return RT.ok(schoolRollStudent);
    }



}