diff --git a/src/main/java/org/ioteatime/meonghanyangserver/group/controller/GroupApi.java b/src/main/java/org/ioteatime/meonghanyangserver/group/controller/GroupApi.java index 8a1c7712..ba39c9be 100644 --- a/src/main/java/org/ioteatime/meonghanyangserver/group/controller/GroupApi.java +++ b/src/main/java/org/ioteatime/meonghanyangserver/group/controller/GroupApi.java @@ -22,5 +22,5 @@ public interface GroupApi { Api generateCctvInvite(@LoginMember Long userId); @Operation(summary = "그룹 통합 정보를 조회합니다.") - Api getGroupTotalData(Authentication authentication); + Api getGroupTotalData(@LoginMember Long userId); } diff --git a/src/main/java/org/ioteatime/meonghanyangserver/group/controller/GroupController.java b/src/main/java/org/ioteatime/meonghanyangserver/group/controller/GroupController.java index 2414f4a3..ab50c339 100644 --- a/src/main/java/org/ioteatime/meonghanyangserver/group/controller/GroupController.java +++ b/src/main/java/org/ioteatime/meonghanyangserver/group/controller/GroupController.java @@ -42,8 +42,8 @@ public Api generateCctvInvite(@LoginMember Long userId) { } @GetMapping("/info-list") - public Api getGroupTotalData(Authentication authentication) { - GroupTotalResponse groupTotalResponse = groupService.getGroupTotalData(authentication); + public Api getGroupTotalData(@LoginMember Long userId) { + GroupTotalResponse groupTotalResponse = groupService.getGroupTotalData(userId); return Api.success(GroupSuccessType.GET_GROUP_TOTAL_INFO, groupTotalResponse); } } diff --git a/src/main/java/org/ioteatime/meonghanyangserver/group/domain/GroupEntity.java b/src/main/java/org/ioteatime/meonghanyangserver/group/domain/GroupEntity.java index f4c86274..4b3b83c3 100644 --- a/src/main/java/org/ioteatime/meonghanyangserver/group/domain/GroupEntity.java +++ b/src/main/java/org/ioteatime/meonghanyangserver/group/domain/GroupEntity.java @@ -26,9 +26,9 @@ public class GroupEntity { @Column(nullable = false) private LocalDateTime createdAt; - @OneToMany(mappedBy = "group", cascade = CascadeType.ALL) + @OneToMany(mappedBy = "group") private List cctvs; - @OneToMany(mappedBy = "group", cascade = CascadeType.ALL) + @OneToMany(mappedBy = "group") private List groupUserEntities; } diff --git a/src/main/java/org/ioteatime/meonghanyangserver/group/dto/response/CreateGroupResponse.java b/src/main/java/org/ioteatime/meonghanyangserver/group/dto/response/CreateGroupResponse.java index aac3864c..d76ca449 100644 --- a/src/main/java/org/ioteatime/meonghanyangserver/group/dto/response/CreateGroupResponse.java +++ b/src/main/java/org/ioteatime/meonghanyangserver/group/dto/response/CreateGroupResponse.java @@ -1,5 +1,10 @@ package org.ioteatime.meonghanyangserver.group.dto.response; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import java.time.LocalDateTime; -public record CreateGroupResponse(Long groupId, String groupName, LocalDateTime createdAt) {} +@Schema(description = "그룹 생성 정보 응답") +public record CreateGroupResponse( + @NotNull Long groupId, @NotBlank String groupName, @NotNull LocalDateTime createdAt) {} diff --git a/src/main/java/org/ioteatime/meonghanyangserver/group/dto/response/GroupTotalResponse.java b/src/main/java/org/ioteatime/meonghanyangserver/group/dto/response/GroupTotalResponse.java index c56d9963..c79f448e 100644 --- a/src/main/java/org/ioteatime/meonghanyangserver/group/dto/response/GroupTotalResponse.java +++ b/src/main/java/org/ioteatime/meonghanyangserver/group/dto/response/GroupTotalResponse.java @@ -1,12 +1,16 @@ package org.ioteatime.meonghanyangserver.group.dto.response; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import java.time.LocalDateTime; import java.util.List; import org.ioteatime.meonghanyangserver.cctv.dto.response.CctvInfoResponse; +@Schema(description = "그룹 통합 정보 응답") public record GroupTotalResponse( - Long groupId, - String groupName, - LocalDateTime createdAt, + @NotNull Long groupId, + @NotBlank String groupName, + @NotNull LocalDateTime createdAt, List groupUser, List cctv) {} diff --git a/src/main/java/org/ioteatime/meonghanyangserver/group/dto/response/GroupUserInfoResponse.java b/src/main/java/org/ioteatime/meonghanyangserver/group/dto/response/GroupUserInfoResponse.java index 8528b0db..400c871d 100644 --- a/src/main/java/org/ioteatime/meonghanyangserver/group/dto/response/GroupUserInfoResponse.java +++ b/src/main/java/org/ioteatime/meonghanyangserver/group/dto/response/GroupUserInfoResponse.java @@ -1,3 +1,8 @@ package org.ioteatime.meonghanyangserver.group.dto.response; -public record GroupUserInfoResponse(Long userId, String nickname) {} +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +@Schema(description = "그룹 유저 정보 응답") +public record GroupUserInfoResponse(@NotNull Long userId, @NotBlank String nickname) {} diff --git a/src/main/java/org/ioteatime/meonghanyangserver/group/repository/groupuser/GroupUserRepository.java b/src/main/java/org/ioteatime/meonghanyangserver/group/repository/groupuser/GroupUserRepository.java index 654aee31..b522ad97 100644 --- a/src/main/java/org/ioteatime/meonghanyangserver/group/repository/groupuser/GroupUserRepository.java +++ b/src/main/java/org/ioteatime/meonghanyangserver/group/repository/groupuser/GroupUserRepository.java @@ -11,5 +11,5 @@ public interface GroupUserRepository { Optional findByUserId(Long userId); - Optional findGroupUser(UserEntity userEntity); + Optional findGroupUser(Long userId); } diff --git a/src/main/java/org/ioteatime/meonghanyangserver/group/repository/groupuser/GroupUserRepositoryImpl.java b/src/main/java/org/ioteatime/meonghanyangserver/group/repository/groupuser/GroupUserRepositoryImpl.java index b416dc2f..925fdfc7 100644 --- a/src/main/java/org/ioteatime/meonghanyangserver/group/repository/groupuser/GroupUserRepositoryImpl.java +++ b/src/main/java/org/ioteatime/meonghanyangserver/group/repository/groupuser/GroupUserRepositoryImpl.java @@ -28,9 +28,8 @@ public Optional findByUserId(Long userId) { } @Override - public Optional findGroupUser(UserEntity userEntity) { - Optional groupUserEntity = - jpaGroupUserRepository.findByUserId(userEntity.getId()); + public Optional findGroupUser(Long userId) { + Optional groupUserEntity = jpaGroupUserRepository.findByUserId(userId); return groupUserEntity; } diff --git a/src/main/java/org/ioteatime/meonghanyangserver/group/service/GroupService.java b/src/main/java/org/ioteatime/meonghanyangserver/group/service/GroupService.java index 6ea1cf18..1072c236 100644 --- a/src/main/java/org/ioteatime/meonghanyangserver/group/service/GroupService.java +++ b/src/main/java/org/ioteatime/meonghanyangserver/group/service/GroupService.java @@ -45,12 +45,9 @@ public CreateGroupResponse createGroup(Authentication authentication) { return GroupResponseMapper.from(newGroupEntity); } - public GroupTotalResponse getGroupTotalData(Authentication authentication) { - CustomUserDetail userDetails = (CustomUserDetail) authentication.getPrincipal(); - - UserEntity userEntity = userDetails.getUserEntity(); + public GroupTotalResponse getGroupTotalData(Long userId) { - GroupUserEntity groupUserEntity = groupUserService.getGroupUser(userEntity); + GroupUserEntity groupUserEntity = groupUserService.getGroupUser(userId); GroupEntity groupEntity = groupUserEntity.getGroup(); diff --git a/src/main/java/org/ioteatime/meonghanyangserver/group/service/GroupUserService.java b/src/main/java/org/ioteatime/meonghanyangserver/group/service/GroupUserService.java index e2f64578..e15b027d 100644 --- a/src/main/java/org/ioteatime/meonghanyangserver/group/service/GroupUserService.java +++ b/src/main/java/org/ioteatime/meonghanyangserver/group/service/GroupUserService.java @@ -53,10 +53,10 @@ public CctvInviteResponse generateCctvInvite(Long userId) { return new CctvInviteResponse(groupUserEntity.getGroup().getId(), kvsChannelName); } - public GroupUserEntity getGroupUser(UserEntity userEntity) { + public GroupUserEntity getGroupUser(Long userId) { GroupUserEntity groupUserEntity = groupUserRepository - .findGroupUser(userEntity) + .findGroupUser(userId) .orElseThrow( () -> new NotFoundException(GroupErrorType.GROUP_USER_NOT_FOUND)); return groupUserEntity;