-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat : PvP leaderboard * fix : commit bugs * fix : commit bugs
- Loading branch information
1 parent
7d1234a
commit 44054a9
Showing
7 changed files
with
353 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
library/src/main/kotlin/delta/codecharacter/core/PvpLeaderboardApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.1.0). | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
*/ | ||
package delta.codecharacter.core | ||
|
||
import delta.codecharacter.dtos.PvPLeaderBoardResponseDto | ||
import io.swagger.v3.oas.annotations.* | ||
import io.swagger.v3.oas.annotations.enums.* | ||
import io.swagger.v3.oas.annotations.media.* | ||
import io.swagger.v3.oas.annotations.responses.* | ||
import io.swagger.v3.oas.annotations.security.* | ||
import org.springframework.http.HttpStatus | ||
import org.springframework.http.MediaType | ||
import org.springframework.http.ResponseEntity | ||
|
||
import org.springframework.web.bind.annotation.* | ||
import org.springframework.validation.annotation.Validated | ||
import org.springframework.web.context.request.NativeWebRequest | ||
import org.springframework.beans.factory.annotation.Autowired | ||
|
||
import jakarta.validation.constraints.DecimalMax | ||
import jakarta.validation.constraints.DecimalMin | ||
import jakarta.validation.constraints.Email | ||
import jakarta.validation.constraints.Max | ||
import jakarta.validation.constraints.Min | ||
import jakarta.validation.constraints.NotNull | ||
import jakarta.validation.constraints.Pattern | ||
import jakarta.validation.constraints.Size | ||
import jakarta.validation.Valid | ||
|
||
import kotlin.collections.List | ||
import kotlin.collections.Map | ||
|
||
@Validated | ||
@RequestMapping("\${api.base-path:}") | ||
interface PvpLeaderboardApi { | ||
|
||
@Operation( | ||
summary = "Get PvP leaderboard", | ||
operationId = "getPvPLeaderboard", | ||
description = """Get PvP leaderboard""", | ||
responses = [ | ||
ApiResponse(responseCode = "200", description = "OK", content = [Content(array = ArraySchema(schema = Schema(implementation = PvPLeaderBoardResponseDto::class)))]), | ||
ApiResponse(responseCode = "401", description = "Unauthorized") | ||
], | ||
security = [ SecurityRequirement(name = "http-bearer") ] | ||
) | ||
@RequestMapping( | ||
method = [RequestMethod.GET], | ||
value = ["/pvpleaderboard"], | ||
produces = ["application/json"] | ||
) | ||
fun getPvPLeaderboard(@Parameter(description = "Index of the page") @Valid @RequestParam(value = "page", required = false) page: kotlin.Int?,@Parameter(description = "Size of the page") @Valid @RequestParam(value = "size", required = false) size: kotlin.Int?): ResponseEntity<List<PvPLeaderBoardResponseDto>> { | ||
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
library/src/main/kotlin/delta/codecharacter/dtos/PvPLeaderBoardResponseDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package delta.codecharacter.dtos | ||
|
||
import java.util.Objects | ||
import com.fasterxml.jackson.annotation.JsonProperty | ||
import delta.codecharacter.dtos.PublicUserDto | ||
import delta.codecharacter.dtos.PvPUserStatsDto | ||
import jakarta.validation.constraints.DecimalMax | ||
import jakarta.validation.constraints.DecimalMin | ||
import jakarta.validation.constraints.Email | ||
import jakarta.validation.constraints.Max | ||
import jakarta.validation.constraints.Min | ||
import jakarta.validation.constraints.NotNull | ||
import jakarta.validation.constraints.Pattern | ||
import jakarta.validation.constraints.Size | ||
import jakarta.validation.Valid | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
/** | ||
* Response model for PvP leaderboard | ||
* @param user | ||
* @param stats | ||
*/ | ||
data class PvPLeaderBoardResponseDto( | ||
|
||
@field:Valid | ||
@Schema(example = "null", required = true, description = "") | ||
@get:JsonProperty("user", required = true) val user: PublicUserDto, | ||
|
||
@field:Valid | ||
@Schema(example = "null", required = true, description = "") | ||
@get:JsonProperty("stats", required = true) val stats: PvPUserStatsDto | ||
) { | ||
|
||
} | ||
|
35 changes: 35 additions & 0 deletions
35
library/src/main/kotlin/delta/codecharacter/dtos/PvPUserStatsDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package delta.codecharacter.dtos | ||
|
||
import java.util.Objects | ||
import com.fasterxml.jackson.annotation.JsonProperty | ||
import jakarta.validation.constraints.DecimalMax | ||
import jakarta.validation.constraints.DecimalMin | ||
import jakarta.validation.constraints.Email | ||
import jakarta.validation.constraints.Max | ||
import jakarta.validation.constraints.Min | ||
import jakarta.validation.constraints.NotNull | ||
import jakarta.validation.constraints.Pattern | ||
import jakarta.validation.constraints.Size | ||
import jakarta.validation.Valid | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
/** | ||
* PvP User stats model | ||
* @param rating | ||
* @param wins | ||
* @param losses | ||
*/ | ||
data class PvPUserStatsDto( | ||
|
||
@Schema(example = "1000", required = true, description = "") | ||
@get:JsonProperty("rating", required = true) val rating: java.math.BigDecimal, | ||
|
||
@Schema(example = "1", required = true, description = "") | ||
@get:JsonProperty("wins", required = true) val wins: kotlin.Int = 0, | ||
|
||
@Schema(example = "1", required = true, description = "") | ||
@get:JsonProperty("losses", required = true) val losses: kotlin.Int | ||
) { | ||
|
||
} | ||
|
19 changes: 19 additions & 0 deletions
19
server/src/main/kotlin/delta/codecharacter/server/leaderboard/PvPLeaderBoardController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package delta.codecharacter.server.leaderboard | ||
|
||
import delta.codecharacter.core.PvpLeaderboardApi | ||
import delta.codecharacter.dtos.PvPLeaderBoardResponseDto | ||
import delta.codecharacter.server.user.public_user.PublicUserService | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.web.bind.annotation.RestController | ||
import org.springframework.http.ResponseEntity | ||
|
||
@RestController | ||
class PvPLeaderBoardController (@Autowired private val publicUserService: PublicUserService) : | ||
PvpLeaderboardApi { | ||
override fun getPvPLeaderboard( | ||
page: Int?, | ||
size: Int?, | ||
): ResponseEntity<List<PvPLeaderBoardResponseDto>> { | ||
return ResponseEntity.ok(publicUserService.getPvPLeaderboard(page, size)) | ||
} | ||
} |
Oops, something went wrong.