feat: 新增了按类查找知识的接口,修复了一些bug
fix list: - getKnowledgeBrief不会筛选null父节点 - createNewKnowledgeFolder无法工作master
parent
4b9264b6b9
commit
9cb228dc5e
|
@ -5,6 +5,10 @@ java -Djarmode=layertools `
|
||||||
extract --destination build/extracted
|
extract --destination build/extracted
|
||||||
|
|
||||||
docker build -f .\Dockerfile -t auto/aics_main:latest .
|
docker build -f .\Dockerfile -t auto/aics_main:latest .
|
||||||
|
|
||||||
echo 'saving...'
|
echo 'saving...'
|
||||||
docker save -o ..\docker\aics_main.tar auto/aics_main:latest
|
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
|
pause
|
|
@ -110,6 +110,7 @@ class KnowledgeController(
|
||||||
id = it
|
id = it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
createTime = LocalDateTime.now()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,4 +151,8 @@ class KnowledgeController(
|
||||||
}
|
}
|
||||||
?: throw BusinessError(ErrorCode.RESOURCE_NOT_FOUND)
|
?: throw BusinessError(ErrorCode.RESOURCE_NOT_FOUND)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
suspend fun findKnowledgeByType(type: KnowledgeFileAttribute.FileType): List<Knowledge> =
|
||||||
|
knowledgeRepository.findAllByKnowledgeFileAttributeSuffixIn(type.suffixes, Knowledge.BRIEF_FETCHER)
|
||||||
}
|
}
|
|
@ -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
|
inline val KnowledgeFileAttribute.externalPreviewable: Boolean
|
||||||
|
|
|
@ -1,12 +1,28 @@
|
||||||
package cn.edu.hfut.auto.knowledge.repository
|
package cn.edu.hfut.auto.knowledge.repository
|
||||||
|
|
||||||
import cn.edu.hfut.auto.knowledge.entity.Knowledge
|
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.spring.repository.KRepository
|
||||||
import org.babyfish.jimmer.sql.fetcher.Fetcher
|
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.*
|
import java.util.*
|
||||||
|
|
||||||
interface KnowledgeRepository : KRepository<Knowledge, UUID> {
|
interface KnowledgeRepository : KRepository<Knowledge, UUID> {
|
||||||
fun findByNameAndParentId(name: String, parentId: UUID?, fetcher: Fetcher<Knowledge>? = null): Knowledge?
|
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>
|
||||||
}
|
}
|
Loading…
Reference in New Issue