package com.schoolinout.web.controller.api;

import com.schoolinout.api.service.IApiStudentService;
import com.schoolinout.common.core.controller.BaseController;
import com.schoolinout.common.core.domain.AjaxResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author sakura
 * @date 2024/1/11 14:14:15 Thu
 */
@Tag(name = "用户端-学生接口")
@RestController
@RequestMapping("/app/student")
public class Api_StudentController extends BaseController {

    @Autowired
    private IApiStudentService studentService;

    @Operation(summary = "获取绑定学生列表")
    @GetMapping("/list")
    public AjaxResult list() {
        Long parentId = getLoginUser().getParentLogin().getId();
        return success(studentService.listStudent(parentId));
    }

    @Operation(summary = "获取绑定学生详情")
    @GetMapping("/info/{studentId}")
    public AjaxResult getEditInfo(@PathVariable Long studentId) {
        Long parentId = getLoginUser().getParentLogin().getId();
        return success(studentService.listStudentEditInfo(parentId, studentId));
    }

}
