zm
2020-05-18 a18bfacbf56b401f6e0fdae8710fbca4df8cff77
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.changhong.epc.zuul.config;
 
import com.codingapi.tx.config.service.TxManagerTxUrlService;
import com.codingapi.tx.netty.service.TxManagerHttpRequestService;
import com.lorne.core.framework.utils.http.HttpUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
 
@Configuration
@Slf4j
public class TxManagerConfig {
 
    @Value("${tm.manager.url}")
    private String url;
 
    @Bean
    public TxManagerTxUrlService txManagerTxUrlService(){
        return ()->url;
    }
 
    @Bean
    public TxManagerHttpRequestService txManagerHttpRequestService(){
        return new TxManagerHttpRequestService(){
 
            @Override
            public String httpGet(String url) {
                log.debug("httpGet-start:{}", url);
                String res = HttpUtils.get(url);
                log.debug("httpGet-end:{}", url);
                return res;
            }
 
            @Override
            public String httpPost(String url, String params) {
                log.debug("httpPost-start:{}@{}", url, params);
                String res = HttpUtils.post(url,params);
                log.debug("httpPost-end:{}@{}", url, params);
                return res;
            }
        };
    }
}