feat: AI 调用改为异步任务并支持结果重复获取
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package com.guo.learningprogresstracker.dto.request;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 提交 AI 任务请求(AI-02)。
|
||||
*/
|
||||
@Data
|
||||
public class AiTaskSubmitRequest {
|
||||
|
||||
@NotBlank(message = "请先指定要处理的类型")
|
||||
private String type;
|
||||
|
||||
@NotBlank(message = "请先指定要处理的对象")
|
||||
private String targetNum;
|
||||
|
||||
/** 类型相关的参数;无需参数时可为空 */
|
||||
private Map<String, Object> params;
|
||||
|
||||
/** 阅读友好度:null 表示不关心 */
|
||||
public String paramAsString(String key) {
|
||||
Object value = params == null ? null : params.get(key);
|
||||
return value == null ? null : String.valueOf(value);
|
||||
}
|
||||
|
||||
public Integer paramAsInteger(String key) {
|
||||
Object value = params == null ? null : params.get(key);
|
||||
if (value instanceof Number number) {
|
||||
return number.intValue();
|
||||
}
|
||||
if (value instanceof String text && !text.isBlank()) {
|
||||
try {
|
||||
return Integer.valueOf(text.trim());
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user