Skip to content

Commit

Permalink
fix: 나의 그룹 조회 응답값 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
leeheefull committed Dec 17, 2024
1 parent 3e09cb7 commit 9bf3911
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.hero.alignlab.domain.group.application

import com.hero.alignlab.domain.auth.model.AuthUser
import com.hero.alignlab.domain.group.infrastructure.GroupTagRepository
import com.hero.alignlab.domain.group.model.response.MyGroupResponse
import com.hero.alignlab.domain.user.application.UserInfoService
import org.springframework.stereotype.Service
Expand All @@ -10,14 +11,16 @@ class MyGroupFacade(
private val groupService: GroupService,
private val groupUserService: GroupUserService,
private val userInfoService: UserInfoService,
private val groupTagRepository: GroupTagRepository
) {
// TODO : 기획 확인후, 코드 변경
suspend fun getMyGroup(user: AuthUser): MyGroupResponse? {
val groupUser = groupUserService.findByUidOrNull(user.uid) ?: return null
val group = groupService.findByIdOrThrow(groupUser.groupId)
val groupUserCount = groupUserService.countAllByGroupId(groupUser.groupId)
val ownerUserInfo = userInfoService.findByIdOrThrow(group.ownerUid)
val tagNames = groupTagRepository.findByGroupId(group.id).map { it.name }

return MyGroupResponse.of(group, groupUserCount.toInt(), ownerUserInfo.nickname)
return MyGroupResponse.of(group, groupUserCount.toInt(), ownerUserInfo.nickname, tagNames)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,32 @@ data class MyGroupResponse(
val description: String?,
/** owner uid */
val ownerUid: Long,
/** 숨김 여부 */
val isHidden: Boolean,
/** 참여 코드, 미입력시 자동 생성 */
val joinCode: String?,
/** 그룹원 수 */
val userCount: Int,
/** 그룹 정원 */
val userCapacity: Int,
/** 그룹장 명 */
val ownerNickname: String,
/** 태그 리스트, 최대 3개 */
val tagNames: List<String>?,
) {
companion object {
fun of(group: Group, userCount: Int, ownerNickname: String): MyGroupResponse {
fun of(group: Group, userCount: Int, ownerNickname: String, tagNames: List<String>?): MyGroupResponse {
return MyGroupResponse(
id = group.id,
name = group.name,
description = group.description,
ownerUid = group.ownerUid,
isHidden = group.isHidden,
joinCode = group.joinCode,
userCount = userCount,
userCapacity = group.userCapacity,
ownerNickname = ownerNickname
ownerNickname = ownerNickname,
tagNames = tagNames ?: emptyList(),
)
}
}
Expand Down

0 comments on commit 9bf3911

Please sign in to comment.