package com.yuchen.saas.park.service.listener;

import com.yuchen.saas.park.api.event.InspectTaskApplicationEvent;
import com.yuchen.saas.park.service.service.FireInspectTaskService;
import lombok.extern.slf4j.Slf4j;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @description: TODO
 * @author
 * @date 2022/10/24 下午5:48
 * @version 0.3.0
 */
@Slf4j
@Service
public class InspectTaskEventListener implements ApplicationListener<InspectTaskApplicationEvent> {

    @Resource
    private FireInspectTaskService fireInspectTaskService;

    @Override
    public void onApplicationEvent(InspectTaskApplicationEvent event) {
        //创建任务
        R<Boolean> create = fireInspectTaskService.create(event.getPlanId());
        if(!create.isSuccess()){
            log.error("新增计划,创建任务失败");
        }
    }
}
