package rd.controller.student;

import rd.data.dto.user.student.StudentUserInfoDTO;
import rd.data.db.table.StudentInfo;
import rd.data.model.response.PaginationWrapper;
import rd.data.model.response.Response;
import rd.service.user.StudentUserService;
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 java.util.List;

@RestController
@RequestMapping("/student")
public class StudentController {
    private final StudentUserService studentUserService;

    public StudentController(StudentUserService studentUserService) {
        this.studentUserService = studentUserService;
    }

    @GetMapping("/list")
    public Response<PaginationWrapper<List<StudentInfo>>> list(
            @RequestParam(value = "page", required = false, defaultValue = "1") int page,
            @RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize
    ) {
        var result = studentUserService.list(page, pageSize);
        return Response.success(result);
    }

    @GetMapping("/info")
    public Response<StudentUserInfoDTO> info(@RequestParam(value = "id") Long id) {
        var result = studentUserService.getInfoById(id);
        return Response.success(result);
    }
}
