package com.yida.data.user.feign;

import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.constant.FebsServerConstant;
import com.yida.data.common.core.entity.message.EduMessageStrategy;
import com.yida.data.common.core.entity.user.EduParent;
import com.yida.data.common.core.entity.user.EduStudent;
import com.yida.data.school.dto.transaction.ListBuyStudentDTO;
import com.yida.data.user.dto.ListStudentDTO;
import com.yida.data.user.fallback.RemoteStudentServiceFallback;
import com.yida.data.user.vo.ListParentByStudentIdsVO;
import com.yida.data.user.vo.ParentInfoVO;
import com.yida.data.user.vo.StudentClassInfoVO;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

@FeignClient(value = FebsServerConstant.EDU_USER, contextId = "studentServiceClient",
    fallbackFactory = RemoteStudentServiceFallback.class)
public interface RemoteStudentService {

    /**
     * 根据学生id查询学生
     */
    @GetMapping("/in/student/getStudent")
    ResultBean<EduStudent> getStudentNoPermission(@RequestParam("studentId") Long id);


    /**
     * 根据学生Id查询学生部门信息
     */
    @PostMapping("/in/student/getStudentDeptByIds")
    ResultBean<List<EduStudent>> getStudentDeptByIds(@RequestBody List<Long> studentIdList);

    /**
     * 处理响应的学生更新事件
     */
    @PostMapping("/in/student/dealWxStudentChange")
    ResultBean dealStudentWxChange(@RequestBody EduStudent student);

    /**
     * 处理响应的学生删除事件
     */
    @GetMapping("/in/student/dealWxStudentDelete")
    ResultBean dealStudentWxDelete(@RequestParam("wxId") String wxId, @RequestParam("schoolId") Long schoolId);

    /**
     * 处理响应的家长更新事件
     */
    @PostMapping("/in/student/dealWxParentChange")
    ResultBean dealParentWxChange(@RequestBody EduParent eduParent, @RequestParam("schoolId") Long schoolId);

    /**
     * 处理响应的家长删除事件
     */
    @GetMapping("/in/student/dealWxParentDelete")
    ResultBean dealParentWxDelete(@RequestParam("wxId") String wxId,
        @RequestParam("schoolId") Long schoolId);

    @GetMapping("/in/student/getParentWithStudent")
    ResultBean<ParentInfoVO> getParentWithStudent(@RequestParam("mobile") String mobile,
        @RequestParam("wxId") String wxId,
        @RequestParam("schoolId") Long schoolId);

    /**
     * 初始化学生列表-不进行判断直接新增学生
     */
    @PostMapping("/in/student/initStudent")
    ResultBean initStudent(@RequestBody List<EduStudent> student);

    /**
     * 根据家长id查询学生
     */
    @GetMapping("/student/listStudentByParent")
    ResultBean<List<EduStudent>> listStudentByParent(@RequestParam("parentId") Long parentId);

    /**
     * 根据学生查询班级信息
     */
    @GetMapping("/student/getClassInfoByStudent")
    ResultBean<StudentClassInfoVO> getClassInfoByStudent(@RequestParam("studentId") Long studentId,
        @RequestParam("parentMobile") String parentMobile);

    /**
     * 根据学号和学校查询学生
     */
    @GetMapping("/in/student/getStudentByStuNumAndSchool")
    ResultBean<EduStudent> getStudentByStuNumAndSchool(@RequestParam("stuNumber") String stuNumber,
        @RequestParam("schoolId") Long schoolId);

    /**
     * 根据年级id、学生名称、班级名称查询学生
     */
    @GetMapping("/in/student/listStudentByGradeAndClass")
    ResultBean<List<EduStudent>> listStudentByGradeAndClass(@RequestParam("studentName") String studentName,
        @RequestParam("className") String className,
        @RequestParam("gradeId") Long gradeId);

    /**
     * 根据教师电话、学校查询家长列表
     */
    @GetMapping("/student/listParentByTeacher")
    ResultBean<List<ParentInfoVO>> listParentByTeacher(@RequestParam("teacherId") Long teacherId,
        @RequestParam("parentName") String parentName);

    @GetMapping("/in/student/saveYidaAppUserId")
    ResultBean saveYidaAppUserId(@RequestParam("parentId") Long parentId,
        @RequestParam("yidaAppUserId") String yidaAppUserId);

    /**
     * 保存家长openId
     *
     * @param parentId 家长id
     * @param openId   微信openId
     * @return com.yida.data.common.core.common.ResultBean
     * @author ZYJ
     * @date 2022/9/22 16:17
     */
    @GetMapping("/in/student/saveWxPublicOpenId")
    ResultBean saveWxPublicOpenId(@RequestParam("parentId") Long parentId,
        @RequestParam("openId") String openId);

    /**
     * 查询用户企业微信Id
     *
     * @param phone
     * @param schoolId
     * @return
     */
    @PostMapping("/student/getParentByPhoneAndSchoolId")
    ResultBean<List<String>> getParentByPhoneAndSchoolId(@RequestBody List<String> phone, @RequestParam Long schoolId);

    /**
     * 根据学校id查询当前学校的自动回复消息
     *
     * @param schoolId 学校id
     * @return com.yida.data.common.core.common.ResultBean<com.yida.data.common.core.entity.message.EduMessageStrategy>
     * @author ZYJ
     * @date 2021/8/25 17:36
     */
    @GetMapping("/in/schoolMessage/getEduMessageStrategyBySchoolId")
    ResultBean<EduMessageStrategy> getEduMessageStrategyBySchoolId(@RequestParam("schoolId") Long schoolId);

    /**
     * 查询未购买该商品的学生
     *
     * @param listBuyStudentDTO
     * @return 学生列表
     */
    @PostMapping("/student/listNotBuyStudent")
    ResultBean<Page<EduStudent>> listNotBuyStudent(@RequestBody ListBuyStudentDTO listBuyStudentDTO);

    /**
     * 查询未购买该商品的学生
     *
     * @param listBuyStudentDTO
     * @return 学生列表
     */
    @PostMapping("in/student/listAllNotBuyStudent")
    ResultBean<List<EduStudent>> listAllNotBuyStudent(@RequestBody ListBuyStudentDTO listBuyStudentDTO);

    /**
     * 通过学生id查询家长WxId
     *
     * @param studentId
     * @return
     */
    @PostMapping("in/student/findParentWxId")
    ResultBean<List<String>> findParentWxId(@RequestBody List<Long> studentId);

    /**
     * 通过学生id查询学生信息，和家长信息
     *
     * @param studentIds
     * @return
     */
    @PostMapping("student/listParentByStudentIds")
    ResultBean<List<ListParentByStudentIdsVO>> listParentByStudentIds(@RequestBody List<Long> studentIds);

    @GetMapping("/in/student/syncQywxStudent")
    ResultBean syncQywxStudent();

    /**
     * 根据条件查询学生列表
     *
     * @param dto
     * @return
     */
    @PostMapping(value = "/in/student/listStudent")
    ResultBean<List<EduStudent>> listStudent(@RequestBody ListStudentDTO dto);


    @PostMapping(value = "/in/student/listStudentByClassId")
    ResultBean<List<EduStudent>> listStudentByClassId(@RequestBody ListStudentDTO dto);

    /**
     * 更新学生在校离校状态
     */
    @GetMapping("/in/student/updateStudentStatus")
    ResultBean updateStudentStatus(@RequestParam("studentId") Long studentId,
        @RequestParam("status") Integer status,
        @RequestParam("dormStatus") Integer dormStatus);

    /**
     * 接触学生与寝室的绑定
     *
     * @param dormIds
     * @return
     */
    @PostMapping("/student/unbindDormRoom")
    ResultBean unbindDormRoom(@RequestBody List<Long> dormIds);

    @GetMapping("/in/student/getStudentByDahua")
    ResultBean<EduStudent> getStudentByDahuaNoPermission(@RequestParam("dahuaCode") String dahuaCode);

    /**
     * 根据学生表字段查询学生id信息
     *
     * @param eduStudent 查询条件
     * @return com.yida.data.common.core.common.ResultBean<java.util.List < java.lang.Long>>
     * @author ZYJ
     * @date 2022/3/29 9:29
     */
    @PostMapping(value = "/in/student/listBaseStudentIds")
    ResultBean<List<Long>> listBaseStudentIds(@RequestBody EduStudent eduStudent);

    /**
     * 根据学生表字段查询学生列表信息
     *
     * @param eduStudent 查询条件
     * @return com.yida.data.common.core.common.ResultBean<java.util.List < com.yida.data.common.core.entity.user.EduStudent>>
     * @author ZYJ
     * @date 2022/3/29 13:58
     */
    @PostMapping(value = "/in/student/listBaseStudent")
    ResultBean<List<EduStudent>> listBaseStudent(@RequestBody EduStudent eduStudent);


    /**
     * 单表查询学生信息
     *
     * @param eduStudent
     * @return
     */
    @PostMapping(value = "/in/student/listBaseStudentNoJoin")
    ResultBean<List<EduStudent>> listBaseStudentNoJoin(@RequestBody EduStudent eduStudent);

    /**
     * 查询校园大数据的人员统计数据
     *
     * @param schoolId 学校id
     * @return com.yida.data.common.core.common.ResultBean<cn.hutool.json.JSONObject>
     * @author ZYJ
     * @date 2023/4/24 15:09
     */
    @GetMapping(value = "/in/student/countUserDashboardNum")
    ResultBean<JSONObject> countUserDashboardNum(@RequestParam Long schoolId);


    /**
     * 新增/编辑学生
     *
     * @param eduStudent
     * @return
     */
    @PostMapping("out/student/saveStudent")
    ResultBean<EduStudent> saveStudent(@RequestBody EduStudent eduStudent);

    @PostMapping("in/student/saveStudentDorm")
    ResultBean saveStudentDorm(@RequestBody EduStudent eduStudent);

    /**
     * 更新学生信息缓存
     *
     * @return
     */
    @GetMapping("in/student/updateStudentCache")
    ResultBean updateStudentCache();
}
