jiazx0107@163.com
2023-11-18 328eba66ddc6fdf2f324b9cd04cd6acec9f642de
src/main/java/com/fzzy/gateway/hx2023/service/ApiInitService.java
@@ -1,28 +1,37 @@
package com.fzzy.gateway.hx2023.service;
import com.bstek.dorado.annotation.Expose;
import com.fzzy.gateway.api.GatewayRemoteManager;
import com.fzzy.gateway.api.GatewayRemoteService;
import com.fzzy.gateway.entity.GatewayConf;
import com.fzzy.gateway.service.GatewayConfService;
import lombok.extern.slf4j.Slf4j;
import com.fzzy.gateway.service.GatewayDeviceService;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
 * 当前接口,初始化相关
 */
@Slf4j
@Component
public class ApiInitService {
    @Resource
    private GatewayConfService confService;
    @Resource
    private GatewayDeviceService deviceService;
    @Resource
    private GatewayRemoteManager gatewayRemoteManager;
    /**
     * apiInitService#init
     */
    @Expose
    public void init() {
        List<GatewayConf> list = confService.listAll();
@@ -34,9 +43,13 @@
        GatewayRemoteService gatewayRemoteService;
        for (GatewayConf gatewayConf : list) {
            gatewayRemoteService = gatewayRemoteManager.getRemoteService(gatewayConf.getPushProtocol());
            gatewayRemoteService.authorize(gatewayConf);
            gatewayRemoteService.init(gatewayConf);
        }
    }
    public void updateDeviceCache() {
        deviceService.flushCache();
    }
}