1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| package com.ioo.system.refactor_report.service;
import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import java.io.IOException;
@Slf4j @Service public class OldDateImportService {
public void main(SseEmitter emitter) { try { templateImport(emitter); } catch (Exception e) { Thread.currentThread().interrupt(); log.error(e.getMessage()); } finally { emitter.complete(); } }
private void sendDataToEmitter(SseEmitter emitter, String data) { try { emitter.send(SseEmitter.event().data(data)); } catch (IOException e) { emitter.completeWithError(e); } }
private void templateImport(SseEmitter emitter) { sendDataToEmitter(emitter, "模板导入开始");
sendDataToEmitter(emitter, "模板导入结束"); }
private void instanceImport(SseEmitter emitter) { sendDataToEmitter(emitter, "实例导入开始");
sendDataToEmitter(emitter, "实例导入结束"); }
private void contentTemplateImport(SseEmitter emitter) { sendDataToEmitter(emitter, "实例导入开始");
sendDataToEmitter(emitter, "实例导入结束"); } }
|