package com.vctgo.system.api;

import com.vctgo.common.core.constant.SecurityConstants;
import com.vctgo.common.core.constant.ServiceNameConstants;
import com.vctgo.common.core.domain.R;
import com.vctgo.system.api.config.FeignConfiguration;
import com.vctgo.system.api.domain.SysClassSetting;
import com.vctgo.system.api.domain.SysReLocationArea;
import com.vctgo.system.api.domain.SysReLocationClass;
import com.vctgo.system.api.domain.dto.BindClassUserDto;
import com.vctgo.system.api.domain.dto.SysClassSettingDto;
import com.vctgo.system.api.domain.dto.SysReClassUserDto;
import com.vctgo.system.api.domain.dto.ToySysClassSettingDto;
import com.vctgo.system.api.factory.RemoteClassFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@FeignClient(contextId = "remoteClassService", value = ServiceNameConstants.SYSTEM_SERVICE,
        fallbackFactory = RemoteClassFallbackFactory.class, configuration = FeignConfiguration.class)
public interface RemoteClassService {

    /**
     * 获取全部的班级列表
     *
     * @param  sysClassSettingDto 班级信息
     * @return 结果
     */
    @GetMapping("/sysClassSetting/external/list")
    R<List<SysClassSetting>> getClassList(@SpringQueryMap SysClassSettingDto sysClassSettingDto);

    /**
     * 获取班级详情
     *
     * @param  id 班级ID
     * @return 结果
     */
    @GetMapping("/sysClassSetting/weekPlan/{id}")
    R<SysClassSetting> getClassInfo(@PathVariable("id") Long id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 获取全部的班级列表
     *
     * @param  userId 用户ID
     * @param  bindUserPosition 用户关系
     * @return 结果
     */
    @GetMapping("/allocation/class/user/external/list/{userId}/{bindUserPosition}")
    R<List<SysClassSetting>> getUserClassDataList(@PathVariable("userId") Long userId,
                                                  @PathVariable("bindUserPosition") Integer bindUserPosition,
                                                  @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 获取班级位置ID列表
     *
     * @return 结果
     */
    @GetMapping("/sysClassSetting/external/getLocationIdList/{ids}")
    R<Long[]> getLocationIdList(@PathVariable("ids")Long[] ids,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 通过班级Id获取位置和区域信息
     *
     * @param classId 班级Id
     * @return
     */
    @GetMapping(value = "/sysClassSetting/inner/classId")
    R<List<SysReLocationArea>>  selectLocationAndAreaByClassId(@RequestParam("classId") String classId);

    /**
     * 通过年级或班级Id获取位置和区域信息
     *
     * @param gradeIn  年级
     * @param classIds 班级
     * @return
     */
    @GetMapping(value = "/sysClassSetting/inner/gradeInAndClass")
    R<List<SysReLocationArea>> selectLocationAndAreaByGradeInAndClass(@RequestParam("gradeIn") String[] gradeIn,
                                                                      @RequestParam("classIds") String[] classIds,
                                                                      @RequestParam("selectType") String selectType);

    @GetMapping(value = "/sysClassSetting/inner/locationId")
    R<List<SysReLocationArea>> selectLocationAndAreaByLocationId(@RequestParam(value = "locationIds") String[] locationIds);

    @GetMapping(value = "/sysClassSetting/inner/locationIdAndClass")
    R<List<SysReLocationClass>> selectLocationIdAndClass() ;

    /**
     * 根据位置ID获取玩具信息
     * @return
     */
    @GetMapping("/sysClassSetting/external/getClassListByLocationId/{locationId}")
    R<List<SysClassSetting>> getClassListByLocationId(@PathVariable("locationId") Long locationId,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping(value = "/sysClassSetting/external/getClassSetting/locationIds")
    R<List<SysClassSetting>> getClassSetting(@RequestParam(value = "locationIds") String[] locationIds,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping(value = "/sysClassSetting/inner/classSetting/locationId/{tenantId}")
    R<List<SysClassSetting>> selectClassSettingAndLocation(@PathVariable("tenantId") String tenantId);

    /**
     * 获取班级详情
     *
     * @param  id 班级ID
     * @return 结果
     */
    @GetMapping("/sysClassSetting/getClassSettingInfo/{id}")
    R<SysClassSetting> getClassSettingInfo(@PathVariable("id") Long id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 查看班级配置的人员明细
     *
     * @param classId  班级ID
     * @param bindUserPosition 绑定类型（1=教师，4=幼儿）
     * @return
     */
    @GetMapping(value = "/allocation/class/user/{classId}/detail")
    R<BindClassUserDto> getClassAllocationDetail(@PathVariable(name = "classId") Long classId,
                                                       @RequestParam(name = "bindUserPosition", required = false) Integer bindUserPosition);

    /**
     * 根据班级绑定人员筛选班级列表
     */
    @GetMapping("/sysClassSetting/classList/bindUserId")
    R<List<SysClassSetting>> classListByBindInfo();

    /**
     * 获取班级配置人员信息列表
     *
     * @param  sysReClassUserDto 班级与人员绑定信息
     * @return 结果
     */
    @GetMapping("/allocation/class/user/list")
    R<List<SysReClassUserDto>> getClassReUserList(@SpringQueryMap SysReClassUserDto sysReClassUserDto);

    @GetMapping("/sysClassSetting/external/getClassListByLocationIdList")
    R<List<SysClassSettingDto>> getClassListByLocationIdList(@RequestParam("locationIds") List<Long> locationIds);

    @GetMapping("/sysClassSetting/external/getLocationByGradeIn")
    R<List<ToySysClassSettingDto>> getLocationByGradeIn(@SpringQueryMap ToySysClassSettingDto sysClassSettingDto);

}
