添加获取surl数量接口
This commit is contained in:
parent
87ab3df17c
commit
1aa5f31694
@ -30,4 +30,10 @@ class SurlGetController(
|
||||
|
||||
return Msg(value = urls)
|
||||
}
|
||||
|
||||
@GetMapping(path = ["/api/surl/count/get"])
|
||||
fun getUrlsCountByUser(@RequestHeader headers: HttpHeaders): Msg<Long> {
|
||||
val username = jwtTokenUtil.getUsernameFromHeader(headers)
|
||||
return Msg(value = surlService.getUrlsCountByUser(username))
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import dev.surl.surl.dsl.Users
|
||||
import dev.surl.surl.util.*
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.jetbrains.exposed.sql.batchInsert
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@ -73,4 +74,15 @@ class SurlService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户短链接数量
|
||||
* @param username 用户名
|
||||
* @return 短链接数量
|
||||
*/
|
||||
fun getUrlsCountByUser(username: String) = transaction {
|
||||
Users.innerJoin(Surls).selectAll().where {
|
||||
Users.username eq username
|
||||
}.count()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user