37 lines
971 B
Java
37 lines
971 B
Java
package de.ph87.data;
|
|
|
|
import de.ph87.data.topic.TopicDto;
|
|
import de.ph87.data.topic.TopicService;
|
|
import de.ph87.data.topic.TopicType;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
|
import org.springframework.context.event.EventListener;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
@Slf4j
|
|
@Service
|
|
@RequiredArgsConstructor
|
|
public class DemoService {
|
|
|
|
private final DemoConfig demoConfig;
|
|
|
|
private final TopicService topicService;
|
|
|
|
@Transactional
|
|
@EventListener(ApplicationReadyEvent.class)
|
|
public void init() {
|
|
if (!demoConfig.isEnabled()) {
|
|
return;
|
|
}
|
|
final TopicDto dto = topicService.create();
|
|
topicService.modify(dto.id, topic -> {
|
|
topic.setEnabled(true);
|
|
topic.setName("openDTU/pv/patrix/json2");
|
|
topic.setType(TopicType.PatrixOpenDtu);
|
|
});
|
|
}
|
|
|
|
}
|