package cn.reghao.bnt.web.ws.event;

import cn.reghao.bnt.common.msg.event.EvtAppStatResult;
import cn.reghao.bnt.web.devops.app.service.AppDeployService;
import cn.reghao.jutil.jdk.event.handler.Handler;
import cn.reghao.jutil.jdk.event.message.Event;
import lombok.extern.slf4j.Slf4j;

/**
 * @author reghao
 * @date 2022-05-05 17:41:32
 */
@Slf4j
public class EvtAppStatResultHandler extends Handler {
    private final AppDeployService appDeployService;

    public EvtAppStatResultHandler(AppDeployService appDeployService) {
        this.appDeployService = appDeployService;
    }

    @Override
    public void handle(Event evt) {
        EvtAppStatResult statResult = (EvtAppStatResult) evt;
        if (statResult.getDeploy()) {
            appDeployService.updateAfterDeploy(statResult);
        } else {
            appDeployService.updateAppDeployingNode(statResult);
        }
    }
}
