package com.yida.data.system.feign;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.constant.FebsServerConstant;
import com.yida.data.common.core.entity.system.Dept;
import com.yida.data.system.fallback.RemoteDeptUserviceFallback;
import com.yida.data.system.vo.AreaVO;
import com.yida.data.system.vo.SchoolClassInfoVO;
import io.swagger.annotations.ApiParam;

import java.util.List;

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;

@FeignClient(value = FebsServerConstant.FEBS_SERVER_SYSTEM, contextId = "deptServiceClient", fallbackFactory =
    RemoteDeptUserviceFallback.class)
public interface RemoteDeptService {

    /**
     * 获取下属部门
     */
    @GetMapping("/dept/findListByParent")
    ResultBean<List<Dept>> deptList(@RequestParam("deptId") Long deptId);

    /**
     * 根据部门获取学校
     */
    @GetMapping("/dept/findSchoolByDept")
    ResultBean<Dept> findSchoolByDept(@RequestParam("deptId") Long deptId);

    /**
     * 获取部门详情
     */
    @GetMapping("/dept/getInfoById")
    ResultBean<Dept> getInfoById(@RequestParam("deptId") Long deptId);

    /**
     * 获取部门详情
     */
    @GetMapping("/in/dept/getInfoById")
    ResultBean<Dept> getInfoByIdNoPermission(@RequestParam("deptId") Long deptId);

    /**
     * 获取区域内所有学校
     */
    @GetMapping("/dept/getSchoolByArea")
    ResultBean<List<Dept>> getSchoolByArea(@RequestParam("areaId") Long areaId,
        @RequestParam("schoolName") String schoolName);

    /**
     * 根据corpid获取学校
     */
    @GetMapping("/in/dept/getSchoolByCorp")
    ResultBean<Dept> getSchoolByCorp(@RequestParam("corpId") String corpId);

    /**
     * 根据微信公众号id获取学校
     *
     * @param appId
     * @return
     */
    @GetMapping("/in/dept/getSchoolByAppId")
    ResultBean<Dept> getSchoolByAppId(@RequestParam("appId") String appId);

    @GetMapping("/in/dept/getSchoolByName")
    ResultBean<Dept> getSchoolByName(@RequestParam("schoolName") String schoolName);

    @GetMapping("/in/dept/getParentById")
    ResultBean<Dept> getParentById(@RequestParam("id") Long id);

    /**
     * 获取学校下属部门（非家校部门）
     */
    @GetMapping("/in/dept/getDeptBySchoolAndName")
    ResultBean<Dept> getDeptBySchoolAndName(@RequestParam("schoolId") Long schoolId,
        @RequestParam("deptName") String deptName);

    /**
     * 获取学校和区域信息
     */
    @GetMapping("/dept/getSchoolAreaInfo")
    ResultBean<SchoolClassInfoVO> getSchoolAreaInfo(@RequestParam("schoolId") Long schoolId);

    /**
     * 获取部门树
     */
    @GetMapping("/dept/getPageSchoolByArea")
    ResultBean<IPage<Dept>> getPageSchoolByArea(@ApiParam("类型") @RequestParam(required = false) Long areaId,
        @ApiParam("搜索关键词 学校名") @RequestParam(required = false) String schoolName,
        @ApiParam("当前页码") @RequestParam(defaultValue = "1") Integer pageNum,
        @ApiParam("页面大小") @RequestParam(defaultValue = "10") Integer pageSize);

    /**
     * 获取学校地区
     *
     * @param id
     * @return
     */
    @GetMapping("/dept/findAreaById")
    ResultBean<AreaVO> findAreaById(@RequestParam("id") Long id);

    @GetMapping("/dept/findChildByParent")
    ResultBean<List<Dept>> findChildByParent(@RequestParam("deptId") Long deptId,
        @RequestParam("type") Integer type);

    /**
     * 根据学校类型查询学校
     */
    @GetMapping("/in/dept/listSchoolBySchoolType")
    ResultBean<List<Dept>> listSchoolBySchoolType(@RequestParam("schoolType") String schoolType);

    /**
     * 同步企业微信部门
     */
    @GetMapping("/in/dept/syncQywxDept")
    ResultBean syncQywxDept();

    /**
     * 处理挂在学校下的部门
     */
    @GetMapping("/in/dept/dealNoParentDept")
    ResultBean dealNoParentDept();

    /**
     * 查询学校部门
     *
     * @param schoolId
     * @param wxId
     * @return
     */
    @GetMapping("/in/dept/getDeptBySchoolAndWxId")
    ResultBean<Dept> getDeptBySchoolAndWxId(@RequestParam("schoolId") Long schoolId,
        @RequestParam("wxId") Long wxId);

    /**
     * 查询部门列表
     *
     * @param ids 部门id
     * @return
     */
    @PostMapping("/in/dept/listDept")
    ResultBean<List<Dept>> listDept(@RequestBody List<Long> ids);

    /**
     * 向上查询父级部门集合，包含子部门
     *
     * @param ids
     * @return
     */
    @PostMapping("/in/dept/findParentDeptByChilds")
    ResultBean<List<Dept>> listParentDeptByChild(@RequestBody List<Long> ids);


    @PostMapping("/in/dept/getDeptTree")
    ResultBean<List> getDeptTree(@RequestBody List<Long> deptIds);
}
