From 3a53769421b7bbb62d4e62b534d820c8e0d7a718 Mon Sep 17 00:00:00 2001 From: aarbit Date: Thu, 8 Jan 2026 22:14:28 -0600 Subject: [PATCH] Adds stubs for some basic Team CRUD --- .../controller/TeamController.kt | 27 +++++++++++++++++++ .../model/converter/TeamConverter.kt | 22 +++++++++++++++ .../scavengerhuntapi/model/domain/Team.kt | 9 +++++++ .../model/request/TeamRequest.kt | 5 ++++ .../model/response/TeamResponse.kt | 8 ++++++ .../scavengerhuntapi/service/TeamService.kt | 21 +++++++++++++++ 6 files changed, 92 insertions(+) create mode 100644 src/main/kotlin/net/halfbinary/scavengerhuntapi/controller/TeamController.kt create mode 100644 src/main/kotlin/net/halfbinary/scavengerhuntapi/model/converter/TeamConverter.kt create mode 100644 src/main/kotlin/net/halfbinary/scavengerhuntapi/model/domain/Team.kt create mode 100644 src/main/kotlin/net/halfbinary/scavengerhuntapi/model/request/TeamRequest.kt create mode 100644 src/main/kotlin/net/halfbinary/scavengerhuntapi/model/response/TeamResponse.kt create mode 100644 src/main/kotlin/net/halfbinary/scavengerhuntapi/service/TeamService.kt diff --git a/src/main/kotlin/net/halfbinary/scavengerhuntapi/controller/TeamController.kt b/src/main/kotlin/net/halfbinary/scavengerhuntapi/controller/TeamController.kt new file mode 100644 index 0000000..c603979 --- /dev/null +++ b/src/main/kotlin/net/halfbinary/scavengerhuntapi/controller/TeamController.kt @@ -0,0 +1,27 @@ +package net.halfbinary.scavengerhuntapi.controller + +import jakarta.validation.Valid +import net.halfbinary.scavengerhuntapi.model.HuntId +import net.halfbinary.scavengerhuntapi.model.request.TeamRequest +import net.halfbinary.scavengerhuntapi.model.response.TeamResponse +import org.springframework.http.ResponseEntity +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +@RestController +@RequestMapping("hunt/{id}/team") +class TeamController { + @GetMapping + fun listHuntTeams(@PathVariable id: HuntId): ResponseEntity> { + TODO() + } + + @PostMapping + fun createHuntTeam(@PathVariable id: HuntId, @Valid @RequestBody team: TeamRequest) { + TODO() + } +} \ No newline at end of file diff --git a/src/main/kotlin/net/halfbinary/scavengerhuntapi/model/converter/TeamConverter.kt b/src/main/kotlin/net/halfbinary/scavengerhuntapi/model/converter/TeamConverter.kt new file mode 100644 index 0000000..f0fe2f5 --- /dev/null +++ b/src/main/kotlin/net/halfbinary/scavengerhuntapi/model/converter/TeamConverter.kt @@ -0,0 +1,22 @@ +package net.halfbinary.scavengerhuntapi.model.converter + +import net.halfbinary.scavengerhuntapi.model.domain.Team +import net.halfbinary.scavengerhuntapi.model.record.TeamRecord +import net.halfbinary.scavengerhuntapi.model.request.TeamRequest +import net.halfbinary.scavengerhuntapi.model.response.TeamResponse + +fun TeamRequest.toDomain(): Team { + return Team(name = name) +} + +fun Team.toRecord(): TeamRecord { + return TeamRecord(id, name) +} + +fun TeamRecord.toDomain(): Team { + return Team(id, name) +} + +fun Team.toResponse(): TeamResponse { + return TeamResponse(id, name) +} \ No newline at end of file diff --git a/src/main/kotlin/net/halfbinary/scavengerhuntapi/model/domain/Team.kt b/src/main/kotlin/net/halfbinary/scavengerhuntapi/model/domain/Team.kt new file mode 100644 index 0000000..dc620f9 --- /dev/null +++ b/src/main/kotlin/net/halfbinary/scavengerhuntapi/model/domain/Team.kt @@ -0,0 +1,9 @@ +package net.halfbinary.scavengerhuntapi.model.domain + +import net.halfbinary.scavengerhuntapi.model.TeamId +import java.util.UUID + +data class Team( + val id: TeamId = UUID.randomUUID(), + val name: String +) diff --git a/src/main/kotlin/net/halfbinary/scavengerhuntapi/model/request/TeamRequest.kt b/src/main/kotlin/net/halfbinary/scavengerhuntapi/model/request/TeamRequest.kt new file mode 100644 index 0000000..5fab85e --- /dev/null +++ b/src/main/kotlin/net/halfbinary/scavengerhuntapi/model/request/TeamRequest.kt @@ -0,0 +1,5 @@ +package net.halfbinary.scavengerhuntapi.model.request + +data class TeamRequest( + val name: String +) diff --git a/src/main/kotlin/net/halfbinary/scavengerhuntapi/model/response/TeamResponse.kt b/src/main/kotlin/net/halfbinary/scavengerhuntapi/model/response/TeamResponse.kt new file mode 100644 index 0000000..3df18ab --- /dev/null +++ b/src/main/kotlin/net/halfbinary/scavengerhuntapi/model/response/TeamResponse.kt @@ -0,0 +1,8 @@ +package net.halfbinary.scavengerhuntapi.model.response + +import net.halfbinary.scavengerhuntapi.model.TeamId + +data class TeamResponse( + val id: TeamId, + val name: String +) diff --git a/src/main/kotlin/net/halfbinary/scavengerhuntapi/service/TeamService.kt b/src/main/kotlin/net/halfbinary/scavengerhuntapi/service/TeamService.kt new file mode 100644 index 0000000..cb5a86c --- /dev/null +++ b/src/main/kotlin/net/halfbinary/scavengerhuntapi/service/TeamService.kt @@ -0,0 +1,21 @@ +package net.halfbinary.scavengerhuntapi.service + +import net.halfbinary.scavengerhuntapi.model.HuntId +import net.halfbinary.scavengerhuntapi.model.TeamId +import net.halfbinary.scavengerhuntapi.model.domain.Team +import org.springframework.stereotype.Service + +@Service +class TeamService { + fun getListOfTeamsForHunt(huntId: HuntId): List { + TODO() + } + + fun createTeam(name: String): Team { + TODO() + } + + fun addTeamToHunt(huntId: HuntId, teamId: TeamId) { + TODO() + } +} \ No newline at end of file