package com.yida.data.user.controller;

import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.system.Dept;
import com.yida.data.common.core.entity.user.EduParent;
import com.yida.data.system.feign.RemoteDeptService;
import com.yida.data.user.service.EduParentService;
import com.yida.data.user.vo.StaParentDistributeVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "家长管理")
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping(value = "/parent")
public class EduParentController {

    private final EduParentService eduParentService;
    private final RemoteDeptService remoteDeptService;

    @ApiOperation("查询家长统计数据")
    @GetMapping("/staParentDistribute")
    public ResultBean<StaParentDistributeVO> staParentDistribute() {
        List<Long> schoolIds = remoteDeptService.getSchoolByArea(null, null).getData().stream().map(Dept::getDeptId).collect(
            Collectors.toList());
        return ResultBean.buildSuccess(eduParentService.staParentDistribute(schoolIds));
    }
}
