package com.ho.business.feignclient;

import com.ho.common.tools.constant.ContextConstant;
import com.ho.common.tools.exception.DataResult;
import com.ho.user.api.entity.SysDept;
import com.ho.user.api.entity.SysLog;
import com.ho.user.api.entity.SysUser;
import com.ho.user.api.vo.req.QueryDeptReqVO;
import com.ho.user.api.vo.req.QueryUserReqVO;
import com.ho.user.api.vo.req.SysSubDictVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

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

/**
 * @描述 调用user-center
 * @创建时间 2021/8/9
 * @修改人
 */
@FeignClient(value = ContextConstant.USER_CENTER, fallback = UserFeignClientFallback.class)
public interface UserFeignClient {

    // 根据部门id查对象
    @PostMapping(value = ContextConstant.ROOT_CONTEXT + "outerApi/getTopDept")
    DataResult<SysDept> getTopDept(@RequestBody QueryDeptReqVO vo);

    // 根据部门id查对象
    @PostMapping(value = ContextConstant.ROOT_CONTEXT + "outerApi/getDept")
    DataResult<List<SysDept>> queryDept(@RequestBody List<QueryDeptReqVO> queryDeptReqVOs);

    //根据用户id查询用户
    @PostMapping(value = ContextConstant.ROOT_CONTEXT + "outerApi/getUsers")
    DataResult<List<SysUser>> queryUser(@RequestBody List<QueryUserReqVO> queryUserReqVO);

    //根据用户名模糊 查询用户
    @PostMapping(value = ContextConstant.ROOT_CONTEXT + "outerApi/getUserByNameConcat")
    DataResult<List<SysUser>> getUserByNameConcat(@RequestBody QueryUserReqVO queryUserReqVO);

    //发送用户中心日志
    @PostMapping(value = ContextConstant.ROOT_CONTEXT + "outerApi/insertLog")
    DataResult insertLog(@RequestBody SysLog sysLog);

    //查询字典
    @PostMapping(value = ContextConstant.ROOT_CONTEXT + "outerApi/getSysSubDict")
    Map<String, String> getSysSubDict(@RequestBody SysSubDictVO vo);

    @PostMapping(value = ContextConstant.ROOT_CONTEXT + "outerApi/getUserById")
    DataResult<SysUser> getUserById(String userId);

    /**
     * 根据deptId获取其本身与其子集的集合
     * @param deptId
     * @return
     */
    @PostMapping(value = ContextConstant.ROOT_CONTEXT + "outerApi/getSysDeptByDeptId")
    List<SysDept> getSysDeptByDeptId(Integer deptId);
}
