package rd.controller.teacher;

import rd.data.dto.user.teacher.TeacherUserInfoDTO;
import rd.data.db.table.TeacherInfo;
import rd.data.model.response.PaginationWrapper;
import rd.data.model.response.Response;
import rd.service.user.TeacherUserService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/teacher")
public class TeacherController {
    private final TeacherUserService teacherUserService;

    public TeacherController(TeacherUserService teacherUserService) {
        this.teacherUserService = teacherUserService;
    }

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

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