package com.xhkjedu.sapi.controller.analyze;

import com.xhkjedu.sapi.model.gradeclass.TClass;
import com.xhkjedu.sapi.service.analyze.SchoolPeopleService;
import com.xhkjedu.sapi.vo.analyze.SchoolPeopleGradeVo;
import com.xhkjedu.sapi.vo.analyze.SchoolPeopleNumVo;
import com.xhkjedu.utils.N_Utils;
import com.xhkjedu.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName SchoolPeopleController
 * Description TODO 学校概况（学校人数班级统计）
 * Author WN
 * Date 2020/8/8 10:18
 **/
@RestController
@RequestMapping("/schoolp")
public class SchoolPeopleController {

    @Autowired
    private SchoolPeopleService schoolPeopleService;

    /**
     *功能描述 学校概况--班级、老师、学生总人数
     * @author WN
     * @date 2020/8/8
     * @param  * @param tClass
     * @return com.xhkjedu.vo.ResultVo
     */
    @PostMapping("/allnum")
    public ResultVo getSchoolAllNum(@RequestBody TClass tClass){
        N_Utils.validation(new Object[]{tClass.getSchoolid(),"学校id",1});
        SchoolPeopleNumVo sp = schoolPeopleService.getSchoolAllNum(tClass.getSchoolid(), tClass.getYear());
        return  new ResultVo(0,"",sp);
    }

    /**
     *功能描述 学校概况--年级下班级、教师、学生数量
     * @author WN
     * @date 2020/8/8
     * @param  * @param tClass
     * @return com.xhkjedu.vo.ResultVo
     */
    @PostMapping("/gradenum")
    public ResultVo getSchoolGradeNum(@RequestBody TClass tClass){
        N_Utils.validation(new Object[]{tClass.getSchoolid(),"学校id",1});
        List<SchoolPeopleGradeVo> list = schoolPeopleService.listSchoolGrades(tClass.getSchoolid(), tClass.getYear());
        return new ResultVo(0,"",list);
    }

    /**
     *功能描述 学校概况--年级下各班级情况统计
     * @author WN
     * @date 2020/8/8
     * @param  * @param tClass
     * @return com.xhkjedu.vo.ResultVo
     */
    @PostMapping("/gradeclass")
    public ResultVo listSchoolGradeClasses(@RequestBody TClass tClass){
        N_Utils.validation(new Object[]{tClass.getSchoolid(),"学校id",1});
        List<SchoolPeopleGradeVo> list = schoolPeopleService.listSchoolGradeClasses(tClass.getSchoolid(), tClass.getYear());
        return new ResultVo(0,"",list);
    }

}
