From 9cb228dc5e43d39a8a28fdc479616c390d59efab Mon Sep 17 00:00:00 2001 From: ArgonarioD Date: Thu, 6 Jul 2023 23:22:44 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E4=BA=86=E6=8C=89?= =?UTF-8?q?=E7=B1=BB=E6=9F=A5=E6=89=BE=E7=9F=A5=E8=AF=86=E7=9A=84=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=EF=BC=8C=E4=BF=AE=E5=A4=8D=E4=BA=86=E4=B8=80=E4=BA=9B?= =?UTF-8?q?bug=20fix=20list=EF=BC=9A=20-=20getKnowledgeBrief=E4=B8=8D?= =?UTF-8?q?=E4=BC=9A=E7=AD=9B=E9=80=89null=E7=88=B6=E8=8A=82=E7=82=B9=20-?= =?UTF-8?q?=20createNewKnowledgeFolder=E6=97=A0=E6=B3=95=E5=B7=A5=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildDockerImage.ps1 | 4 ++++ .../controller/KnowledgeController.kt | 5 +++++ .../knowledge/entity/KnowledgeFileAttribute.kt | 7 +++++++ .../repository/KnowledgeRepository.kt | 18 +++++++++++++++++- 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/buildDockerImage.ps1 b/buildDockerImage.ps1 index 1729867..acbeab1 100644 --- a/buildDockerImage.ps1 +++ b/buildDockerImage.ps1 @@ -5,6 +5,10 @@ java -Djarmode=layertools ` extract --destination build/extracted docker build -f .\Dockerfile -t auto/aics_main:latest . + echo 'saving...' docker save -o ..\docker\aics_main.tar auto/aics_main:latest + +echo 'compressing...' +Compress-Archive -Path ..\docker\aics_main.tar -DestinationPath ..\docker\aics_main.zip pause \ No newline at end of file diff --git a/src/main/kotlin/cn/edu/hfut/auto/knowledge/controller/KnowledgeController.kt b/src/main/kotlin/cn/edu/hfut/auto/knowledge/controller/KnowledgeController.kt index ddbac8b..c5cbb2d 100644 --- a/src/main/kotlin/cn/edu/hfut/auto/knowledge/controller/KnowledgeController.kt +++ b/src/main/kotlin/cn/edu/hfut/auto/knowledge/controller/KnowledgeController.kt @@ -110,6 +110,7 @@ class KnowledgeController( id = it } } + createTime = LocalDateTime.now() }) } @@ -150,4 +151,8 @@ class KnowledgeController( } ?: throw BusinessError(ErrorCode.RESOURCE_NOT_FOUND) } + + @GetMapping + suspend fun findKnowledgeByType(type: KnowledgeFileAttribute.FileType): List = + knowledgeRepository.findAllByKnowledgeFileAttributeSuffixIn(type.suffixes, Knowledge.BRIEF_FETCHER) } \ No newline at end of file diff --git a/src/main/kotlin/cn/edu/hfut/auto/knowledge/entity/KnowledgeFileAttribute.kt b/src/main/kotlin/cn/edu/hfut/auto/knowledge/entity/KnowledgeFileAttribute.kt index 4d9073c..41c8c6a 100644 --- a/src/main/kotlin/cn/edu/hfut/auto/knowledge/entity/KnowledgeFileAttribute.kt +++ b/src/main/kotlin/cn/edu/hfut/auto/knowledge/entity/KnowledgeFileAttribute.kt @@ -39,6 +39,13 @@ interface KnowledgeFileAttribute { } } } + + @Suppress("unused") + enum class FileType(val suffixes: List) { + AUDIO(listOf("wav", "mp3")), + VIDEO(listOf("mp4", "avi", "flv", "mkv", "wmv")), + DOCUMENT(listOf("pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "txt", "md")) + } } inline val KnowledgeFileAttribute.externalPreviewable: Boolean diff --git a/src/main/kotlin/cn/edu/hfut/auto/knowledge/repository/KnowledgeRepository.kt b/src/main/kotlin/cn/edu/hfut/auto/knowledge/repository/KnowledgeRepository.kt index 8ffb7ac..6f3e73b 100644 --- a/src/main/kotlin/cn/edu/hfut/auto/knowledge/repository/KnowledgeRepository.kt +++ b/src/main/kotlin/cn/edu/hfut/auto/knowledge/repository/KnowledgeRepository.kt @@ -1,12 +1,28 @@ package cn.edu.hfut.auto.knowledge.repository import cn.edu.hfut.auto.knowledge.entity.Knowledge +import cn.edu.hfut.auto.knowledge.entity.id +import cn.edu.hfut.auto.knowledge.entity.parent +import cn.edu.hfut.auto.knowledge.entity.`parent?` import org.babyfish.jimmer.spring.repository.KRepository import org.babyfish.jimmer.sql.fetcher.Fetcher +import org.babyfish.jimmer.sql.kt.ast.expression.eq +import org.babyfish.jimmer.sql.kt.ast.table.isNull import java.util.* interface KnowledgeRepository : KRepository { fun findByNameAndParentId(name: String, parentId: UUID?, fetcher: Fetcher? = null): Knowledge? - fun findAllByParentId(parentId: UUID?, fetcher: Fetcher? = null): List + fun findAllByParentId(parentId: UUID?, fetcher: Fetcher? = null): List { + return sql.createQuery(Knowledge::class) { + if (parentId == null) { + where(table.`parent?`.isNull()) + } else { + where(table.parent.id eq parentId) + } + select(table.fetch(fetcher)) + }.execute() + } + + fun findAllByKnowledgeFileAttributeSuffixIn(knowledgeFileAttributeSuffix: List, fetcher: Fetcher? = null): List } \ No newline at end of file