Skip to content

Commit

Permalink
feat: fs-server支持客户端会话管理 #1275
Browse files Browse the repository at this point in the history
  • Loading branch information
yaoxuwan committed Oct 18, 2023
1 parent 16b19e4 commit f3a1742
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import com.tencent.bkrepo.fs.server.request.ClientCreateRequest
import com.tencent.bkrepo.fs.server.utils.ReactiveSecurityUtils
import org.springframework.data.mongodb.core.query.Criteria
import org.springframework.data.mongodb.core.query.Query
import org.springframework.data.mongodb.core.query.Update
import org.springframework.data.mongodb.core.query.isEqualTo
import java.time.LocalDateTime

Expand Down Expand Up @@ -85,12 +84,11 @@ class ClientService(
.and(TClient::repoName.name).isEqualTo(repoName)
.and(TClient::id.name).isEqualTo(clientId)
)
val update = Update().set(TClient::heartbeatTime.name, LocalDateTime.now())
.set(TClient::online.name, true)
val result = clientRepository.upsert(query, update)
if (result.matchedCount == 0L) {
throw ErrorCodeException(CommonMessageCode.RESOURCE_NOT_FOUND, clientId)
}
val client = clientRepository.findOne(query)
?: throw ErrorCodeException(CommonMessageCode.RESOURCE_NOT_FOUND, clientId)
client.heartbeatTime = LocalDateTime.now()
client.online = true
clientRepository.save(client)
}

private suspend fun insertClient(request: ClientCreateRequest): TClient {
Expand Down

0 comments on commit f3a1742

Please sign in to comment.