package com.mortals.xhx.feign.user;

import com.mortals.xhx.common.pdu.UserPdu;
import com.mortals.xhx.feign.IFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * 用户服务
 *
 * @author: zxfei
 * @date: 2022/5/30 10:40
 */
@FeignClient(name = "base-manager", path = "/base", fallback = UserFeignFallbackFactory.class)
public interface IApiUserFeign extends IFeign {

    /**
     * 门户登录
     *
     * @param req
     * @return
     */
    @PostMapping("/login/login")
    String portalLogin(@RequestBody UserPdu req);

}


@Slf4j
@Component
class UserFeignFallbackFactory implements FallbackFactory<IApiUserFeign> {
    @Override
    public IApiUserFeign create(Throwable t) {
        return new IApiUserFeign() {

            @Override
            public String portalLogin(UserPdu req) {
                return null;
            }
        };
    }
}