refactor: rename repo fun-s as they always take id

This commit is contained in:
DarkCat09 2024-06-21 16:56:14 +04:00
parent 440008ec64
commit ae2d98fa1f
Signed by: DarkCat09
GPG key ID: 0A26CD5B3345D6E3
2 changed files with 4 additions and 4 deletions

View file

@ -12,11 +12,11 @@ object ProfileRepository {
), ),
) )
fun getById(id: UInt): Profile? { fun get(id: UInt): Profile? {
return profiles.get(id) return profiles.get(id)
} }
fun deleteById(id: UInt): Boolean { fun delete(id: UInt): Boolean {
return profiles.remove(id) != null return profiles.remove(id) != null
} }
} }

View file

@ -22,7 +22,7 @@ fun Application.configureRouting() {
return@get return@get
} }
val profile = ProfileRepository.getById(id) val profile = ProfileRepository.get(id)
if (profile == null) { if (profile == null) {
call.respond(HttpStatusCode.NotFound) call.respond(HttpStatusCode.NotFound)
return@get return@get
@ -39,7 +39,7 @@ fun Application.configureRouting() {
return@delete return@delete
} }
if (!ProfileRepository.deleteById(id)) { if (!ProfileRepository.delete(id)) {
call.respond(HttpStatusCode.NotFound) call.respond(HttpStatusCode.NotFound)
} else { } else {
call.respond(HttpStatusCode.OK) call.respond(HttpStatusCode.OK)