getImportTypes() {
22 |
23 | return Set.of(entityType);
24 | }
25 | }
--------------------------------------------------------------------------------
/uni-ai-backend/generator-processor/src/main/java/io/qifan/infrastructure/generator/processor/processor/DefaultModelElementProcessorContext.java:
--------------------------------------------------------------------------------
1 | package io.qifan.infrastructure.generator.processor.processor;
2 |
3 | public record DefaultModelElementProcessorContext(Class> typeElement, String outputPath)
4 | implements ModelElementProcessor.ProcessorContext {
5 | }
6 |
--------------------------------------------------------------------------------
/uni-ai-backend/generator-processor/src/main/java/io/qifan/infrastructure/generator/processor/processor/ModelElementProcessor.java:
--------------------------------------------------------------------------------
1 | package io.qifan.infrastructure.generator.processor.processor;
2 |
3 |
4 | public interface ModelElementProcessor {
5 |
6 |
7 | R process(ProcessorContext context, P sourceModel);
8 |
9 | int getPriority();
10 |
11 | interface ProcessorContext {
12 |
13 | Class> typeElement();
14 |
15 | String outputPath();
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/uni-ai-backend/generator-processor/src/main/java/io/qifan/infrastructure/generator/processor/processor/RouterCreateProcessor.java:
--------------------------------------------------------------------------------
1 | package io.qifan.infrastructure.generator.processor.processor;
2 |
3 | import io.qifan.infrastructure.generator.processor.model.front.Router;
4 | import io.qifan.infrastructure.generator.processor.utils.TypeUtils;
5 | import io.qifan.infrastructure.generator.processor.writer.ModelWriter;
6 |
7 | import java.util.List;
8 | import java.util.Set;
9 |
10 | public class RouterCreateProcessor {
11 | public void porocess(Set> entities, String outputPath) {
12 | ModelWriter modelWriter = new ModelWriter(outputPath);
13 | Router router = Router.builder()
14 | .entityList(entities.stream().map(TypeUtils::getType)
15 | .toList())
16 | .build();
17 | modelWriter.writeModel(router, false);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/uni-ai-backend/generator-processor/src/main/java/io/qifan/infrastructure/generator/processor/writer/FreeMarkerWritable.java:
--------------------------------------------------------------------------------
1 | package io.qifan.infrastructure.generator.processor.writer;
2 |
3 | import freemarker.template.TemplateException;
4 |
5 | import java.io.IOException;
6 | import java.io.Writer;
7 |
8 | public abstract class FreeMarkerWritable implements Writable {
9 |
10 | @Override
11 | public void write(Context context, Writer writer) {
12 | try {
13 | new FreeMarkerModelElementWriter().write(this, context, writer);
14 | } catch (IOException | TemplateException e) {
15 | throw new RuntimeException(e);
16 | }
17 | }
18 |
19 | protected String getTemplateName() {
20 | return getTemplateNameForClass(getClass());
21 | }
22 |
23 | protected String getTemplateNameForClass(Class> clazz) {
24 | return clazz.getName().replace('.', '/') + ".ftl";
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/uni-ai-backend/generator-processor/src/main/java/io/qifan/infrastructure/generator/processor/writer/Writable.java:
--------------------------------------------------------------------------------
1 | package io.qifan.infrastructure.generator.processor.writer;
2 |
3 | import java.io.Writer;
4 |
5 | public interface Writable {
6 | void write(Context context, Writer writer);
7 |
8 | interface Context {
9 | T get(Class type);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/uni-ai-backend/generator-processor/src/main/resources/io/qifan/infrastructure/generator/processor/model/dto/Dto.ftl:
--------------------------------------------------------------------------------
1 | <#-- @ftlvariable name="" type="io.qifan.infrastructure.generator.processor.model.dto.Dto" -->
2 | export ${entityType.typePath}
3 |
4 | input ${type.typeName}Input {
5 | #allScalars(${type.typeName})
6 | id
7 | <#list getFields() as field>
8 | <#switch field.itemType.code>
9 | <#case 6>
10 | id(${field.fieldName})
11 | #switch>
12 | #list>
13 | }
14 |
15 | specification ${type.typeName}Spec {
16 | #allScalars
17 | <#list getFields() as field>
18 | <#switch field.itemType.code>
19 | <#case 1>
20 | like/i(${field.fieldName})
21 | <#break>
22 | <#case 2>
23 | like/i(${field.fieldName})
24 | <#break>
25 | <#case 5>
26 | ge(${field.fieldName})
27 | le(${field.fieldName})
28 | <#break>
29 | <#case 6>
30 | associatedIdEq(${field.fieldName})
31 | <#break>
32 | #switch>
33 | #list>
34 | associatedIdEq(creator)
35 | }
--------------------------------------------------------------------------------
/uni-ai-backend/generator-processor/src/main/resources/io/qifan/infrastructure/generator/processor/model/front/Store.ftl:
--------------------------------------------------------------------------------
1 | <#-- @ftlvariable name="" type="io.qifan.infrastructure.generator.processor.model.front.Store" -->
2 | <#assign uncapitalizeTypeName = entityType.getUncapitalizeTypeName()>
3 |
4 | import { api } from '@/utils/api-instance'
5 | export const ${uncapitalizeTypeName}QueryOptions = async (keyword: string, id: string) => {
6 | return (
7 | await api.${uncapitalizeTypeName}ForAdminController.query({ body: { query: { name: keyword, id } } })
8 | ).content
9 | }
--------------------------------------------------------------------------------
/uni-ai-backend/generator-processor/src/main/resources/io/qifan/infrastructure/generator/processor/model/front/TableItem.ftl:
--------------------------------------------------------------------------------
1 | <#-- @ftlvariable name="" type="io.qifan.infrastructure.generator.processor.model.front.TableItem" -->
2 | <#if getItemType().code!=-1>
3 |
4 |
5 | <#switch getItemType().code>
6 | <#case 0>
7 |
8 | <#break>
9 | <#case 4>
10 |
11 | <#break>
12 | <#case 6>
13 | {{row.${getProp().replaceAll("Id","")}.name}}
14 | <#break>
15 | <#case 9>
16 |
17 | <#break>
18 | <#default>
19 | {{row.${getProp()}}}
20 | #switch>
21 |
22 |
23 | #if>
24 |
--------------------------------------------------------------------------------
/uni-ai-backend/generator-processor/src/main/resources/io/qifan/infrastructure/generator/processor/model/service/Service.ftl:
--------------------------------------------------------------------------------
1 | <#-- @ftlvariable name="" type="io.qifan.infrastructure.generator.processor.model.service.Service" -->
2 | package ${type.packagePath};
3 |
4 | <#list importTypes as importType>
5 | import ${importType.getTypePath()};
6 | #list>
7 | import org.springframework.data.domain.Page;
8 | import org.springframework.stereotype.Service;
9 | import org.springframework.transaction.annotation.Transactional;
10 |
11 | <#assign uncapitalizeTypeName = entityType.getUncapitalizeTypeName()>
12 | @Service
13 | @Slf4j
14 | @AllArgsConstructor
15 | @Transactional
16 | public class ${type.typeName} {
17 | private final ${entityType.typeName}Repository ${uncapitalizeTypeName}Repository;
18 |
19 | }
--------------------------------------------------------------------------------
/uni-ai-backend/scripts/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM openjdk:17
2 | # 作者的信息,可以不填
3 | MAINTAINER http://www.jarcheng.top/
4 | # 注意这里,这个地方访问的是build时指定的资源路径。而不是当前文件夹下的文件。
5 | # 将资源路径内的的jar包夹复制到镜像内并且重命名为app.jar。
6 | COPY ./target/server-0.1.12.jar app.jar
7 | # 镜像实例化,即启动容器后的运行命令,我们这边就是启动服务
8 | ENTRYPOINT ["java","-jar", "/app.jar"]
--------------------------------------------------------------------------------
/uni-ai-backend/scripts/build.sh:
--------------------------------------------------------------------------------
1 | cd ../../uni-ai-admin
2 | npm run build-only
3 | cp -r ./dist ../uni-ai-backend/server/src/main/resources
4 | cd ../uni-ai-backend
5 | mvn -DskipTests=true package
6 | cd scripts
7 | docker build -t qifan7/uni-ai:0.1.12 -f Dockerfile ../server
8 | docker push qifan7/uni-ai:0.1.12
--------------------------------------------------------------------------------
/uni-ai-backend/scripts/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: "3.9"
2 | name: uni-ai-compose
3 | services:
4 | mysql:
5 | # 镜像名称
6 | image: mysql:8.0.26
7 | # 相当于 --name
8 | container_name: mysql
9 | # 相当于多个 -e
10 | environment:
11 | MYSQL_ROOT_PASSWORD: 123456
12 | TZ: Asia/Shanghai
13 | MYSQL_DATABASE: uni_ai
14 | # 相当于 -p
15 | ports:
16 | - "3308:3306"
17 | # 相当于 -v
18 | volumes:
19 | - mysql-data:/var/lib/mysql
20 | # 容器启动后执行下面这个命令
21 | command: [ 'mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci' ]
22 | redis:
23 | image: redis/redis-stack:latest
24 | container_name: redis-stack
25 | restart: always
26 | ports:
27 | - "6381:6379"
28 | - "8001:8001"
29 | environment:
30 | REDIS_ARGS: --requirepass 123456
31 | volumes:
32 | - redis-data:/data
33 | uni-ai:
34 | image: qifan7/uni-ai:0.1.12
35 | container_name: uni-ai
36 | environment:
37 | spring.profiles.active: prod
38 | ports:
39 | - "8877:8877"
40 | depends_on:
41 | - mysql
42 | - redis
43 | volumes:
44 | mysql-data: { }
45 | redis-data: { }
46 |
--------------------------------------------------------------------------------
/uni-ai-backend/server/src/main/dto/ai/AiCollection.dto:
--------------------------------------------------------------------------------
1 | export io.qifan.server.ai.collection.entity.AiCollection
2 |
3 | input AiCollectionCreateInput {
4 | #allScalars(AiCollection)
5 | id(embeddingModel)
6 | }
7 | input AiCollectionUpdateInput {
8 | #allScalars(AiCollection)
9 | id!
10 | id(embeddingModel)
11 | }
12 |
13 | specification AiCollectionSpec {
14 | #allScalars
15 | like/i(name)
16 | like/i(collectionName)
17 | like/i(id)
18 | ge(createdTime)
19 | le(createdTime)
20 | ge(editedTime)
21 | le(editedTime)
22 | id(creator)
23 | id(embeddingModel)
24 | }
--------------------------------------------------------------------------------
/uni-ai-backend/server/src/main/dto/ai/AiDocument.dto:
--------------------------------------------------------------------------------
1 | export io.qifan.server.ai.document.entity.AiDocument
2 |
3 | input AiDocumentCreateInput {
4 | #allScalars(AiDocument)
5 | id(aiCollection)
6 | -docIds
7 | }
8 | input AiDocumentUpdateInput {
9 | #allScalars(AiDocument)
10 | id!
11 | id(aiCollection)
12 | -docIds
13 | }
14 |
15 | specification AiDocumentSpec {
16 | #allScalars
17 | like/i(name)
18 | like/i(id)
19 | like/i(content)
20 | ge(editedTime)
21 | le(editedTime)
22 | ge(createdTime)
23 | le(createdTime)
24 | id(creator)
25 | id(aiCollection)
26 | }
--------------------------------------------------------------------------------
/uni-ai-backend/server/src/main/dto/ai/AiFactory.dto:
--------------------------------------------------------------------------------
1 | export io.qifan.server.ai.factory.entity.AiFactory
2 |
3 | input AiFactoryCreateInput {
4 | #allScalars(AiFactory)
5 | }
6 | input AiFactoryUpdateInput {
7 | #allScalars(AiFactory)
8 | id!
9 | }
10 |
11 | specification AiFactorySpec {
12 | #allScalars
13 | like/i(description)
14 | like/i(id)
15 | ge(createdTime)
16 | le(createdTime)
17 | ge(editedTime)
18 | le(editedTime)
19 | id(creator)
20 | }
--------------------------------------------------------------------------------
/uni-ai-backend/server/src/main/dto/ai/AiMessage.dto:
--------------------------------------------------------------------------------
1 | export io.qifan.server.ai.message.entity.AiMessage
2 |
3 | input AiMessageCreateInput {
4 | #allScalars(AiMessage)
5 | id(aiSession)
6 | }
7 | input AiMessageUpdateInput {
8 | #allScalars(AiMessage)
9 | id!
10 | id(aiSession)
11 | }
12 | //AiMessageView {
13 | // content
14 | // type
15 | //}
16 |
17 | specification AiMessageSpec {
18 | #allScalars
19 | like/i(id)
20 | ge(createdTime)
21 | le(createdTime)
22 | ge(editedTime)
23 | le(editedTime)
24 | id(creator)
25 | id(aiSession)
26 | }
--------------------------------------------------------------------------------
/uni-ai-backend/server/src/main/dto/ai/AiModel.dto:
--------------------------------------------------------------------------------
1 | export io.qifan.server.ai.model.entity.AiModel
2 |
3 | input AiModelCreateInput {
4 | #allScalars(AiModel)
5 | tagIds:Array
6 | }
7 | input AiModelUpdateInput {
8 | #allScalars(AiModel)
9 | id!
10 | tagIds:Array
11 | }
12 |
13 | specification AiModelSpec {
14 | #allScalars
15 | like/i(name)
16 | like/i(id)
17 | ge(createdTime)
18 | le(createdTime)
19 | ge(editedTime)
20 | le(editedTime)
21 | id(creator)
22 | flat(tags) {
23 | flat(aiTag) {
24 | valueIn(name) as tagNames
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/uni-ai-backend/server/src/main/dto/ai/AiPlugin.dto:
--------------------------------------------------------------------------------
1 | export io.qifan.server.ai.plugin.entity.AiPlugin
2 |
3 | input AiPluginCreateInput {
4 | #allScalars(AiPlugin)
5 | }
6 | input AiPluginUpdateInput {
7 | #allScalars(AiPlugin)
8 | id!
9 | }
10 |
11 | specification AiPluginSpec {
12 | #allScalars
13 | like/i(name)
14 | like/i(description)
15 | like/i(id)
16 | ge(createdTime)
17 | le(createdTime)
18 | ge(editedTime)
19 | le(editedTime)
20 | id(creator)
21 | valueIn(name) as Names
22 | }
--------------------------------------------------------------------------------
/uni-ai-backend/server/src/main/dto/ai/AiRole.dto:
--------------------------------------------------------------------------------
1 | export io.qifan.server.ai.role.entity.AiRole
2 |
3 | input AiRoleCreateInput {
4 | #allScalars(AiRole)
5 | }
6 | input AiRoleUpdateInput {
7 | #allScalars(AiRole)
8 | id!
9 | }
10 |
11 | specification AiRoleSpec {
12 | #allScalars
13 | like/i(name)
14 | like/i(id)
15 | ge(createdTime)
16 | le(createdTime)
17 | ge(editedTime)
18 | le(editedTime)
19 | id(creator)
20 | }
--------------------------------------------------------------------------------
/uni-ai-backend/server/src/main/dto/ai/AiSession.dto:
--------------------------------------------------------------------------------
1 | export io.qifan.server.ai.session.entity.AiSession
2 |
3 | input AiSessionCreateInput {
4 | #allScalars(AiSession)
5 | }
6 | input AiSessionUpdateInput {
7 | #allScalars(AiSession)
8 | id!
9 | }
10 |
11 | specification AiSessionSpec {
12 | #allScalars
13 | like/i(name)
14 | like/i(id)
15 | ge(createdTime)
16 | le(createdTime)
17 | ge(editedTime)
18 | le(editedTime)
19 | id(creator)
20 | }
--------------------------------------------------------------------------------
/uni-ai-backend/server/src/main/dto/ai/AiTag.dto:
--------------------------------------------------------------------------------
1 | export io.qifan.server.ai.tag.root.entity.AiTag
2 |
3 | input AiTagCreateInput {
4 | #allScalars(AiTag)
5 | }
6 | input AiTagUpdateInput {
7 | #allScalars(AiTag)
8 | id!
9 | }
10 |
11 | specification AiTagSpec {
12 | #allScalars
13 | like/i(service)
14 | like/i(id)
15 | ge(editedTime)
16 | le(editedTime)
17 | ge(createdTime)
18 | le(createdTime)
19 | id(creator)
20 | valueIn(id) as ids
21 | }
--------------------------------------------------------------------------------
/uni-ai-backend/server/src/main/dto/dict/Dict.dto:
--------------------------------------------------------------------------------
1 | export io.qifan.server.dict.entity.Dict
2 | input DictInput {
3 | #allScalars(Dict)
4 | id?
5 | }
6 |
7 | specification DictSpec {
8 | #allScalars
9 | like/i(dictEnName)
10 | like/i(keyEnName)
11 | like/i(keyName)
12 | like/i(dictName)
13 | like/i(id)
14 | ge(editedTime)
15 | le(editedTime)
16 | ge(createdTime)
17 | le(createdTime)
18 | }
--------------------------------------------------------------------------------
/uni-ai-backend/server/src/main/dto/menu/Menu.dto:
--------------------------------------------------------------------------------
1 | export io.qifan.server.menu.entity.Menu
2 | input MenuInput {
3 | #allScalars(Menu)
4 | id?
5 | }
6 |
7 | specification MenuSpec {
8 | #allScalars
9 | like/i(name)
10 | like/i(path)
11 | like/i(id)
12 | ge(createdTime)
13 | le(createdTime)
14 | ge(editedTime)
15 | le(editedTime)
16 | }
--------------------------------------------------------------------------------
/uni-ai-backend/server/src/main/dto/role/Role.dto:
--------------------------------------------------------------------------------
1 | export io.qifan.server.role.entity.Role
2 | input RoleInput {
3 | #allScalars(Role)
4 | id?
5 | menuIds: Array
6 | }
7 |
8 | specification RoleSpec {
9 | #allScalars
10 | like/i(name)
11 | like/i(id)
12 | valueIn(id) as ids
13 | ge(editedTime)
14 | le(editedTime)
15 | ge(createdTime)
16 | le(createdTime)
17 | }
--------------------------------------------------------------------------------
/uni-ai-backend/server/src/main/dto/user/User.dto:
--------------------------------------------------------------------------------
1 | export io.qifan.server.user.root.entity.User
2 |
3 | input UserCreateInput {
4 | #allScalars(User)
5 | roleIds: Array
6 | }
7 | input UserUpdateInput {
8 | #allScalars(User)
9 | id!
10 | roleIds: Array
11 | }
12 | input UserInfoInput{
13 | nickname
14 | gender
15 | avatar
16 | }
17 | input UserRegisterInput {
18 | phone
19 | password
20 | code: String
21 | }
22 | input UserLoginInput {
23 | password
24 | phone
25 | }
26 | input UserResetPasswordInput {
27 | password
28 | phone
29 | code: String
30 | }
31 | specification UserSpec {
32 | #allScalars
33 | like/i(id)
34 | like/i(phone)
35 | like/i(nickname)
36 | like/i(password)
37 | ge(createdTime)
38 | le(createdTime)
39 | ge(editedTime)
40 | le(editedTime)
41 | }
--------------------------------------------------------------------------------
/uni-ai-backend/server/src/main/dto/user/UserWeChat.dto:
--------------------------------------------------------------------------------
1 | export io.qifan.server.user.wechat.entity.UserWeChat
2 | input UserWeChatCreateInput {
3 | #allScalars(UserWeChat)
4 | }
5 | input UserWeChatUpdateInput {
6 | #allScalars(UserWeChat)
7 | id!
8 | }
9 | specification UserWeChatSpec {
10 | #allScalars
11 | like/i(id)
12 | like/i(openId)
13 | ge(editedTime)
14 | le(editedTime)
15 | ge(createdTime)
16 | le(createdTime)
17 | }
--------------------------------------------------------------------------------
/uni-ai-backend/server/src/main/dto/wallet/Wallet.dto:
--------------------------------------------------------------------------------
1 | export io.qifan.server.wallet.root.entity.Wallet
2 |
3 | input WalletCreateInput {
4 | #allScalars(Wallet)
5 | id?
6 | id(user)
7 | }
8 | input WalletUpdateInput {
9 | #allScalars(Wallet)
10 | id!
11 | id(user)
12 | }
13 |
14 | specification WalletSpec {
15 | #allScalars
16 | like/i(password)
17 | like/i(id)
18 | ge(createdTime)
19 | le(createdTime)
20 | ge(editedTime)
21 | le(editedTime)
22 | id(creator)
23 | flat(user) {
24 | id as userId
25 | like/i(phone)
26 | }
27 | }
--------------------------------------------------------------------------------
/uni-ai-backend/server/src/main/dto/wallet/WalletItem.dto:
--------------------------------------------------------------------------------
1 | export io.qifan.server.wallet.item.entity.WalletItem
2 |
3 | input WalletItemCreateInput {
4 | #allScalars(WalletItem)
5 | }
6 | input WalletItemUpdateInput {
7 | #allScalars(WalletItem)
8 | id!
9 | }
10 |
11 | specification WalletItemSpec {
12 | #allScalars
13 | like/i(name)
14 | like/i(id)
15 | ge(createdTime)
16 | le(createdTime)
17 | ge(editedTime)
18 | le(editedTime)
19 | id(creator)
20 | }
--------------------------------------------------------------------------------
/uni-ai-backend/server/src/main/dto/wallet/WalletOrder.dto:
--------------------------------------------------------------------------------
1 | export io.qifan.server.wallet.order.entity.WalletOrder
2 |
3 | input WalletOrderCreateInput {
4 | #allScalars(WalletOrder)
5 | id?
6 | id(user)
7 | }
8 | input WalletOrderUpdateInput {
9 | #allScalars(WalletOrder)
10 | id!
11 | id(user)
12 | }
13 |
14 | specification WalletOrderSpec {
15 | #allScalars
16 | ge(payTime)
17 | le(payTime)
18 | like/i(id)
19 | ge(createdTime)
20 | le(createdTime)
21 | ge(editedTime)
22 | le(editedTime)
23 | id(creator)
24 | id(user)
25 | }
--------------------------------------------------------------------------------
/uni-ai-backend/server/src/main/dto/wallet/WalletRecord.dto:
--------------------------------------------------------------------------------
1 | export io.qifan.server.wallet.record.entity.WalletRecord
2 |
3 | input WalletRecordCreateInput {
4 | #allScalars(WalletRecord)
5 | id(wallet)
6 | -balance
7 | }
8 | input WalletRecordUpdateInput {
9 | #allScalars(WalletRecord)
10 | id!
11 | id(wallet)
12 | -balance
13 | }
14 |
15 | specification WalletRecordSpec {
16 | #allScalars
17 | like/i(description)
18 | like/i(id)
19 | ge(createdTime)
20 | le(createdTime)
21 | ge(editedTime)
22 | le(editedTime)
23 | id(creator)
24 | id(wallet)
25 | }
--------------------------------------------------------------------------------
/uni-ai-backend/server/src/main/java/io/qifan/server/ServerApplication.java:
--------------------------------------------------------------------------------
1 | package io.qifan.server;
2 |
3 | import io.qifan.server.infrastructure.model.WxPayPropertiesExtension;
4 | import org.babyfish.jimmer.client.EnableImplicitApi;
5 | import org.springframework.ai.autoconfigure.vectorstore.redis.RedisVectorStoreAutoConfiguration;
6 | import org.springframework.boot.SpringApplication;
7 | import org.springframework.boot.autoconfigure.SpringBootApplication;
8 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
9 | import org.springframework.scheduling.annotation.EnableAsync;
10 |
11 | @SpringBootApplication(exclude = {RedisVectorStoreAutoConfiguration.class})
12 | @EnableImplicitApi
13 | @EnableConfigurationProperties(value = {WxPayPropertiesExtension.class})
14 | @EnableAsync
15 | public class ServerApplication {
16 |
17 | public static void main(String[] args) {
18 | SpringApplication.run(ServerApplication.class, args);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/uni-ai-backend/server/src/main/java/io/qifan/server/ai/collection/entity/AiCollection.java:
--------------------------------------------------------------------------------
1 | package io.qifan.server.ai.collection.entity;
2 |
3 | import io.qifan.infrastructure.generator.core.GenEntity;
4 | import io.qifan.infrastructure.generator.core.GenField;
5 | import io.qifan.infrastructure.generator.core.ItemType;
6 | import io.qifan.server.ai.model.entity.AiModel;
7 | import io.qifan.server.infrastructure.jimmer.BaseEntity;
8 | import org.babyfish.jimmer.sql.Entity;
9 | import org.babyfish.jimmer.sql.IdView;
10 | import org.babyfish.jimmer.sql.ManyToOne;
11 |
12 |
13 | /**
14 | *
15 | * 知识库
16 | *
17 | *
18 | *
19 | * @author a1507
20 | * @date 2024-05-30
21 | */
22 | @Entity
23 | @GenEntity
24 | public interface AiCollection extends BaseEntity {
25 |
26 | /**
27 | * 知识库名称
28 | */
29 | @GenField(value = "中文名称", order = 0)
30 | String name();
31 |
32 | @GenField(value = "英文名称", order = 1)
33 | String collectionName();
34 |
35 | /**
36 | * 嵌入模型
37 | */
38 | @GenField(value = "嵌入模型", order = 1, type = ItemType.ASSOCIATION_SELECT)
39 | @IdView
40 | String embeddingModelId();
41 |
42 | @ManyToOne
43 | AiModel embeddingModel();
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/uni-ai-backend/server/src/main/java/io/qifan/server/ai/collection/service/AiCollectionService.java:
--------------------------------------------------------------------------------
1 | package io.qifan.server.ai.collection.service;
2 |
3 | import io.qifan.server.ai.collection.repository.AiCollectionRepository;
4 | import lombok.AllArgsConstructor;
5 | import lombok.extern.slf4j.Slf4j;
6 | import org.springframework.stereotype.Service;
7 | import org.springframework.transaction.annotation.Transactional;
8 |
9 | @Service
10 | @Slf4j
11 | @AllArgsConstructor
12 | @Transactional
13 | public class AiCollectionService {
14 | private final AiCollectionRepository aiCollectionRepository;
15 |
16 | }
--------------------------------------------------------------------------------
/uni-ai-backend/server/src/main/java/io/qifan/server/ai/document/entity/AiDocument.java:
--------------------------------------------------------------------------------
1 | package io.qifan.server.ai.document.entity;
2 |
3 | import io.qifan.infrastructure.generator.core.GenEntity;
4 | import io.qifan.infrastructure.generator.core.GenField;
5 | import io.qifan.infrastructure.generator.core.ItemType;
6 | import io.qifan.server.ai.collection.entity.AiCollection;
7 | import io.qifan.server.infrastructure.jimmer.BaseEntity;
8 | import org.babyfish.jimmer.sql.*;
9 |
10 | import java.util.List;
11 |
12 |
13 | /**
14 | *
15 | * 知识库文档
16 | *
17 | */
18 | @GenEntity
19 | @Entity
20 | public interface AiDocument extends BaseEntity {
21 | @GenField(value = "名称")
22 | String name();
23 |
24 | @GenField(value = "内容")
25 | String content();
26 |
27 | @GenField(value = "知识库", order = 1, type = ItemType.ASSOCIATION_SELECT)
28 | @IdView
29 | String aiCollectionId();
30 |
31 | @ManyToOne
32 | @OnDissociate(DissociateAction.DELETE)
33 | AiCollection aiCollection();
34 |
35 | @Serialized
36 | List docIds();
37 | }
38 |
--------------------------------------------------------------------------------
/uni-ai-backend/server/src/main/java/io/qifan/server/ai/document/service/AiDocumentService.java:
--------------------------------------------------------------------------------
1 | package io.qifan.server.ai.document.service;
2 |
3 | import io.qifan.server.ai.document.repository.AiDocumentRepository;
4 | import lombok.AllArgsConstructor;
5 | import lombok.extern.slf4j.Slf4j;
6 | import org.springframework.stereotype.Service;
7 | import org.springframework.transaction.annotation.Transactional;
8 |
9 | @Service
10 | @Slf4j
11 | @AllArgsConstructor
12 | @Transactional
13 | public class AiDocumentService {
14 | private final AiDocumentRepository aiDocumentRepository;
15 |
16 | }
--------------------------------------------------------------------------------
/uni-ai-backend/server/src/main/java/io/qifan/server/ai/factory/entity/AiFactory.java:
--------------------------------------------------------------------------------
1 | package io.qifan.server.ai.factory.entity;
2 |
3 | import io.qifan.infrastructure.generator.core.GenEntity;
4 | import io.qifan.infrastructure.generator.core.GenField;
5 | import io.qifan.infrastructure.generator.core.ItemType;
6 | import io.qifan.server.dict.model.DictConstants;
7 | import io.qifan.server.infrastructure.jimmer.BaseEntity;
8 | import jakarta.validation.constraints.Null;
9 | import org.babyfish.jimmer.sql.Entity;
10 | import org.babyfish.jimmer.sql.Serialized;
11 |
12 | import java.util.Map;
13 |
14 |
15 | /**
16 | *
17 | * AI厂家
18 | *
19 | */
20 | @GenEntity
21 | @Entity
22 | public interface AiFactory extends BaseEntity {
23 |
24 | /**
25 | * 厂家名称
26 | */
27 | @GenField(value = "厂家名称", type = ItemType.SELECTABLE, dictEnName = DictConstants.AI_FACTORY_TYPE, order = 0)
28 | DictConstants.AiFactoryType name();
29 |
30 | /**
31 | * 厂家描述
32 | */
33 | @Null
34 | @GenField(value = "厂家描述", order = 1)
35 | String description();
36 |
37 | /**
38 | * options
39 | */
40 | @Null
41 | @Serialized
42 | Map options();
43 | }
44 |
--------------------------------------------------------------------------------
/uni-ai-backend/server/src/main/java/io/qifan/server/ai/factory/service/AiFactoryService.java:
--------------------------------------------------------------------------------
1 | package io.qifan.server.ai.factory.service;
2 |
3 | import io.qifan.server.ai.factory.repository.AiFactoryRepository;
4 | import lombok.AllArgsConstructor;
5 | import lombok.extern.slf4j.Slf4j;
6 | import org.springframework.stereotype.Service;
7 | import org.springframework.transaction.annotation.Transactional;
8 |
9 | @Service
10 | @Slf4j
11 | @AllArgsConstructor
12 | @Transactional
13 | public class AiFactoryService {
14 | private final AiFactoryRepository aiFactoryRepository;
15 |
16 | }
--------------------------------------------------------------------------------
/uni-ai-backend/server/src/main/java/io/qifan/server/ai/message/entity/AiMessage.java:
--------------------------------------------------------------------------------
1 | package io.qifan.server.ai.message.entity;
2 |
3 | import io.qifan.infrastructure.generator.core.GenEntity;
4 | import io.qifan.infrastructure.generator.core.GenField;
5 | import io.qifan.infrastructure.generator.core.ItemType;
6 | import io.qifan.server.ai.session.entity.AiSession;
7 | import io.qifan.server.dict.model.DictConstants;
8 | import io.qifan.server.infrastructure.jimmer.BaseEntity;
9 | import org.babyfish.jimmer.sql.*;
10 |
11 | import java.util.List;
12 | import java.util.Map;
13 |
14 |
15 | @Entity
16 | @Table(name = "ai_message")
17 | @GenEntity
18 | public interface AiMessage extends BaseEntity {
19 |
20 | /**
21 | * 消息类型(用户/助手/系统)
22 | */
23 | @GenField(value = "消息类型", type = ItemType.SELECTABLE, dictEnName = DictConstants.AI_MESSAGE_TYPE, order = 0)
24 | DictConstants.AiMessageType type();
25 |
26 | /**
27 | * 消息内容
28 | */
29 | @Serialized
30 | @GenField(value = "消息内容", type = ItemType.INPUT_TEXT_AREA, order = 1)
31 | List