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