Skip to content

Commit

Permalink
chore : 머지 충돌 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
GaBaljaintheroom committed Jul 8, 2024
2 parents 575db15 + 49b807e commit 8c6c7f6
Show file tree
Hide file tree
Showing 54 changed files with 1,238 additions and 275 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@ public Optional<String> findMessageAuthenticationCodeByMemberId(final Long membe

return Optional.of(code);
}

public void delete(final Long memberId, final byte[] encrypt) {
redisTemplate.opsForHash().delete(PREFIX + memberId, encrypt);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package site.timecapsulearchive.core.domain.auth.service;

import jakarta.servlet.http.HttpServletRequest;
import java.nio.charset.StandardCharsets;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import site.timecapsulearchive.core.domain.auth.data.dto.TemporaryTokenDto;
Expand Down Expand Up @@ -77,9 +78,12 @@ public TokenDto validVerificationMessage(
final String certificationNumber,
final String receiver
) {
Long verifiedMemberId = messageVerificationService.validVerificationMessage(memberId,
certificationNumber,
receiver);
final byte[] plain = receiver.getBytes(StandardCharsets.UTF_8);

messageVerificationService.validVerificationMessage(memberId,
certificationNumber, plain);

Long verifiedMemberId = memberService.updateVerifiedMember(memberId, plain);

return tokenManager.createNewToken(verifiedMemberId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ public class MessageVerificationService {

private final MessageAuthenticationCacheRepository messageAuthenticationCacheRepository;
private final SmsApiManager smsApiManager;
private final MemberRepository memberRepository;
private final MemberTemporaryRepository memberTemporaryRepository;

private final AESEncryptionManager aesEncryptionManager;
private final HashEncryptionManager hashEncryptionManager;

/**
Expand Down Expand Up @@ -77,12 +73,11 @@ private String generateMessage(final String code, final String appHashKey) {
+ "타인 노출 금지";
}

public Long validVerificationMessage(
public void validVerificationMessage(
final Long memberId,
final String certificationNumber,
final String receiver
final byte[] plain
) {
final byte[] plain = receiver.getBytes(StandardCharsets.UTF_8);
byte[] encrypt = hashEncryptionManager.encrypt(plain);

final String findCertificationNumber = messageAuthenticationCacheRepository
Expand All @@ -93,33 +88,11 @@ public Long validVerificationMessage(
throw new CertificationNumberNotMatchException();
}

return updateToVerifiedMember(memberId, plain);
messageAuthenticationCacheRepository.delete(memberId, encrypt);
}

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

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

memberTemporaryRepository.delete(memberTemporary);

boolean isDuplicateTag = memberRepository.checkTagDuplication(memberTemporary.getTag());
if (isDuplicateTag) {
log.warn("member tag duplicate - email:{}, tag:{}", memberTemporary.getEmail(),
memberTemporary.getTag());
memberTemporary.updateTagLowerCaseSocialType();
log.warn("member tag update - tag: {}", memberTemporary.getTag());
}

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

memberRepository.save(verifiedMember);

return verifiedMember.getId();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.hibernate.annotations.Where;
import org.locationtech.jts.geom.Point;
import site.timecapsulearchive.core.domain.capsule.exception.GroupCapsuleOpenNotFoundException;
import site.timecapsulearchive.core.domain.capsule.exception.NoCapsuleAuthorityException;
import site.timecapsulearchive.core.domain.capsuleskin.entity.CapsuleSkin;
import site.timecapsulearchive.core.domain.group.entity.Group;
import site.timecapsulearchive.core.domain.member.entity.Member;
Expand Down Expand Up @@ -66,6 +67,9 @@ public class Capsule extends BaseEntity {
@Embedded
private Address address;

@Column(name = "declaration_count")
private Long declarationCount = 0L;

@OneToMany(mappedBy = "capsule")
private final List<Image> images = new ArrayList<>();

Expand Down Expand Up @@ -143,4 +147,13 @@ public boolean isAllGroupMemberOpened(Long memberId, Long capsuleId) {

return isCapsuleOpened;
}

public void upDeclarationCount() {
if (type.isPublicOrGroup()) {
declarationCount++;

return;
}
throw new NoCapsuleAuthorityException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ public enum CapsuleType {
PUBLIC,
GROUP,
TREASURE,
ALL
ALL;

public boolean isPublicOrGroup() {
return this == PUBLIC || this == GROUP;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -195,5 +195,35 @@ ResponseEntity<ApiSpec<CapsuleOpenedResponse>> updateCapsuleOpened(
@Parameter(in = ParameterIn.PATH, description = "캡슐 아이디", required = true)
Long capsuleId
);

@Operation(
summary = "공개, 그룹 캡슐 신고",
description = "공개, 그룹 캡슐을 신고한다.",
security = {@SecurityRequirement(name = "user_token")},
tags = {"capsule"}
)
@ApiResponses(value = {
@ApiResponse(
responseCode = "200",
description = "처리 완료"
),
@ApiResponse(
responseCode = "404",
description = "해당 캡슐을 찾을 수 없을 경우 발생하는 예외",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))
),
@ApiResponse(
responseCode = "403",
description = "해당 캡슐을 신고할 권한이 없을 경우 발생하는 예외",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))
)
})
ResponseEntity<ApiSpec<String>> declarationCapsule(
Long memberId,

@Parameter(in = ParameterIn.PATH, description = "신고할 캡슐 아이디", required = true)
Long capsuleId
);

}

Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,19 @@ public ResponseEntity<ApiSpec<CapsuleOpenedResponse>> updateCapsuleOpened(
);
}

@PatchMapping(value = "/{capsule_id}/declaration", produces = {"application/json"})
@Override
public ResponseEntity<ApiSpec<String>> declarationCapsule(
@AuthenticationPrincipal final Long memberId,
@PathVariable("capsule_id") final Long capsuleId
) {
capsuleService.declarationCapsule(capsuleId);

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

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public interface CapsuleRepository extends Repository<Capsule, Long>, CapsuleQue

void delete(Capsule capsule);

Optional<Capsule> findById(Long id);

@Query("select c from Capsule c where c.id = :capsuleId and c.member.id = :memberId")
Optional<Capsule> findCapsuleByMemberIdAndCapsuleId(
@Param("memberId") Long memberId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,12 @@ public void deleteRelatedAllCapsuleByMemberId(final Long memberId, final ZonedDa
capsuleSkinRepository.deleteByMemberId(memberId, deletedAt);
capsuleRepository.deleteExcludeGroupCapsuleByMemberId(memberId, deletedAt);
}

@Transactional
public void declarationCapsule(final Long capsuleId) {
Capsule capsuleToDeclaration = capsuleRepository.findById(capsuleId)
.orElseThrow(CapsuleNotFondException::new);

capsuleToDeclaration.upDeclarationCount();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Max;
import java.time.ZonedDateTime;
import org.hibernate.validator.constraints.Range;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -22,13 +22,13 @@
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.response.GroupCapsuleOpenStateResponse;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.response.GroupCapsuleMembersResponse;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.response.GroupCapsuleSliceResponse;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.response.GroupSpecificCapsuleSliceResponse;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.response.GroupCapsuleSummaryResponse;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.response.MyGroupCapsuleSliceResponse;
import site.timecapsulearchive.core.global.common.response.ApiSpec;
import site.timecapsulearchive.core.global.error.ErrorResponse;


@Validated
public interface GroupCapsuleApi {

@Operation(
Expand Down Expand Up @@ -103,8 +103,31 @@ ResponseEntity<ApiSpec<GroupCapsuleSummaryResponse>> getGroupCapsuleSummaryByCap
);

@Operation(
summary = "그룹 캡슐 목록 조회",
description = "그룹원만 볼 수 있는 그룹 캡슐 목록을 조회한다.",
summary = "사용자가 속해있는 그룹들의 캡슐 목록 조회",
description = "사용자가 속해있는 그룹들의 그룹 캡슐 목록을 조회한다.",
security = {@SecurityRequirement(name = "user_token")},
tags = {"group capsule"}
)
@ApiResponses(value = {
@ApiResponse(
responseCode = "200",
description = "처리 완료"
)
})
ResponseEntity<ApiSpec<GroupCapsuleSliceResponse>> getGroupCapsules(
Long memberId,

@Parameter(in = ParameterIn.QUERY, description = "페이지 크기", required = true)
@Max(value = 40, message = "최대 페이징 크기는 40입니다.")
int size,

@Parameter(in = ParameterIn.QUERY, description = "마지막 캡슐 아이디", required = true)
Long lastCapsuleId
);

@Operation(
summary = "그룹 소유 캡슐 목록 조회",
description = "그룹이 소유한 그룹원만 볼 수 있는 그룹 캡슐 목록을 조회한다.",
security = {@SecurityRequirement(name = "user_token")},
tags = {"group capsule"}
)
Expand All @@ -119,7 +142,7 @@ ResponseEntity<ApiSpec<GroupCapsuleSummaryResponse>> getGroupCapsuleSummaryByCap
content = @Content(schema = @Schema(implementation = ErrorResponse.class))
)
})
ResponseEntity<ApiSpec<GroupCapsuleSliceResponse>> getGroupCapsules(
ResponseEntity<ApiSpec<GroupSpecificCapsuleSliceResponse>> getGroupSpecificCapsules(
Long memberId,

@Parameter(in = ParameterIn.QUERY, description = "그룹 아이디", required = true)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package site.timecapsulearchive.core.domain.capsule.group_capsule.api;

import jakarta.validation.Valid;
import jakarta.validation.constraints.Max;
import java.time.ZonedDateTime;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Slice;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -15,18 +17,21 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import site.timecapsulearchive.core.domain.capsule.data.dto.CapsuleBasicInfoDto;
import site.timecapsulearchive.core.domain.capsule.generic_capsule.data.dto.CapsuleDetailDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.CombinedGroupCapsuleSummaryDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.GroupCapsuleDetailDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.GroupCapsuleDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.GroupCapsuleMemberDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.GroupCapsuleOpenStateDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.GroupCapsuleSliceRequestDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.dto.GroupSpecificCapsuleSliceRequestDto;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.reqeust.GroupCapsuleCreateRequest;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.reqeust.GroupCapsuleUpdateRequest;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.response.GroupCapsuleDetailResponse;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.response.GroupCapsuleOpenStateResponse;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.response.GroupCapsuleMembersResponse;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.response.GroupCapsuleOpenStateResponse;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.response.GroupCapsuleSliceResponse;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.response.GroupCapsuleSummaryResponse;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.response.GroupSpecificCapsuleSliceResponse;
import site.timecapsulearchive.core.domain.capsule.group_capsule.data.response.MyGroupCapsuleSliceResponse;
import site.timecapsulearchive.core.domain.capsule.group_capsule.facade.GroupCapsuleFacade;
import site.timecapsulearchive.core.domain.capsule.group_capsule.service.GroupCapsuleService;
Expand All @@ -35,6 +40,7 @@
import site.timecapsulearchive.core.global.geography.GeoTransformManager;
import site.timecapsulearchive.core.infra.s3.manager.S3PreSignedUrlManager;

@Validated
@RestController
@RequestMapping("/group-capsules")
@RequiredArgsConstructor
Expand Down Expand Up @@ -114,27 +120,53 @@ public ResponseEntity<ApiSpec<GroupCapsuleSummaryResponse>> getGroupCapsuleSumma
);
}

@GetMapping(produces = {"application/json"})
@Override
public ResponseEntity<ApiSpec<GroupCapsuleSliceResponse>> getGroupCapsules(
@AuthenticationPrincipal final Long memberId,
@RequestParam("size") final int size,
@RequestParam(value = "last_capsule_id", required = false) final Long lastCapsuleId
) {
Slice<GroupCapsuleDto> groupCapsuleSlice = groupCapsuleService.findGroupCapsuleSlice(
memberId, size, lastCapsuleId);

return ResponseEntity.ok(
ApiSpec.success(
SuccessCode.SUCCESS,
GroupCapsuleSliceResponse.createOf(
groupCapsuleSlice.getContent(),
groupCapsuleSlice.hasNext(),
s3PreSignedUrlManager::getS3PreSignedUrlForGet,
s3PreSignedUrlManager::getS3PreSignedUrlsForGet,
geoTransformManager::changePoint3857To4326
)
)
);
}

@GetMapping(
value = "/specific",
produces = {"application/json"}
)
@Override
public ResponseEntity<ApiSpec<GroupCapsuleSliceResponse>> getGroupCapsules(
public ResponseEntity<ApiSpec<GroupSpecificCapsuleSliceResponse>> getGroupSpecificCapsules(
@AuthenticationPrincipal final Long memberId,
@RequestParam("group_id") final Long groupId,
@RequestParam("size") final int size,
@RequestParam(value = "last_capsule_id", required = false) final Long lastCapsuleId
) {
final GroupCapsuleSliceRequestDto dto = GroupCapsuleSliceRequestDto.createOf(memberId,
final GroupSpecificCapsuleSliceRequestDto dto = GroupSpecificCapsuleSliceRequestDto.createOf(
memberId,
groupId,
size, lastCapsuleId);

final Slice<CapsuleBasicInfoDto> groupCapsuleSlice = groupCapsuleService.findGroupCapsuleSlice(
final Slice<CapsuleBasicInfoDto> groupCapsuleSlice = groupCapsuleService.findGroupSpecificCapsuleSlice(
dto);

return ResponseEntity.ok(
ApiSpec.success(
SuccessCode.SUCCESS,
GroupCapsuleSliceResponse.create(
GroupSpecificCapsuleSliceResponse.create(
groupCapsuleSlice.getContent(),
groupCapsuleSlice.hasNext(),
s3PreSignedUrlManager::getS3PreSignedUrlForGet
Expand Down
Loading

0 comments on commit 8c6c7f6

Please sign in to comment.