package com.yida.data.user.feign;

import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.constant.FebsServerConstant;
import com.yida.data.common.core.entity.user.EduStaff;
import com.yida.data.common.core.entity.user.EduStaffDept;
import com.yida.data.common.core.entity.user.EduTeacherDept;
import com.yida.data.user.dto.ListStaffDTO;
import com.yida.data.user.fallback.RemoteStaffServiceFallback;
import com.yida.data.user.vo.TeacherClassVO;
import com.yida.data.user.vo.TeacherDeptVO;
import io.swagger.annotations.ApiParam;
import org.apache.ibatis.annotations.Param;
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_USER, contextId = "StaffServiceClient",
    fallbackFactory = RemoteStaffServiceFallback.class)
public interface RemoteStaffService {


    /**
     * 根据教师id查询教师角色
     *
     * @param teacherId 教师id
     * @return
     */
    @GetMapping("/staff/findTeacherRole")
    ResultBean<List<EduTeacherDept>> findTeacherRole(@RequestParam("teacherId") Long teacherId,
        @RequestParam("type") Integer type);

    /**
     * 查询教师可见课程
     *
     * @param teacherId
     * @param schoolId
     * @return
     */
    @GetMapping("/staff/findTeacherCourseId")
    ResultBean<List<Long>> findTeacherCourseId(@RequestParam("teacherId") Long teacherId,
        @RequestParam("schoolId") Long schoolId);

    /**
     * 根据id查询职工信息
     */
    @GetMapping("/in/staff/getStaff")
    ResultBean<EduStaff> getStaffNoPermission(@RequestParam("id") Long id);

    /**
     * 通过部门id，名字或者手机号查询员工id
     *
     * @param deptId
     * @param nameOrPhone
     * @param schoolId
     * @return
     */
    @GetMapping("/staff/listStaffByDeptId")
    ResultBean<List<Long>> listStaffByDeptId(@RequestParam("deptId") @Param("deptId") Long deptId,
        @RequestParam("nameOrPhone") @Param("nameOrPhone") String nameOrPhone,
        @RequestParam("schoolId") Long schoolId);


    @GetMapping("/in/staff/listStaffByDeptId")
    ResultBean<List<Long>> listStaffByDeptIdNoPermission(@RequestParam("deptId") @Param("deptId") Long deptId,
        @RequestParam("nameOrPhone") @Param("nameOrPhone") String nameOrPhone,
        @RequestParam("schoolId") Long schoolId);

    /**
     * 根据条件查询职工列表
     */
    @PostMapping("/in/staff/listStaff")
    ResultBean<List<EduStaff>> listStaff(@RequestBody ListStaffDTO dto);

    /**
     * 查询职工信息
     */
    @GetMapping("/in/staff/getStaff")
    ResultBean<EduStaff> getStaff(@RequestParam("id") Long id);

    /**
     * 查询职工部门信息
     *
     * @param staffIds
     * @return
     */
    @PostMapping("/staff/getStaffDeptByStaffIds")
    ResultBean<List<EduStaffDept>> getStaffDeptByStaffIds(@ApiParam("职工id") @RequestBody List<Long> staffIds);

    @PostMapping("/in/staff/getStaffDeptByStaffIds")
    ResultBean<List<EduStaffDept>> getStaffDeptByStaffIdsNoPermission(@ApiParam("职工id") @RequestBody List<Long> staffIds);

    @GetMapping("/in/staff/syncQywxStaff")
    ResultBean syncQywxStaff();


    /**
     * 初始化职工信息
     */
    @PostMapping("/staff/initStaff")
    ResultBean initStaff(@RequestBody List<EduStaff> teacherList);

    /**
     * 根据职工微信id查询职工信息
     */
    @GetMapping("/in/staff/getStaffByWxOrMobileOrOpenId")
    ResultBean<EduStaff> getStaffByWxOrMobileOrOpenId(@RequestParam("wxId") String wxId,
        @RequestParam("mobile") String mobile,
        @RequestParam("wxOpenId") String wxOpenId,
        @RequestParam("schoolId") Long schoolId);

    /**
     * 处理企业微信职工删除
     */
    @GetMapping("/in/staff/dealWxUserDelete")
    ResultBean dealWxUserDelete(@RequestParam("wxId") String wxId,
        @RequestParam("schoolId") Long schoolId);

    @GetMapping("/in/staff/getStaffByDahua")
    ResultBean<EduStaff> getStaffByDahuaNoPermission(@RequestParam("dahuaCode") String dahuaCode);

    /**
     * 查询教师可见班级
     *
     * @param teacherId
     * @return
     */
    @GetMapping("/staff/listClassByTeacher")
    ResultBean<List<TeacherClassVO>> listClassByTeacher(@RequestParam("teacherId") Long teacherId);

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


    @GetMapping("/in/staff/listStaffRolesByStaffId")
    ResultBean<List<Integer>> listStaffRolesByStaffId(@RequestParam("staffId") Long staffId);

    /**
     * 根据职工id集合查询职工信息
     *
     * @param staffIds 职工id集合
     * @return com.yida.data.common.core.common.ResultBean<java.util.List < com.yida.data.common.core.entity.user.EduStaff>>
     * @author ZYJ
     * @date 2023/6/8 17:24
     */
    @PostMapping("/staff/getStaffList")
    ResultBean<List<EduStaff>> getStaffList(@RequestBody List<Long> staffIds);

    /**
     * 更新职工信息缓存
     *
     * @return
     */
    @GetMapping("in/staff/updateStaffCache")
    ResultBean updateStaffCache();

    /**
     * 查询职工管理班级
     *
     * @return
     */
    @GetMapping("in/staff/listClassIdByStaffId")
    ResultBean<List<Long>> listClassIdByStaffId();
}