package com.mortals.xhx.base.framework.config;

import com.mortals.framework.springcloud.config.web.BaseWebMvcConfigurer;
import com.mortals.xhx.base.framework.WxMessageConverter;
import com.mortals.xhx.base.framework.feign.HierarchicalContract;
import feign.Contract;
import feign.codec.Decoder;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.cloud.openfeign.support.SpringDecoder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author: zxfei
 * @date: 2021/8/13 0:24
 * @description:
 **/
@Configuration
public class AccountConfig {
    @Bean
    public Contract feignContract() {
        return new HierarchicalContract();
    }

    @Bean
    public BaseWebMvcConfigurer getBaseWebMvc(){
        return new BaseWebMvcConfigurer(false,null);
    }

    @Bean
    public Decoder feignDecoder() {
        WxMessageConverter wxConverter = new WxMessageConverter();
        ObjectFactory<HttpMessageConverters> objectFactory = () -> new HttpMessageConverters(wxConverter);
        return new SpringDecoder(objectFactory);
    }

}
