feat: 新增了按类查找知识的接口,修复了一些bug

fix list:
- getKnowledgeBrief不会筛选null父节点
- createNewKnowledgeFolder无法工作
master
ArgonarioD 2023-07-06 23:22:44 +08:00
parent 4b9264b6b9
commit 9cb228dc5e
4 changed files with 33 additions and 1 deletions

View File

@ -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

View File

@ -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<Knowledge> =
knowledgeRepository.findAllByKnowledgeFileAttributeSuffixIn(type.suffixes, Knowledge.BRIEF_FETCHER)
}

View File

@ -39,6 +39,13 @@ interface KnowledgeFileAttribute {
}
}
}
@Suppress("unused")
enum class FileType(val suffixes: List<String>) {
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

View File

@ -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<Knowledge, UUID> {
fun findByNameAndParentId(name: String, parentId: UUID?, fetcher: Fetcher<Knowledge>? = null): Knowledge?
fun findAllByParentId(parentId: UUID?, fetcher: Fetcher<Knowledge>? = null): List<Knowledge>
fun findAllByParentId(parentId: UUID?, fetcher: Fetcher<Knowledge>? = null): List<Knowledge> {
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<String>, fetcher: Fetcher<Knowledge>? = null): List<Knowledge>
}