1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- package com.shkpr.service.alambizplugin.dto;
- import com.fasterxml.jackson.annotation.JsonFormat;
- import com.shkpr.service.alambizplugin.constants.CommAsyncStatusEnum;
- import lombok.Data;
- import org.springframework.format.annotation.DateTimeFormat;
- import java.time.LocalDateTime;
- import java.util.List;
- import java.util.Map;
- /**
- * 通用异步结果
- *
- * @author 欧阳劲驰
- * @since 1.0.0
- */
- @Data
- public class CommAsyncResult<T> {
- /**
- * id
- */
- private String id;
- /**
- * 检查状态:0:进行中,1:成功,2:失败,3:不存在
- */
- private Integer status;
- /**
- * 操作人
- */
- private String operator;
- /**
- * 子项key
- */
- private List<String> subitemKeys;
- /**
- * 结果数据
- */
- private T data;
- /**
- * 请求检查时间
- */
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh_CN", timezone = "Asia/Shanghai")
- @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
- private LocalDateTime requestTime;
- /**
- * 完成检查时间
- */
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh_CN", timezone = "Asia/Shanghai")
- @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
- private LocalDateTime completeTime;
- /**
- * 数据更新时间
- */
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh_CN", timezone = "Asia/Shanghai")
- @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
- private Map<String, LocalDateTime> refreshTimes;
- /**
- * 进行中
- */
- public static <T> CommAsyncResult<T> inProgress(String id, LocalDateTime requestTime, String operator) {
- CommAsyncResult<T> result = new CommAsyncResult<>();
- result.setId(id);
- result.setStatus(CommAsyncStatusEnum.IN_PROGRESS.getCode());
- result.setRequestTime(requestTime);
- result.setOperator(operator);
- return result;
- }
- /**
- * 成功
- */
- public static <T> CommAsyncResult<T> success(String id) {
- CommAsyncResult<T> result = new CommAsyncResult<>();
- result.setId(id);
- result.setStatus(CommAsyncStatusEnum.SUCCESS.getCode());
- result.setRequestTime(LocalDateTime.now());
- return result;
- }
- /**
- * 失败
- */
- public static <T> CommAsyncResult<T> fail(String id) {
- CommAsyncResult<T> result = new CommAsyncResult<>();
- result.setId(id);
- result.setStatus(CommAsyncStatusEnum.FAIL.getCode());
- result.setRequestTime(LocalDateTime.now());
- return result;
- }
- }
|