package com.yida.data.user.controller.out;

import com.yida.data.common.core.common.ResultBean;
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 io.swagger.annotations.ApiParam;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;

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

    private final EduParentService eduParentService;

    @ApiOperation("查询家长统计数据")
    @GetMapping("/staParentDistribute")
    public ResultBean<StaParentDistributeVO> staParentDistribute(Long[] schoolIds) {
        return ResultBean.buildSuccess(eduParentService.staParentDistribute(Arrays.asList(schoolIds)));
    }

    @ApiOperation("H5页面判断是否有家长信息, 没用则新增家长数据(不包含学生)")
    @GetMapping("/checkParent")
    public ResultBean<String> checkParent(
            @ApiParam(value = "学校id", required = true) @RequestParam Long schoolId,
            @ApiParam(value = "家长手机号码", required = true) @RequestParam String mobile,
            @ApiParam(value = "app登录用户id") String appUserId) {
        eduParentService.checkParent(schoolId, mobile, appUserId);
        return ResultBean.buildSuccess();
    }
}
