/**
 * 
 */
package org.springblade.system.client;

import java.util.List;

import org.springblade.common.openfeign.OpenFeignConstants;
import org.springblade.system.client.factory.UserClientFallbackFactory;
import org.springblade.system.client.model.UserModel;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author wookvn
 *
 */
@FeignClient(contextId = "userClient", 
	value = OpenFeignConstants.SYSTEM_SERVICE, 
	fallbackFactory = UserClientFallbackFactory.class)
public interface UserClient {

	/**
	 * 根据ID查询
	 * @param id
	 * @return
	 */
	@GetMapping(OpenFeignConstants.SYSTEM_SERVICE + "/user/info/{id}")
	public UserModel getById(@PathVariable Long id);
	
	/**
	 * 根据ID列表查询
	 * @param ids
	 * @return
	 */
	@GetMapping(OpenFeignConstants.SYSTEM_SERVICE + "/user/listByIds")
	public List<UserModel> listByIds(@RequestParam List<Long> ids);
	
	/**
	 * 
	 * @param deptId - 传空查询所有
	 * @return
	 */
	@GetMapping(OpenFeignConstants.SYSTEM_SERVICE + "/user/listByDeptId")
	public List<UserModel> listByDeptId(@RequestParam(value = "deptId", required = false) Long deptId);
	
	/**
	 * 根据ID生成accessToken
	 * @param id
	 * @return
	 */
	@GetMapping(OpenFeignConstants.SYSTEM_SERVICE + "/user/genAccessToken/{id}")
	public String genAccessToken(@PathVariable Long id);


	/**
	 * 根据thirdUserId查询
	 */
	@GetMapping(OpenFeignConstants.SYSTEM_SERVICE + "/user/infoByThirdUserId/{thirdUserId}")
	public UserModel getByThirdUserId(@PathVariable String thirdUserId);


	/**
	 * 根据ID生成accessToken
	 * @param id
	 * @return
	 */
	@GetMapping(OpenFeignConstants.SYSTEM_SERVICE + "/user/genToken/{id}/{expireIn}")
	public String genToken(@PathVariable Long id,@PathVariable String expireIn);


	/**
	 *
	 * @param roleId - 查询角色下的用户
	 * @return
	 */
	@GetMapping(OpenFeignConstants.SYSTEM_SERVICE + "/listByRoleId")
	public List<UserModel> listByRoleId(@RequestParam(value = "roleId", required = true)String roleId);

	/**
	 *
	 * @param postId - 查询岗位下的用户
	 * @return
	 */
	@GetMapping(OpenFeignConstants.SYSTEM_SERVICE + "/listByPostId")
	public List<UserModel> listByPostId(@RequestParam(value = "postId", required = true)String postId);

	/**
	 * 根据租户id查询用户信息
	 * @param tenantId
	 * @return
	 */
	@GetMapping(OpenFeignConstants.SYSTEM_SERVICE + "listByTenantId")
	public List<UserModel> listByTenantId(@RequestParam(value = "tenantId", required = true) String tenantId);
}
