优化查询逻辑
This commit is contained in:
parent
bb6d583ef6
commit
c028147459
@ -39,6 +39,7 @@ class SurlService {
|
||||
* 批量添加短链接
|
||||
* @param baseurls 原始链接列表
|
||||
*/
|
||||
@Suppress("UNUSED")
|
||||
fun batchAddSurl(baseurls: List<String>) = transaction {
|
||||
Surls.batchInsert(baseurls, shouldReturnGeneratedValues = false) {
|
||||
this[Surls.url] = it
|
||||
@ -61,10 +62,11 @@ class SurlService {
|
||||
/**
|
||||
* 根据用户名获取短链接列表
|
||||
* @param username 用户名
|
||||
* @return 短链接列表
|
||||
*/
|
||||
fun getUrlsByUser(username: String): List<KeyValuePair<String, String>> {
|
||||
return transaction {
|
||||
Users.leftJoin(Surls).select(Surls.id, Surls.url).where {
|
||||
Users.innerJoin(Surls).select(Surls.id, Surls.url).where {
|
||||
Users.username eq username
|
||||
}.map {
|
||||
KeyValuePair(numberToKey(it[Surls.id].value), it[Surls.url])
|
||||
|
Loading…
Reference in New Issue
Block a user