diff --git a/service-ai/database/service_ai_feedback.sql b/service-ai/database/service_ai_feedback.sql
index f9ce3ba..8baf92a 100644
--- a/service-ai/database/service_ai_feedback.sql
+++ b/service-ai/database/service_ai_feedback.sql
@@ -1,11 +1,18 @@
CREATE TABLE `service_ai_feedback`
(
- `id` bigint NOT NULL,
- `source` longtext NOT NULL,
- `conclusion` longtext,
+ `id` bigint NOT NULL,
+ `created_time` datetime(6) DEFAULT NULL,
+ `modified_time` datetime(6) DEFAULT NULL,
`analysis` longtext,
- `pictures` longtext,
- `status` varchar(50) NOT NULL DEFAULT 'ANALYSIS_PROCESSING',
- `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
- `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
-) DEFAULT CHARSET = utf8mb4;
\ No newline at end of file
+ `conclusion` longtext,
+ `source` longtext NOT NULL,
+ `status` tinyint NOT NULL,
+ PRIMARY KEY (`id`)
+) DEFAULT CHARSET = utf8mb4;
+
+CREATE TABLE `service_ai_feedback_pictures`
+(
+ `feedback_id` bigint NOT NULL,
+ `pictures_id` bigint NOT NULL,
+ PRIMARY KEY (`feedback_id`, `pictures_id`)
+) DEFAULT CHARSET = utf8mb4;
diff --git a/service-ai/database/service_ai_file.sql b/service-ai/database/service_ai_file.sql
index 9ee9588..d0bb88f 100644
--- a/service-ai/database/service_ai_file.sql
+++ b/service-ai/database/service_ai_file.sql
@@ -1,11 +1,12 @@
CREATE TABLE `service_ai_file`
(
- `id` bigint NOT NULL,
- `filename` varchar(500) DEFAULT NULL,
- `size` bigint DEFAULT NULL,
- `md5` varchar(100) DEFAULT NULL,
- `path` varchar(500) DEFAULT NULL,
- `type` varchar(50) DEFAULT NULL,
- `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ `id` bigint NOT NULL,
+ `created_time` datetime(6) DEFAULT NULL,
+ `modified_time` datetime(6) DEFAULT NULL,
+ `filename` varchar(255) DEFAULT NULL,
+ `md5` varchar(255) DEFAULT NULL,
+ `path` varchar(255) DEFAULT NULL,
+ `size` bigint DEFAULT NULL,
+ `type` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
-) DEFAULT CHARSET = utf8mb4;
\ No newline at end of file
+) DEFAULT CHARSET = utf8mb4;
diff --git a/service-ai/database/service_ai_group.sql b/service-ai/database/service_ai_group.sql
index b5c2333..eafead9 100644
--- a/service-ai/database/service_ai_group.sql
+++ b/service-ai/database/service_ai_group.sql
@@ -1,9 +1,10 @@
CREATE TABLE `service_ai_group`
(
`id` bigint NOT NULL,
+ `created_time` datetime(6) DEFAULT NULL,
+ `modified_time` datetime(6) DEFAULT NULL,
+ `name` varchar(255) NOT NULL,
+ `status` tinyint NOT NULL,
`knowledge_id` bigint NOT NULL,
- `name` varchar(100) NOT NULL,
- `status` varchar(10) NOT NULL DEFAULT 'RUNNING',
- `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
- `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
-) DEFAULT CHARSET = utf8mb4;
\ No newline at end of file
+ PRIMARY KEY (`id`)
+) DEFAULT CHARSET=utf8mb4;
diff --git a/service-ai/database/service_ai_knowledge.sql b/service-ai/database/service_ai_knowledge.sql
index 25f7b0a..90f30f5 100644
--- a/service-ai/database/service_ai_knowledge.sql
+++ b/service-ai/database/service_ai_knowledge.sql
@@ -1,11 +1,11 @@
CREATE TABLE `service_ai_knowledge`
(
`id` bigint NOT NULL,
- `vector_source_id` varchar(100) NOT NULL,
- `name` varchar(100) NOT NULL,
+ `created_time` datetime(6) DEFAULT NULL,
+ `modified_time` datetime(6) DEFAULT NULL,
`description` longtext NOT NULL,
- `strategy` varchar(10) NOT NULL,
- `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
- `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ `name` varchar(255) NOT NULL,
+ `strategy` tinyint NOT NULL,
+ `vector_source_id` bigint NOT NULL,
PRIMARY KEY (`id`)
-) DEFAULT CHARSET = utf8mb4;
\ No newline at end of file
+) DEFAULT CHARSET = utf8mb4;
diff --git a/service-ai/pom.xml b/service-ai/pom.xml
index 9763d44..472629d 100644
--- a/service-ai/pom.xml
+++ b/service-ai/pom.xml
@@ -110,6 +110,11 @@
jasypt-spring-boot-starter
3.0.5
+
+ com.blinkfox
+ fenix-spring-boot-starter
+ 3.0.0
+
diff --git a/service-ai/service-ai-core/src/main/java/com/lanyuanxiaoyao/service/ai/core/configuration/SnowflakeId.java b/service-ai/service-ai-core/src/main/java/com/lanyuanxiaoyao/service/ai/core/configuration/SnowflakeId.java
deleted file mode 100644
index 59da9ee..0000000
--- a/service-ai/service-ai-core/src/main/java/com/lanyuanxiaoyao/service/ai/core/configuration/SnowflakeId.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package com.lanyuanxiaoyao.service.ai.core.configuration;
-
-import java.time.Instant;
-
-/**
- * 使用雪花算法作为ID生成器
- *
- * @author lanyuanxiaoyao
- * @date 2024-11-14
- */
-public class SnowflakeId {
- /**
- * 起始的时间戳
- */
- private final static long START_TIMESTAMP = 1;
-
- /**
- * 序列号占用的位数
- */
- private final static long SEQUENCE_BIT = 11;
-
- /**
- * 序列号最大值
- */
- private final static long MAX_SEQUENCE_BIT = ~(-1 << SEQUENCE_BIT);
-
- /**
- * 时间戳值向左位移
- */
- private final static long TIMESTAMP_OFFSET = SEQUENCE_BIT;
-
- /**
- * 序列号
- */
- private static long sequence = 0;
- /**
- * 上一次时间戳
- */
- private static long lastTimestamp = -1;
-
- public static synchronized long next() {
- long currentTimestamp = nowTimestamp();
- if (currentTimestamp < lastTimestamp) {
- throw new RuntimeException("Clock have moved backwards.");
- }
-
- if (currentTimestamp == lastTimestamp) {
- // 相同毫秒内, 序列号自增
- sequence = (sequence + 1) & MAX_SEQUENCE_BIT;
- // 同一毫秒的序列数已经达到最大
- if (sequence == 0) {
- currentTimestamp = nextTimestamp();
- }
- } else {
- // 不同毫秒内, 序列号置为0
- sequence = 0;
- }
-
- lastTimestamp = currentTimestamp;
- return (currentTimestamp - START_TIMESTAMP) << TIMESTAMP_OFFSET | sequence;
- }
-
- private static long nextTimestamp() {
- long milli = nowTimestamp();
- while (milli <= lastTimestamp) {
- milli = nowTimestamp();
- }
- return milli;
- }
-
- private static long nowTimestamp() {
- return Instant.now().toEpochMilli();
- }
-}
diff --git a/service-ai/service-ai-web/pom.xml b/service-ai/service-ai-web/pom.xml
index 4e650c6..fa93ea7 100644
--- a/service-ai/service-ai-web/pom.xml
+++ b/service-ai/service-ai-web/pom.xml
@@ -53,7 +53,6 @@
com.blinkfox
fenix-spring-boot-starter
- 3.0.0
com.mysql
diff --git a/service-ai/service-ai-web/src/main/java/com/lanyuanxiaoyao/service/ai/web/base/controller/ListController.java b/service-ai/service-ai-web/src/main/java/com/lanyuanxiaoyao/service/ai/web/base/controller/ListController.java
index 02dd5b2..91ad12e 100644
--- a/service-ai/service-ai-web/src/main/java/com/lanyuanxiaoyao/service/ai/web/base/controller/ListController.java
+++ b/service-ai/service-ai-web/src/main/java/com/lanyuanxiaoyao/service/ai/web/base/controller/ListController.java
@@ -1,17 +1,16 @@
package com.lanyuanxiaoyao.service.ai.web.base.controller;
-import com.lanyuanxiaoyao.service.ai.core.entity.amis.AmisResponse;
+import com.lanyuanxiaoyao.service.ai.core.entity.amis.AmisCrudResponse;
import com.lanyuanxiaoyao.service.ai.web.base.controller.query.Query;
-import org.eclipse.collections.api.list.ImmutableList;
/**
* @author lanyuanxiaoyao
* @date 2024-11-28
*/
-public interface ListController {
+public interface ListController {
String LIST = "/list";
- AmisResponse> list() throws Exception;
+ AmisCrudResponse list() throws Exception;
- AmisResponse> list(Query query) throws Exception;
+ AmisCrudResponse list(Query query) throws Exception;
}
diff --git a/service-ai/service-ai-web/src/main/java/com/lanyuanxiaoyao/service/ai/web/base/controller/SimpleController.java b/service-ai/service-ai-web/src/main/java/com/lanyuanxiaoyao/service/ai/web/base/controller/SimpleController.java
index 93713c0..36e77e4 100644
--- a/service-ai/service-ai-web/src/main/java/com/lanyuanxiaoyao/service/ai/web/base/controller/SimpleController.java
+++ b/service-ai/service-ai-web/src/main/java/com/lanyuanxiaoyao/service/ai/web/base/controller/SimpleController.java
@@ -4,5 +4,5 @@ package com.lanyuanxiaoyao.service.ai.web.base.controller;
* @author lanyuanxiaoyao
* @date 2024-11-28
*/
-public interface SimpleController extends SaveController, ListController, DetailController, RemoveController {
+public interface SimpleController extends SaveController, ListController, DetailController, RemoveController {
}
diff --git a/service-ai/service-ai-web/src/main/java/com/lanyuanxiaoyao/service/ai/web/base/controller/SimpleControllerSupport.java b/service-ai/service-ai-web/src/main/java/com/lanyuanxiaoyao/service/ai/web/base/controller/SimpleControllerSupport.java
index bd9197f..5f077b1 100644
--- a/service-ai/service-ai-web/src/main/java/com/lanyuanxiaoyao/service/ai/web/base/controller/SimpleControllerSupport.java
+++ b/service-ai/service-ai-web/src/main/java/com/lanyuanxiaoyao/service/ai/web/base/controller/SimpleControllerSupport.java
@@ -1,13 +1,14 @@
package com.lanyuanxiaoyao.service.ai.web.base.controller;
import cn.hutool.core.util.ObjectUtil;
+import com.lanyuanxiaoyao.service.ai.core.entity.amis.AmisCrudResponse;
import com.lanyuanxiaoyao.service.ai.core.entity.amis.AmisResponse;
import com.lanyuanxiaoyao.service.ai.web.base.controller.query.Query;
import com.lanyuanxiaoyao.service.ai.web.base.entity.SimpleEntity;
import com.lanyuanxiaoyao.service.ai.web.base.service.SimpleServiceSupport;
+import java.util.List;
import lombok.extern.slf4j.Slf4j;
-import org.eclipse.collections.api.factory.Lists;
-import org.eclipse.collections.api.list.ImmutableList;
+import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
@@ -34,43 +35,52 @@ public abstract class SimpleControllerSupport> list() throws Exception {
+ public AmisCrudResponse list() throws Exception {
ListItemMapper mapper = listItemMapper();
- return AmisResponse.responseSuccess(service.list().collect(entity -> {
- try {
- return mapper.from(entity);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }));
+ return AmisCrudResponse.responseCrudData(
+ service.list()
+ .collect(entity -> {
+ try {
+ return mapper.from(entity);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ })
+ );
}
@PostMapping(LIST)
@Override
- public AmisResponse> list(@RequestBody Query query) throws Exception {
+ public AmisCrudResponse list(@RequestBody Query query) throws Exception {
if (ObjectUtil.isNull(query)) {
- return AmisResponse.responseSuccess(Lists.immutable.empty());
+ return AmisCrudResponse.responseCrudData(List.of(), 0);
}
ListItemMapper mapper = listItemMapper();
- return AmisResponse.responseSuccess(service.list(query).collect(entity -> {
- try {
- return mapper.from(entity);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }));
+ Page result = service.list(query);
+ return AmisCrudResponse.responseCrudData(
+ result.get()
+ .map(entity -> {
+ try {
+ return mapper.from(entity);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ })
+ .toList(),
+ result.getTotalElements()
+ );
}
@GetMapping(DETAIL)
@Override
- public AmisResponse detail(@PathVariable Long id) throws Exception {
+ public AmisResponse detail(@PathVariable("id") Long id) throws Exception {
DetailItemMapper mapper = detailItemMapper();
return AmisResponse.responseSuccess(mapper.from(service.detailOrThrow(id)));
}
@GetMapping(REMOVE)
@Override
- public AmisResponse