package com.yonge.cooleshow.auth.api.client;

import com.yonge.cooleshow.auth.api.client.fallback.SysUserFeignServiceFallback;
import com.yonge.cooleshow.auth.api.dto.RealnameAuthReq;
import com.yonge.cooleshow.auth.api.dto.SysUserQueryInfo;
import com.yonge.cooleshow.auth.api.entity.SysUser;
import com.yonge.cooleshow.common.entity.HttpResponseResult;
import com.yonge.toolset.feign.config.FeignConfiguration;
import com.yonge.toolset.utils.idcard.IdcardInfoExtractor;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(contextId = "sysUserFeignService", name = "auth-server", configuration = { FeignConfiguration.class }, fallback = SysUserFeignServiceFallback.class)
public interface SysUserFeignService {

	@GetMapping(value = "user/queryUserById/{userId}")
	public SysUser queryUserById(@PathVariable("userId") Long userId);

	@GetMapping(value = "user/queryUserByPhone")
	public SysUser queryUserByMobile(@RequestParam("mobile") String mobile);

	@PostMapping(value = "user/add", consumes = MediaType.APPLICATION_JSON_VALUE)
	public HttpResponseResult<Long> add(SysUser user);

	@PostMapping(value = "user/update", consumes = MediaType.APPLICATION_JSON_VALUE)
	public HttpResponseResult<Integer> update(SysUser user);

	@GetMapping(value = "queryUserInfo")
	public SysUser queryUserInfo();

	@GetMapping(value = "role/queryRoleCodeListByUserId")
	public List<String> queryRoleCodeListByUserId(@RequestParam("userId") Long userId);

	@PostMapping(value = "user/updateSysUser", consumes = MediaType.APPLICATION_JSON_VALUE)
	public HttpResponseResult<Boolean> updateSysUser(SysUser user);

	@PostMapping(value = "exit/{clientId}/{phone}", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
	public HttpResponseResult<String> exitByPhone(@PathVariable("clientId") String clientId, @PathVariable("phone") String phone);

	@PostMapping(value = "user/realNameAuth")
	public HttpResponseResult<IdcardInfoExtractor> realNameAuth(@RequestBody RealnameAuthReq realNameAuthDto);

	@PostMapping(value = "user/bindOpenId")
	HttpResponseResult<Boolean> bindOpenId(@RequestBody SysUser user);

	@PostMapping(value = "/refreshToken")
	@ApiOperation(value = "刷新token")
	HttpResponseResult refreshToken(@RequestParam("refreshToken")String refreshToken,
										   @RequestParam("clientId")String clientId,
										   @RequestParam("clientSecret")String clientSecret);

	@PostMapping(value = "exit",consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
	@ApiOperation(value = "退出登录")
	HttpResponseResult<String> logout();

	@PostMapping(value = "user/list")
	HttpResponseResult<List<SysUser>> page(@RequestBody SysUserQueryInfo queryInfo);

}
