Skip to content

Commit

Permalink
fix: 그룹초대기능 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
SangWoon123 committed May 17, 2024
1 parent 3f46ac9 commit b347294
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.tukorea.planding.domain.group.dto.request;

import lombok.Builder;
import lombok.Data;

@Builder
@Data
public class GroupInviteRequest{
private Long groupId;
private String userCode;
public record GroupInviteRequest(
Long groupId,
String userCode
) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@ public class GroupInviteService {
@Transactional
public GroupInviteMessageResponse inviteGroupRoom(UserInfo userInfo, GroupInviteRequest groupInviteRequest) {
// 초대하는 사용자와 초대 대상 사용자가 같은지 확인
if (userInfo.getUserCode().equals(groupInviteRequest.getUserCode())) {
if (userInfo.getUserCode().equals(groupInviteRequest.userCode())) {
throw new BusinessException(ErrorCode.CANNOT_INVITE_YOURSELF);
}

if (!groupQueryService.getGroupById(groupInviteRequest.getGroupId()).getOwner().equals(userInfo.getUserCode())) {
if (!groupQueryService.getGroupById(groupInviteRequest.groupId()).getOwner().equals(userInfo.getUserCode())) {
throw new BusinessException(ErrorCode.UNAUTHORIZED_GROUP_ROOM_INVITATION);
}

if (groupQueryService.existGroupInUser(groupInviteRequest.getUserCode(), groupInviteRequest.getGroupId())) {
if (groupQueryService.existGroupInUser(groupInviteRequest.userCode(), groupInviteRequest.groupId())) {
throw new BusinessException(ErrorCode.USER_ALREADY_IN_GROUP);
}

GroupInviteMessageResponse groupInviteMessageResponse = GroupInviteMessageResponse.create("IN" + UUID.randomUUID(), groupInviteRequest.getGroupId(), groupInviteRequest.getUserCode(), userInfo.getId());
GroupInviteMessageResponse groupInviteMessageResponse = GroupInviteMessageResponse.create("IN" + UUID.randomUUID(), groupInviteRequest.groupId(), groupInviteRequest.userCode(), userInfo.getId());

redisGroupInviteService.createInvitation(groupInviteRequest.getUserCode(), groupInviteMessageResponse);
redisGroupInviteService.createInvitation(groupInviteRequest.userCode(), groupInviteMessageResponse);

return groupInviteMessageResponse;
}
Expand Down

0 comments on commit b347294

Please sign in to comment.