package com.ym.mec.web.controller;

import com.ym.mec.biz.dal.dto.CourseScheduleStudentListDto;
import com.ym.mec.biz.dal.enums.StudentAttendanceStatusEnum;
import com.ym.mec.biz.dal.page.CourseScheduleStudentPaymentQueryInfo;
import com.ym.mec.biz.dal.page.CourseScheduleTeacherSalaryQueryInfo;
import com.ym.mec.biz.service.CourseScheduleStudentPaymentService;
import com.ym.mec.common.controller.BaseController;
import com.ym.mec.common.entity.HttpResponseResult;
import com.ym.mec.common.page.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;
import java.util.stream.Collectors;

/**
 * @Author Joburgess
 * @Date 2020/11/17 0017
 */
@RestController
@RequestMapping("courseScheduleStudentPayment")
@Api(tags = "学生课程之缴费记录服务")
public class CourseScheduleStudentPaymentController extends BaseController {

    @Autowired
    private CourseScheduleStudentPaymentService courseScheduleStudentPaymentService;

    @ApiOperation(value = "分页查询指定课程上的学员")
    @GetMapping("/queryCourseStudentList")
    @PreAuthorize("@pcs.hasPermissions('courseScheduleStudentPayment/queryCourseStudentList')")
    public HttpResponseResult queryCourseStudentList(CourseScheduleStudentPaymentQueryInfo queryInfo) {
        return succeed(courseScheduleStudentPaymentService.queryCourseStudentList(queryInfo));
    }

    @ApiOperation(value = "获取指定课程上的学员信息")
    @GetMapping("/getCourseStudents")
    @PreAuthorize("@pcs.hasPermissions('courseScheduleStudentPayment/getCourseStudents')")
    public HttpResponseResult getCourseStudents(String courseIds){
        if(StringUtils.isBlank(courseIds)){
            return failed("请指定课程");
        }
        return succeed(courseScheduleStudentPaymentService.getCourseStudents(Arrays.stream(courseIds.split(",")).map(Long::valueOf).collect(Collectors.toList())));
    }

}
