package com.bc.exam.modules.student.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bc.exam.core.api.ApiRest;
import com.bc.exam.core.api.controller.BaseController;
import com.bc.exam.core.api.dto.PagingReqDTO;
import com.bc.exam.modules.student.entity.Student;
import com.bc.exam.modules.student.service.StudentService;
import com.bc.exam.modules.user.UserUtils;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Description 描述:学生基础信息 前端控制器
 * @Author A贾宇婷034244310
 * @Date 20260615
 */
@RestController
@RequestMapping("/student/student")
public class StudentController extends BaseController {

    @Resource
    StudentService studentService;

    /**
     * 学生个人信息获取
     * @param
     * @return
     */
    @PostMapping(value = "/queryPsInfo")
    public ApiRest<Student> login() {

        return super.success(studentService.getById(UserUtils.getUserId()));
    }

    /**
     * 添加或修改
     * @param reqDTO
     * @return
     */
    @ApiOperation(value = "添加或修改")
    @PostMapping("/save")
    public ApiRest save(@RequestBody Student reqDTO) {
        reqDTO.setUserid(UserUtils.getUserId());
        reqDTO.setId(UserUtils.getUserId());
        studentService.saveOrUpdate(reqDTO);
        return super.success();
    }

    /**
     * 分页查找
     * @param reqDTO
     * @return
     */
    @ApiOperation(value = "分页查找")
    @PostMapping("/paging")
    public ApiRest<IPage<Student>> paging(@RequestBody PagingReqDTO<Student> reqDTO) {
        //分页查询并转换
        IPage<Student> page = studentService.paging(reqDTO);
        return super.success(page);
    }


}

