package com.chushang.system.feign;

import com.chushang.common.core.constant.SecurityConstants;
import com.chushang.common.core.web.Result;
import com.chushang.security.entity.po.SysUser;
import com.chushang.security.entity.vo.LoginUser;
import com.chushang.system.constants.SystemConstants;
import com.chushang.system.entity.dto.ListUserDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

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

/**
 * by zhaowenyuan create 2022/5/20 10:05
 */
@FeignClient(contextId = "remoteUserService",
        value = SystemConstants.SYSTEM_SERVICE,
        path = SystemConstants.APPLICATION_CONTENT_PATH + "/user/remote"
)
public interface RemoteUserService {

    /**
     * 通过用户名查询用户信息
     *
     * @param username 用户名
     * @param source 请求来源
     * @return 结果
     */
    @GetMapping("/info/{username}")
    Result<LoginUser> getUserInfo(@PathVariable(value = "username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);



    /**
     * 通过用户id查询用户信息
     *
     * @param userId 用户id
     * @return 结果
     */
    @GetMapping("/getInfoById/{userId}")
    Result<SysUser> getInfoById(@PathVariable(value = "userId") Long userId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 通过用户名获取 对应的userId
     */
    @GetMapping("/username")
    Result<Map<String, Long>> getIdByUsernames(@RequestParam(value = "userNames") Set<String> userNames, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
    /**
     * 通过用户名获取 对应的userId
     */
    @GetMapping("/nickname")
    Result<Map<String, Long>> getIdByNicknames(@RequestParam(value = "nickNames") Set<String> nickNames, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    @GetMapping("/querynamebyid")
    Map<Long, SysUser> getUserNameByIds(@RequestParam(value = "userIds") Set<Long> userIds,
                                       @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @PostMapping("/user/list")
   Result<List<SysUser>> getSysUsers(@RequestBody ListUserDTO listUser) ;
}
