|
@@ -7,8 +7,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
-import java.util.concurrent.CompletableFuture;
|
|
|
|
-
|
|
|
|
@Component
|
|
@Component
|
|
public class ComfyUtil {
|
|
public class ComfyUtil {
|
|
|
|
|
|
@@ -16,43 +14,41 @@ public class ComfyUtil {
|
|
private ComfyuiTaskDao comfyuiTaskDao;
|
|
private ComfyuiTaskDao comfyuiTaskDao;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * [新增] 生成任务的记录 (异步)
|
|
|
|
|
|
+ * [新增] 生成任务的记录
|
|
*/
|
|
*/
|
|
- public void asyncInsertTaskRecord(String prompt_id, String prompt) {
|
|
|
|
|
|
+ public void insertComfyuiTask(String prompt, String type) {
|
|
Long user_id = SecurityUtil.getUserId();
|
|
Long user_id = SecurityUtil.getUserId();
|
|
- CompletableFuture.runAsync(() -> {
|
|
|
|
- // [DB] 新增任务记录
|
|
|
|
- try {
|
|
|
|
- System.out.println("-- 新增任务记录 --");
|
|
|
|
- ComfyuiTask comfyuiTask = new ComfyuiTask();
|
|
|
|
- comfyuiTask.setUser_id(user_id);
|
|
|
|
- comfyuiTask.setPrompt_id(prompt_id);
|
|
|
|
- comfyuiTask.setGenerate_request(prompt);
|
|
|
|
- comfyuiTaskDao.insert(comfyuiTask);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- System.out.println(e.getMessage());
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ try {
|
|
|
|
+ System.out.println("-- 新增任务记录 --");
|
|
|
|
+ ComfyuiTask comfyuiTask = new ComfyuiTask();
|
|
|
|
+ comfyuiTask.setUser_id(user_id);
|
|
|
|
+ comfyuiTask.setType(type);
|
|
|
|
+ comfyuiTask.setGenerate_request(prompt);
|
|
|
|
+
|
|
|
|
+ comfyuiTaskDao.insert(comfyuiTask);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ System.out.println(e.getMessage());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
- * [更新] 生成任务的记录 (异步)
|
|
|
|
|
|
+ * [更新] 生成任务的记录
|
|
|
|
+ * - status: 任务状态 (-1:未开始, 1:进行中, 2:成功, 3:失败)
|
|
*/
|
|
*/
|
|
- public void asyncUpdateTaskRecord(String prompt_id, String response, Integer status) {
|
|
|
|
- CompletableFuture.runAsync(() -> {
|
|
|
|
- // [DB] 新增任务记录
|
|
|
|
- try {
|
|
|
|
- System.out.println("-- 更新任务记录 --");
|
|
|
|
- LambdaQueryWrapper<ComfyuiTask> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
- wrapper.eq(ComfyuiTask::getPrompt_id, prompt_id);
|
|
|
|
-
|
|
|
|
- ComfyuiTask comfyuiTask = new ComfyuiTask();
|
|
|
|
- comfyuiTask.setStatus(status);
|
|
|
|
- comfyuiTask.setGenerate_response(response);
|
|
|
|
- comfyuiTaskDao.update(comfyuiTask, wrapper);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- System.out.println(e.getMessage());
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ public void updateComfyuiTask(String prompt_id, String response, Integer status) {
|
|
|
|
+ try {
|
|
|
|
+ System.out.println("-- 更新任务记录 --");
|
|
|
|
+ LambdaQueryWrapper<ComfyuiTask> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper.eq(ComfyuiTask::getPrompt_id, prompt_id);
|
|
|
|
+
|
|
|
|
+ ComfyuiTask comfyuiTask = new ComfyuiTask();
|
|
|
|
+ comfyuiTask.setStatus(status);
|
|
|
|
+ comfyuiTask.setPrompt_id(prompt_id);
|
|
|
|
+ comfyuiTask.setGenerate_response(response);
|
|
|
|
+
|
|
|
|
+ comfyuiTaskDao.update(comfyuiTask, wrapper);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ System.out.println(e.getMessage());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|