package com.yida.data.school.feign.facility;

import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.constant.FebsServerConstant;
import com.yida.data.common.core.entity.school.EduDormitory;
import com.yida.data.common.core.entity.school.EduDormitoryMaster;
import com.yida.data.common.core.entity.school.EduDormitoryRoom;
import com.yida.data.school.dto.index.EditPersonNumDTO;
import com.yida.data.school.dto.index.ListDormRoomDTO;

import com.yida.data.school.fallback.facility.RemoteDormitoryServiceFallback;
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;

@FeignClient(value = FebsServerConstant.EDU_SCHOOL, contextId = "dormitoryServiceClient",
    fallbackFactory = RemoteDormitoryServiceFallback.class)
public interface RemoteDormitoryService {

    /**
     * 查询宿管管辖的宿舍楼
     *
     * @param masterId
     * @return
     */
    @GetMapping("/facility/dorm/listDormByMaster")
    ResultBean<List<EduDormitory>> listDormByMaster(@RequestParam("masterId") Long masterId);


    /**
     * 查询寝室
     */
    @PostMapping("/facility/dormRoom/listDormRoom")
    ResultBean<List<EduDormitoryRoom>> listDormRoom(@RequestBody ListDormRoomDTO dto);

    @PostMapping("/in/facility/dormRoom/listDormRoom")
    ResultBean<List<EduDormitoryRoom>> listDormRoomNoAuth(@RequestBody ListDormRoomDTO dto);

    /**
     * 查询寝室
     *
     * @param id
     * @return
     */
    @GetMapping("/facility/dormRoom/getDormRoom")
    ResultBean<EduDormitoryRoom> getDormRoom(@RequestParam("id") Long id);

    /**
     * 查询寝室
     *
     * @param id
     * @return
     */
    @GetMapping("/in/facility/dormRoom/getDormRoom")
    ResultBean<EduDormitoryRoom> getDormRoomNoPermission(@RequestParam("id") Long id);

    /**
     * 根据名称和宿舍查询
     *
     * @param name
     * @return
     */
    @GetMapping("/facility/dormRoom/getDormRoomByNameAndDorm")
    ResultBean<EduDormitoryRoom> getDormRoomByNameAndDorm(@RequestParam("name") String name,
        @RequestParam("dormId") Long dormId);

    /**
     * 根据名称查询宿舍
     *
     * @param name
     * @return
     */
    @GetMapping("/facility/dorm/getDormByName")
    ResultBean<EduDormitory> getDormByName(@RequestParam("name") String name,
        @RequestParam("schoolId") Long schoolId);

    /**
     * 修改寝室入住的人数
     *
     * @return
     */
    @PostMapping("/facility/dormRoom/editPersonNum")
    ResultBean editPersonNum(@RequestBody List<EditPersonNumDTO> dtos);

    /**
     * 修改寝室入住的人数
     *
     * @return
     */
    @PostMapping("in/facility/dormRoom/editPersonNum")
    ResultBean editPersonNumNoPermission(@RequestBody List<EditPersonNumDTO> dtos);

    /**
     * 获取宿舍
     *
     * @param id
     * @return
     */
    @GetMapping("/facility/dorm/getDorm")
    ResultBean<EduDormitory> getDorm(@RequestParam("id") Long id);

    /**
     * 获取宿舍信息(不鉴权)
     *
     * @param id 宿舍id
     * @return com.yida.data.common.core.common.ResultBean<com.yida.data.common.core.entity.school.EduDormitory>
     * @author ZYJ
     * @date 2022/7/15 15:20
     */
    @GetMapping("/in/facility/dorm/getDorm")
    ResultBean<EduDormitory> getDormNoPermission(@RequestParam("id") Long id);

    @GetMapping("/in/facility/dorm/getDormListBySchoolId")
    ResultBean<List<EduDormitory>> getDormBySchoolId(@RequestParam("schoolId") Long schoolId);

}
