-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
475d08d
commit 61f5daa
Showing
11 changed files
with
154 additions
and
6 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
18 changes: 18 additions & 0 deletions
18
src/main/kotlin/com/hero/alignlab/domain/group/application/GroupUserScoreService.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,18 @@ | ||
package com.hero.alignlab.domain.group.application | ||
|
||
import com.hero.alignlab.domain.group.domain.GroupUserScore | ||
import com.hero.alignlab.domain.group.infrastructure.GroupUserScoreRepository | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.withContext | ||
import org.springframework.stereotype.Service | ||
|
||
@Service | ||
class GroupUserScoreService( | ||
private val groupUserScoreRepository: GroupUserScoreRepository, | ||
) { | ||
suspend fun findAllByGroupId(groupId: Long): List<GroupUserScore> { | ||
return withContext(Dispatchers.IO) { | ||
groupUserScoreRepository.findAllByGroupId(groupId) | ||
} | ||
} | ||
} |
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
24 changes: 24 additions & 0 deletions
24
src/main/kotlin/com/hero/alignlab/domain/group/domain/GroupUserScore.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,24 @@ | ||
package com.hero.alignlab.domain.group.domain | ||
|
||
import com.hero.alignlab.domain.common.domain.BaseEntity | ||
import jakarta.persistence.* | ||
|
||
@Entity | ||
@Table(name = "`group_user_score`") | ||
class GroupUserScore( | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
val id: Long = -1, | ||
|
||
@Column(name = "group_id") | ||
val groupId: Long, | ||
|
||
@Column(name = "group_user_id") | ||
val groupUserId: Long, | ||
|
||
@Column(name = "uid") | ||
val uid: Long, | ||
|
||
@Column(name = "score") | ||
var score: Int?, | ||
) : BaseEntity() |
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
12 changes: 12 additions & 0 deletions
12
src/main/kotlin/com/hero/alignlab/domain/group/infrastructure/GroupUserScoreRepository.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,12 @@ | ||
package com.hero.alignlab.domain.group.infrastructure | ||
|
||
import com.hero.alignlab.domain.group.domain.GroupUserScore | ||
import org.springframework.data.jpa.repository.JpaRepository | ||
import org.springframework.stereotype.Repository | ||
import org.springframework.transaction.annotation.Transactional | ||
|
||
@Transactional(readOnly = true) | ||
@Repository | ||
interface GroupUserScoreRepository : JpaRepository<GroupUserScore, Long> { | ||
fun findAllByGroupId(groupId: Long): List<GroupUserScore> | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/kotlin/com/hero/alignlab/domain/group/model/response/GetGroupRanksResponse.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,13 @@ | ||
package com.hero.alignlab.domain.group.model.response | ||
|
||
data class GetGroupRanksResponse( | ||
val groupId: Long, | ||
val ranks: List<GetGroupRankResponse> | ||
) | ||
|
||
data class GetGroupRankResponse( | ||
val groupUserId: Long, | ||
val name: String, | ||
val rank: Int, | ||
val score: Int, | ||
) |
26 changes: 26 additions & 0 deletions
26
src/main/kotlin/com/hero/alignlab/domain/group/resource/GroupUserScoreResource.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,26 @@ | ||
package com.hero.alignlab.domain.group.resource | ||
|
||
import com.hero.alignlab.common.extension.wrapOk | ||
import com.hero.alignlab.domain.auth.model.AuthUser | ||
import com.hero.alignlab.domain.group.application.GroupFacade | ||
import io.swagger.v3.oas.annotations.Operation | ||
import io.swagger.v3.oas.annotations.tags.Tag | ||
import org.springframework.http.MediaType | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RequestParam | ||
import org.springframework.web.bind.annotation.RestController | ||
|
||
@Tag(name = "Group User Score API") | ||
@RestController | ||
@RequestMapping(produces = [MediaType.APPLICATION_JSON_VALUE]) | ||
class GroupUserScoreResource( | ||
private val groupFacade: GroupFacade, | ||
) { | ||
@Operation(summary = "바른 자세 랭킹") | ||
@GetMapping("/api/v1/group-scores") | ||
suspend fun getScores( | ||
user: AuthUser, | ||
@RequestParam groupId: Long, | ||
) = groupFacade.getGroupRank(user, groupId).wrapOk() | ||
} |
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