package com.reading.platform.controller.parent;

import com.reading.platform.common.response.Result;
import com.reading.platform.common.security.SecurityUtils;
import com.reading.platform.entity.Student;
import com.reading.platform.service.StudentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "Parent - Child", description = "Child Information APIs for Parent")
@RestController
@RequestMapping("/api/parent/children")
@RequiredArgsConstructor
public class ParentChildController {

    private final StudentService studentService;

    @Operation(summary = "Get my children")
    @GetMapping
    public Result<List<Student>> getMyChildren() {
        Long parentId = SecurityUtils.getCurrentUserId();
        return Result.success(studentService.getStudentsByParentId(parentId));
    }

    @Operation(summary = "Get child by ID")
    @GetMapping("/{id}")
    public Result<Student> getChild(@PathVariable Long id) {
        return Result.success(studentService.getStudentById(id));
    }

}
