jiazx0107@163.com
2023-10-24 f2cacfb5c8760d2b9b539821cc9e13054dbc1320
src/main/java/com/fzzy/gateway/sc2023/api/ApiInitService.java
@@ -1,7 +1,12 @@
package com.fzzy.gateway.sc2023.api;
import com.fzzy.gateway.entity.GatewayConf;
import com.fzzy.gateway.service.GatewayConfService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
 * 当前接口,初始化相关
@@ -10,6 +15,26 @@
@Component
public class ApiInitService {
    @Resource
    private GatewayConfService confService;
    @Resource
    private GatewayRemoteManager gatewayRemoteManager;
    public void init() {
        List<GatewayConf> list = confService.listAll();
        if (null == list || list.isEmpty()) {
            return;
        }
        GatewayRemoteService gatewayRemoteService;
        for (GatewayConf gatewayConf : list) {
            gatewayRemoteService = gatewayRemoteManager.getRemoteService(gatewayConf.getPushProtocol());
            gatewayRemoteService.authorize(gatewayConf);
        }
    }
}