Skip to content

Commit

Permalink
Merge pull request #425 from tukcomCD2024/develop_back_core
Browse files Browse the repository at this point in the history
feat : Backend core 모듈 develop_backend 합병
  • Loading branch information
GaBaljaintheroom authored May 14, 2024
2 parents e0e5ff6 + 22e6de2 commit 2c2d90b
Show file tree
Hide file tree
Showing 118 changed files with 3,810 additions and 774 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import site.timecapsulearchive.core.domain.auth.data.response.VerificationMessageSendResponse;
import site.timecapsulearchive.core.domain.auth.service.MessageVerificationService;
import site.timecapsulearchive.core.domain.auth.service.TokenManager;
import site.timecapsulearchive.core.domain.member.data.mapper.MemberMapper;
import site.timecapsulearchive.core.domain.member.service.MemberService;
import site.timecapsulearchive.core.global.common.response.ApiSpec;
import site.timecapsulearchive.core.global.common.response.SuccessCode;
Expand All @@ -40,7 +39,6 @@ public class AuthApiController implements AuthApi {
private final TokenManager tokenService;
private final MessageVerificationService messageVerificationService;
private final MemberService memberService;
private final MemberMapper memberMapper;


@GetMapping(value = "/login/url/kakao", produces = {"application/json"})
Expand Down Expand Up @@ -126,7 +124,7 @@ public ResponseEntity<ApiSpec<TokenResponse>> reIssueAccessToken(
public ResponseEntity<ApiSpec<TemporaryTokenResponse>> signUpWithSocialProvider(
@Valid @RequestBody final SignUpRequest request
) {
final Long id = memberService.createMember(memberMapper.signUpRequestToDto(request));
final Long id = memberService.createMember(request.toDto());

return ResponseEntity.ok(
ApiSpec.success(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import site.timecapsulearchive.core.domain.member.data.dto.SignUpRequestDto;
import site.timecapsulearchive.core.domain.member.entity.SocialType;

@Schema(description = "소셜 프로바이더의 인증 아이디로 회원가입 요청")
Expand All @@ -27,4 +28,13 @@ public record SignUpRequest(
SocialType socialType
) {

public SignUpRequestDto toDto() {
return new SignUpRequestDto(
authId,
email,
profileUrl,
socialType
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
import site.timecapsulearchive.core.domain.auth.exception.CertificationNumberNotMatchException;
import site.timecapsulearchive.core.domain.auth.repository.MessageAuthenticationCacheRepository;
import site.timecapsulearchive.core.domain.member.entity.Member;
import site.timecapsulearchive.core.domain.member.entity.MemberTemporary;
import site.timecapsulearchive.core.domain.member.exception.MemberNotFoundException;
import site.timecapsulearchive.core.domain.member.repository.MemberRepository;
import site.timecapsulearchive.core.domain.member.repository.MemberTemporaryRepository;
import site.timecapsulearchive.core.global.security.encryption.AESEncryptionManager;
import site.timecapsulearchive.core.global.security.encryption.HashEncryptionManager;
import site.timecapsulearchive.core.infra.sms.data.response.SmsApiResponse;
Expand All @@ -30,6 +32,7 @@ public class MessageVerificationService {
private final MessageAuthenticationCacheRepository messageAuthenticationCacheRepository;
private final SmsApiManager smsApiManager;
private final MemberRepository memberRepository;
private final MemberTemporaryRepository memberTemporaryRepository;
private final TokenManager tokenManager;

private final AESEncryptionManager aesEncryptionManager;
Expand Down Expand Up @@ -90,22 +93,27 @@ public TokenResponse validVerificationMessage(
throw new CertificationNumberNotMatchException();
}

updateMemberData(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 updateMemberData(final Long memberId, final byte[] plain) {
final Member findMember = memberRepository.findMemberById(memberId)
private Long updateToVerifiedMember(final Long memberId, final byte[] plain) {
final MemberTemporary memberTemporary = memberTemporaryRepository.findById(memberId)
.orElseThrow(MemberNotFoundException::new);

findMember.updatePhoneHash(hashEncryptionManager.encrypt(plain));
findMember.updatePhoneNumber(aesEncryptionManager.encryptWithPrefixIV(plain));
findMember.updateVerification();
memberTemporaryRepository.delete(memberTemporary);

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 @@ -9,7 +9,9 @@
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import java.util.Objects;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import site.timecapsulearchive.core.domain.member.entity.Member;
Expand All @@ -26,11 +28,21 @@ public class GroupCapsuleOpen extends BaseEntity {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "is_opened", nullable = false)
private Boolean isOpened;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "capsule_id", nullable = false)
private Capsule capsule;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id", nullable = false)
private Member member;

@Builder
private GroupCapsuleOpen(Boolean isOpened, Capsule capsule, Member member) {
this.isOpened = Objects.requireNonNull(isOpened);
this.capsule = Objects.requireNonNull(capsule);
this.member = Objects.requireNonNull(member);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.hibernate.validator.constraints.Range;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import site.timecapsulearchive.core.domain.capsule.entity.CapsuleType;
import site.timecapsulearchive.core.domain.capsule.generic_capsule.data.request.CapsuleCreateRequest;
import site.timecapsulearchive.core.domain.capsule.generic_capsule.data.response.CapsuleOpenedResponse;
import site.timecapsulearchive.core.domain.capsule.generic_capsule.data.response.ImagesPageResponse;
import site.timecapsulearchive.core.domain.capsule.generic_capsule.data.response.NearbyARCapsuleResponse;
import site.timecapsulearchive.core.domain.capsule.generic_capsule.data.response.NearbyCapsuleResponse;
import site.timecapsulearchive.core.global.common.response.ApiSpec;
import site.timecapsulearchive.core.global.error.ErrorResponse;

@Validated
public interface CapsuleApi {

@Operation(
Expand Down Expand Up @@ -56,14 +58,16 @@ ResponseEntity<ImagesPageResponse> getImages(
description = "잘못된 요청 파라미터에 의해 발생"
)
})
ResponseEntity<ApiSpec<NearbyARCapsuleResponse>> getNearbyARCapsules(
ResponseEntity<ApiSpec<NearbyARCapsuleResponse>> getARNearbyMyCapsules(
Long memberId,

@Parameter(in = ParameterIn.QUERY, description = "위도(wsg84)", required = true)
double longitude,
@Range(min = -90, max = 90, message = "위도는 -90과 90 사이여야 합니다.")
double latitude,

@Parameter(in = ParameterIn.QUERY, description = "경도(wsg84)", required = true)
double latitude,
@Range(min = -180, max = 180, message = "경도는 -180과 180 사이여야 합니다.")
double longitude,

@Parameter(in = ParameterIn.QUERY, description = "조회 거리(km)", required = true)
double distance,
Expand All @@ -88,14 +92,16 @@ ResponseEntity<ApiSpec<NearbyARCapsuleResponse>> getNearbyARCapsules(
description = "잘못된 요청 파라미터에 의해 발생"
)
})
ResponseEntity<ApiSpec<NearbyCapsuleResponse>> getNearbyCapsules(
ResponseEntity<ApiSpec<NearbyCapsuleResponse>> getMapNearbyMyCapsules(
Long memberId,

@Parameter(in = ParameterIn.QUERY, description = "위도(wsg84)", required = true)
double longitude,
@Range(min = -90, max = 90, message = "위도는 -90과 90 사이여야 합니다.")
double latitude,

@Parameter(in = ParameterIn.QUERY, description = "경도(wsg84)", required = true)
double latitude,
@Range(min = -180, max = 180, message = "경도는 -180과 180 사이여야 합니다.")
double longitude,

@Parameter(in = ParameterIn.QUERY, description = "조회 거리(km)", required = true)
double distance,
Expand All @@ -105,8 +111,8 @@ ResponseEntity<ApiSpec<NearbyCapsuleResponse>> getNearbyCapsules(
);

@Operation(
summary = "캡슐 열람 상태로 변경",
description = "캡슐을 열람 상태를 변경해준다.",
summary = "현재 사용자 위치 기준으로 사용자의 친구들의 지도용 캡슐 목록 조회",
description = "지도에서 캡슐을 보기 위해 현재 사용자 위치를 바탕으로 반경 distance km만큼 친구들의 캡슐을 조회한다.",
security = {@SecurityRequirement(name = "user_token")},
tags = {"capsule"}
)
Expand All @@ -116,70 +122,78 @@ ResponseEntity<ApiSpec<NearbyCapsuleResponse>> getNearbyCapsules(
description = "처리 완료"
),
@ApiResponse(
responseCode = "404",
description = "해당 캡슐을 찾을 수 없을 경우 발생하는 예외",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))
responseCode = "400",
description = "잘못된 요청 파라미터에 의해 발생"
)
})
ResponseEntity<ApiSpec<CapsuleOpenedResponse>> updateCapsuleOpened(
ResponseEntity<ApiSpec<NearbyCapsuleResponse>> getMapNearbyFriendsCapsules(
Long memberId,

@Parameter(in = ParameterIn.PATH, description = "캡슐 아이디", required = true)
Long capsuleId
@Parameter(in = ParameterIn.QUERY, description = "위도(wsg84)", required = true)
@Range(min = -90, max = 90, message = "위도는 -90과 90 사이여야 합니다.")
double latitude,

@Parameter(in = ParameterIn.QUERY, description = "경도(wsg84)", required = true)
@Range(min = -180, max = 180, message = "경도는 -180과 180 사이여야 합니다.")
double longitude,

@Parameter(in = ParameterIn.QUERY, description = "조회 거리(km)", required = true)
double distance
);

@Operation(
summary = "비밀 캡슐 생성",
description = "사용자만 볼 수 있는 비밀 캡슐을 생성한다.",
summary = "현재 사용자 위치 기준으로 사용자의 친구들의 AR용 캡슐 목록 조회",
description = "AR 카메라로 캡슐을 보기 위해 현재 사용자 위치를 바탕으로 반경 distance km만큼 친구들의 캡슐을 조회한다.",
security = {@SecurityRequirement(name = "user_token")},
tags = {"secret capsule"}
tags = {"capsule"}
)
@ApiResponses(value = {
@ApiResponse(
responseCode = "202",
description = "처리 시작"
responseCode = "200",
description = "처리 완료"
),
@ApiResponse(
responseCode = "400",
description = "좌표변환을 할 수 없을 때 발생하는 예외, 입력좌표 확인 요망",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))
),
@ApiResponse(
responseCode = "404",
description = "캡슐 스킨을 찾을 수 없을 경우 발생하는 예외",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))
description = "잘못된 요청 파라미터에 의해 발생"
)
})
ResponseEntity<ApiSpec<String>> createSecretCapsule(
ResponseEntity<ApiSpec<NearbyARCapsuleResponse>> getARNearbyFriendsCapsules(
Long memberId,
CapsuleCreateRequest request

@Parameter(in = ParameterIn.QUERY, description = "위도(wsg84)", required = true)
@Range(min = -90, max = 90, message = "위도는 -90과 90 사이여야 합니다.")
double latitude,

@Parameter(in = ParameterIn.QUERY, description = "경도(wsg84)", required = true)
@Range(min = -180, max = 180, message = "경도는 -180과 180 사이여야 합니다.")
double longitude,

@Parameter(in = ParameterIn.QUERY, description = "조회 거리(km)", required = true)
double distance
);

@Operation(
summary = "공개 캡슐 생성",
description = "사용자의 친구들만 볼 수 있는 공개 캡슐을 생성한다.",
summary = "캡슐 열람 상태로 변경",
description = "캡슐을 열람 상태를 변경해준다.",
security = {@SecurityRequirement(name = "user_token")},
tags = {"public capsule"}
tags = {"capsule"}
)
@ApiResponses(value = {
@ApiResponse(
responseCode = "202",
description = "처리 시작"
),
@ApiResponse(
responseCode = "400",
description = "좌표변환을 할 수 없을 때 발생하는 예외, 입력좌표 확인 요망",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))
responseCode = "200",
description = "처리 완료"
),
@ApiResponse(
responseCode = "404",
description = "캡슐 스킨을 찾을 수 없을 경우 발생하는 예외",
description = "해당 캡슐을 찾을 수 없을 경우 발생하는 예외",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))
)
})
ResponseEntity<ApiSpec<String>> createPublicCapsule(
ResponseEntity<ApiSpec<CapsuleOpenedResponse>> updateCapsuleOpened(
Long memberId,
CapsuleCreateRequest request

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

Loading

0 comments on commit 2c2d90b

Please sign in to comment.