Skip to content

Commit

Permalink
Merge branch 'develop_back_core' into feat/group_capsule_open-B-core-…
Browse files Browse the repository at this point in the history
…#403
  • Loading branch information
seokho-1116 authored May 14, 2024
2 parents 95a54b2 + ebe786a commit f4c9c1c
Show file tree
Hide file tree
Showing 385 changed files with 14,484 additions and 1,326 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,25 +93,27 @@ public TokenResponse validVerificationMessage(
throw new CertificationNumberNotMatchException();
}

updateToVerifiedMember(memberId, plain);
final Long verifiedMemberId = updateToVerifiedMember(memberId, plain);

return tokenManager.createNewToken(memberId);
return tokenManager.createNewToken(verifiedMemberId);
}

private boolean isNotMatch(final String certificationNumber,
final String findCertificationNumber) {
return !certificationNumber.equals(findCertificationNumber);
}

private void updateToVerifiedMember(final Long memberId, final byte[] plain) {
private Long updateToVerifiedMember(final Long memberId, final byte[] plain) {
final MemberTemporary memberTemporary = memberTemporaryRepository.findById(memberId)
.orElseThrow(MemberNotFoundException::new);

memberTemporaryRepository.delete(memberTemporary);

final Member member = memberTemporary.toMember(hashEncryptionManager.encrypt(plain),
final Member verifiedMember = memberTemporary.toMember(hashEncryptionManager.encrypt(plain),
aesEncryptionManager.encryptWithPrefixIV(plain));

memberRepository.save(member);
memberRepository.save(verifiedMember);

return verifiedMember.getId();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public record NearbyARCapsuleSummaryResponse(
@Schema(description = "캡슐 타입")
CapsuleType capsuleType
) {

public NearbyARCapsuleSummaryResponse {
if (dueDate != null) {
dueDate = dueDate.withZoneSameInstant(ResponseMappingConstant.ZONE_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Optional<Capsule> findCapsuleByMemberIdAndCapsuleId(

@Modifying(clearAutomatically = true)
@Query("UPDATE Capsule c SET c.isOpened = true WHERE c.id = :capsuleId and c.member.id = :memberId")
void updateIsOpenedTrue(
int updateIsOpenedTrue(
@Param("memberId") Long memberId,
@Param("capsuleId") Long capsuleId
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ public Capsule findCapsuleByMemberIdAndCapsuleId(final Long memberId, final Long

@Transactional
public void updateIsOpenedTrue(final Long memberId, final Long capsuleId) {
capsuleRepository.updateIsOpenedTrue(memberId, capsuleId);
int isOpenedTrue = capsuleRepository.updateIsOpenedTrue(memberId, capsuleId);

if (isOpenedTrue != 1) {
throw new CapsuleNotFondException();
}
}

@Transactional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.util.function.Function;
import site.timecapsulearchive.core.domain.capsule.entity.CapsuleType;
import site.timecapsulearchive.core.domain.capsule.secret_capsule.data.response.MySecreteCapsuleResponse;
import site.timecapsulearchive.core.global.common.response.ResponseMappingConstant;

public record MySecreteCapsuleDto(
Long capsuleId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.springframework.http.ResponseEntity;
import site.timecapsulearchive.core.domain.friend.data.request.SearchFriendsRequest;
import site.timecapsulearchive.core.domain.friend.data.request.SendFriendRequest;
import site.timecapsulearchive.core.domain.friend.data.response.FriendReqStatusResponse;
import site.timecapsulearchive.core.domain.friend.data.response.FriendRequestsSliceResponse;
import site.timecapsulearchive.core.domain.friend.data.response.FriendsSliceResponse;
import site.timecapsulearchive.core.domain.friend.data.response.SearchFriendsResponse;
Expand Down Expand Up @@ -129,7 +128,7 @@ ResponseEntity<ApiSpec<String>> denyFriendRequest(
description = "외부 API 요청 실패"
)
})
ResponseEntity<ApiSpec<FriendReqStatusResponse>> requestFriend(
ResponseEntity<ApiSpec<String>> requestFriend(
Long memberId,

@Parameter(in = ParameterIn.PATH, description = "친구 아이디", required = true, schema = @Schema())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import site.timecapsulearchive.core.domain.friend.data.dto.SearchFriendSummaryDto;
import site.timecapsulearchive.core.domain.friend.data.request.SearchFriendsRequest;
import site.timecapsulearchive.core.domain.friend.data.request.SendFriendRequest;
import site.timecapsulearchive.core.domain.friend.data.response.FriendReqStatusResponse;
import site.timecapsulearchive.core.domain.friend.data.response.FriendRequestsSliceResponse;
import site.timecapsulearchive.core.domain.friend.data.response.FriendsSliceResponse;
import site.timecapsulearchive.core.domain.friend.data.response.SearchFriendsResponse;
Expand Down Expand Up @@ -89,7 +88,9 @@ public ResponseEntity<ApiSpec<String>> deleteFriend(
friendService.deleteFriend(memberId, friendId);

return ResponseEntity.ok(
ApiSpec.empty(SuccessCode.SUCCESS)
ApiSpec.empty(
SuccessCode.SUCCESS
)
);
}

Expand All @@ -101,23 +102,26 @@ public ResponseEntity<ApiSpec<String>> denyFriendRequest(

friendService.denyRequestFriend(memberId, friendId);

return ResponseEntity.ok(ApiSpec.empty(SuccessCode.SUCCESS));

return ResponseEntity.ok(
ApiSpec.empty(
SuccessCode.SUCCESS
)
);
}

@PostMapping(value = "/{friend_id}/request")
@Override
public ResponseEntity<ApiSpec<FriendReqStatusResponse>> requestFriend(
public ResponseEntity<ApiSpec<String>> requestFriend(
@AuthenticationPrincipal final Long memberId,
@PathVariable("friend_id") final Long friendId) {

return ResponseEntity.accepted()
.body(
ApiSpec.success(
SuccessCode.SUCCESS,
friendService.requestFriend(memberId, friendId)
)
);
friendService.requestFriend(memberId, friendId);

return ResponseEntity.ok(
ApiSpec.empty(
SuccessCode.ACCEPTED
)
);
}

@PostMapping(value = "/requests")
Expand All @@ -128,8 +132,11 @@ public ResponseEntity<ApiSpec<String>> requestFriends(
) {
friendFacade.requestFriends(memberId, request.friendIds());

return ResponseEntity.accepted()
.body(ApiSpec.empty(SuccessCode.ACCEPTED));
return ResponseEntity.ok(
ApiSpec.empty(
SuccessCode.ACCEPTED
)
);
}

@PostMapping(value = "/{friend_id}/accept-request")
Expand All @@ -140,7 +147,11 @@ public ResponseEntity<ApiSpec<String>> acceptFriendRequest(
) {
friendService.acceptFriend(memberId, friendId);

return ResponseEntity.ok(ApiSpec.empty(SuccessCode.SUCCESS));
return ResponseEntity.ok(
ApiSpec.empty(
SuccessCode.SUCCESS
)
);
}

@PostMapping(
Expand Down Expand Up @@ -173,12 +184,11 @@ public ResponseEntity<ApiSpec<SearchTagFriendSummaryResponse>> searchFriendByTag
@AuthenticationPrincipal Long memberId,
@RequestParam(value = "friend_tag") final String tag
) {
return ResponseEntity.ok()
.body(
ApiSpec.success(
SuccessCode.SUCCESS,
friendService.searchFriend(memberId, tag)
)
);
return ResponseEntity.ok(
ApiSpec.success(
SuccessCode.SUCCESS,
friendService.searchFriend(memberId, tag)
)
);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.sql.Types;
import java.time.ZonedDateTime;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
Expand All @@ -19,8 +21,8 @@ public void bulkSave(final Long ownerId, final List<Long> friendIds) {
jdbcTemplate.batchUpdate(
"""
INSERT INTO friend_invite (
friend_invite_id, owner_id, friend_id
) values (?, ?, ?)
friend_invite_id, owner_id, friend_id, created_at, updated_at
) values (?, ?, ?, ?, ?)
""",
new BatchPreparedStatementSetter() {

Expand All @@ -30,6 +32,8 @@ public void setValues(final PreparedStatement ps, final int i) throws SQLExcepti
ps.setNull(1, Types.BIGINT);
ps.setLong(2, ownerId);
ps.setLong(3, friendId);
ps.setTimestamp(4, Timestamp.valueOf(ZonedDateTime.now().toLocalDateTime()));
ps.setTimestamp(5, Timestamp.valueOf(ZonedDateTime.now().toLocalDateTime()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ List<FriendInvite> findFriendInviteWithMembersByOwnerIdAndFriendId(

Optional<FriendInvite> findFriendInviteByOwnerIdAndFriendId(Long memberId, Long targetId);

void deleteFriendInviteById(Long id);
int deleteFriendInviteByOwnerIdAndFriendId(Long memberId, Long targetId);

void delete(FriendInvite friendInvite);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import site.timecapsulearchive.core.domain.friend.data.dto.FriendSummaryDto;
import site.timecapsulearchive.core.domain.friend.data.dto.SearchFriendSummaryDto;
import site.timecapsulearchive.core.domain.friend.data.dto.SearchFriendSummaryDtoByTag;
import site.timecapsulearchive.core.domain.friend.data.response.FriendReqStatusResponse;
import site.timecapsulearchive.core.domain.friend.data.response.SearchTagFriendSummaryResponse;
import site.timecapsulearchive.core.domain.friend.entity.FriendInvite;
import site.timecapsulearchive.core.domain.friend.entity.MemberFriend;
Expand Down Expand Up @@ -43,7 +42,7 @@ public class FriendService {
private final SocialNotificationManager socialNotificationManager;
private final TransactionTemplate transactionTemplate;

public FriendReqStatusResponse requestFriend(final Long memberId, final Long friendId) {
public void requestFriend(final Long memberId, final Long friendId) {
validateFriendDuplicateId(memberId, friendId);
validateTwoWayInvite(memberId, friendId);

Expand All @@ -63,8 +62,6 @@ protected void doInTransactionWithoutResult(TransactionStatus status) {
});

socialNotificationManager.sendFriendReqMessage(owner.getNickname(), friendId);

return FriendReqStatusResponse.success();
}

private void validateFriendDuplicateId(final Long memberId, final Long friendId) {
Expand Down Expand Up @@ -114,20 +111,22 @@ protected void doInTransactionWithoutResult(TransactionStatus status) {
}

@Transactional
public void denyRequestFriend(Long memberId, Long friendId) {
public void denyRequestFriend(final Long memberId, final Long friendId) {
validateFriendDuplicateId(memberId, friendId);
final FriendInvite friendInvite = friendInviteRepository
.findFriendInviteByOwnerIdAndFriendId(memberId, friendId).orElseThrow(
FriendNotFoundException::new);

friendInviteRepository.deleteFriendInviteById(friendInvite.getId());
int isDenyRequest = friendInviteRepository.deleteFriendInviteByOwnerIdAndFriendId(friendId,
memberId);

if (isDenyRequest != 1) {
throw new FriendTwoWayInviteException();
}
}

@Transactional
public void deleteFriend(final Long memberId, final Long friendId) {
validateFriendDuplicateId(memberId, friendId);

List<MemberFriend> memberFriends = memberFriendRepository
final List<MemberFriend> memberFriends = memberFriendRepository
.findMemberFriendByOwnerIdAndFriendId(memberId, friendId);

memberFriends.forEach(memberFriendRepository::delete);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import site.timecapsulearchive.core.domain.group.data.reqeust.GroupCreateRequest;
import site.timecapsulearchive.core.domain.group.data.reqeust.GroupUpdateRequest;
import site.timecapsulearchive.core.domain.group.data.response.GroupDetailResponse;
Expand All @@ -32,15 +31,24 @@ public interface GroupApi {
@ApiResponse(
responseCode = "200",
description = "처리 완료"
),
@ApiResponse(
responseCode = "404",
description = "그룹 초대 찾기 실패"
),
@ApiResponse(
responseCode = "500",
description = "외부 API 요청 실패"
)
})
@PostMapping(value = "/groups/{group_id}/members/{member_id}/accept-invitation")
ResponseEntity<Void> acceptGroupInvitation(
@Parameter(in = ParameterIn.PATH, description = "그룹 아이디", required = true, schema = @Schema())
@PathVariable("group_id") Long groupId,
ResponseEntity<ApiSpec<String>> acceptGroupInvitation(
Long memberId,

@Parameter(in = ParameterIn.PATH, description = "대상 회원 아이디", required = true, schema = @Schema())
@PathVariable("member_id") Long memberId
@Parameter(in = ParameterIn.PATH, description = "그룹 아이디", required = true)
Long groupId,

@Parameter(in = ParameterIn.PATH, description = "대상 회원 아이디", required = true)
Long targetId
);

@Operation(
Expand All @@ -53,6 +61,10 @@ ResponseEntity<Void> acceptGroupInvitation(
@ApiResponse(
responseCode = "200",
description = "처리완료"
),
@ApiResponse(
responseCode = "500",
description = "외부 API 요청 실패"
)
})
ResponseEntity<ApiSpec<String>> createGroup(
Expand Down Expand Up @@ -111,13 +123,13 @@ ResponseEntity<Void> deleteGroupMember(
description = "처리 완료"
)
})
@PostMapping(value = "/groups/{group_id}/members/{member_id}/deny-invitation")
ResponseEntity<Void> denyGroupInvitation(
@Parameter(in = ParameterIn.PATH, description = "그룹 아이디", required = true, schema = @Schema())
@PathVariable("group_id") Long groupId,
ResponseEntity<ApiSpec<String>> rejectGroupInvitation(
Long memberId,

@Parameter(in = ParameterIn.PATH, description = "대상 회원 아이디", required = true, schema = @Schema())
@PathVariable("member_id") Long memberId
Long groupId,

@Parameter(in = ParameterIn.PATH, description = "그룹 초대 대상 아이디", required = true)
Long groupOwnerId
);

@Operation(
Expand Down Expand Up @@ -181,13 +193,14 @@ ResponseEntity<ApiSpec<GroupsSliceResponse>> findGroups(
description = "처리 시작"
)
})
@PostMapping(value = "/groups/{group_id}/members/{member_id}/invitation")
ResponseEntity<Void> inviteGroup(
@Parameter(in = ParameterIn.PATH, description = "그룹 아이디", required = true, schema = @Schema())
@PathVariable("group_id") Long groupId,
ResponseEntity<ApiSpec<String>> inviteGroup(
Long memberId,

@Parameter(in = ParameterIn.PATH, description = "대상 회원 아이디", required = true, schema = @Schema())
@PathVariable("member_id") Long memberId
@Parameter(in = ParameterIn.PATH, description = "그룹 아이디", required = true)
Long groupId,

@Parameter(in = ParameterIn.PATH, description = "대상 회원 아이디", required = true)
Long targetId
);

@Operation(
Expand Down
Loading

0 comments on commit f4c9c1c

Please sign in to comment.