package com.school.project.controller;

import com.school.project.dto.PaginationDTO;
import com.school.project.dto.teacher.*;
import com.school.project.model.Teacher;
import com.school.project.service.teacher.TeacherServiceImpl;
import com.school.project.service.teacher.UploadMarksServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.security.Principal;

@RestController
@RequestMapping("/teacher")
public class TeacherController {

    @Autowired
    TeacherServiceImpl teacherService;

    @Autowired
    UploadMarksServiceImpl uploadMarksService;


//    @GetMapping("")
//    public TeacherViewDataDTO getTeacherData(Principal principal) {
//        return teacherService.getTeacherData(principal.getName());
//    }

    @GetMapping("/course")
    public TeacherViewCoursesDTO getTeacherCourses(Principal principal) {
        return teacherService.getTeacherCourses(principal.getName());
    }

    @PostMapping("/upload/marks")
    public void addAssessment(@RequestBody AddAssessmentDTO addAssessmentDTO) {
        uploadMarksService.setAssessment(addAssessmentDTO);
    }

    @PostMapping("/upload/marks/assessments")
    public void addMarks(@RequestBody UploadMarksDTO uploadMarksDTO) {
        uploadMarksService.setObtainedMarks(uploadMarksDTO);
    }

    @GetMapping
    public Page<TeacherViewDataDTO> getAllTeachers(@RequestBody PaginationDTO paginationDTO) {
        return teacherService.getAllTeachers(paginationDTO);
    }

}