package com.sptg.permissions.api.feigns;

import com.sptg.common.core.beans.ResultBean;
import com.sptg.permissions.api.dto.AccountDto;
import com.sptg.permissions.api.dto.LoginDto;
import com.sptg.permissions.api.entity.Account;
import com.sptg.permissions.api.feigns.fallback.AccountAuthenticationFeignFallbackFactory;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.io.Serializable;


/**
 * title: AccountAuthenticationFeign
 * package: com.sptg.permissions.api.feigns
 * description: 认证相关接口
 *
 *                  
 *                 
 */
@FeignClient(value = "smart-house-permissions",fallbackFactory = AccountAuthenticationFeignFallbackFactory.class)
public interface AccountAuthenticationFeign {

    /**
     * 自动登陆接口
     * @param loginDto 登陆接口数据传输对象
     * @return Account
     */
    @PostMapping(value ="/account/authLogin")
    Account authLogin(@RequestBody LoginDto loginDto);

    /**
     * 用户登陆接口
     * @param loginDto 登陆接口数据传输对象
     * @return ResultBean<AccountDto> 若登陆成功,则返回用户信息.
     */
    @PostMapping(value ="/account/login")
    ResultBean<Account> login(@RequestBody LoginDto loginDto);

    /**
     * 用户第三方授权登陆接口
     * @param loginDto 登陆接口数据传输对象
     * @return ResultBean<AccountDto> 若登陆成功,则返回用户信息.
     */
    @PostMapping(value ="/account/oauth/login")
    ResultBean<Account> oauthLogin(@RequestBody LoginDto loginDto);

    /**
     * 功能描述: 重新加载账号信息
     * @param id 账号Id
     * @return Account
     *                  
     *                       
     */
    @GetMapping(value = "/account/reload/{id}")
    Account reload(@PathVariable(value = "id") Serializable id);
    /**
     * 功能描述: 根据openid获取账号信息
     * @param openid
     * @return  ResultBean<Account>
     *               
     *                      
     */
    @PostMapping(value = "/account/getByOpenid")
    ResultBean<Account> getByOpenid(@RequestBody String openid);
    /**
     * 功能描述: 账号绑定微信--绑定openid
     * @param dto
     * @return  ResultBean<Account>
     *               
     *                      
     */
    @PostMapping(value = "/account/bindOpenid")
    ResultBean<Boolean> bindOpenid(@RequestBody AccountDto dto);
}
