Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MERGE] develop을 main에 반영 #160

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@
import io.oeid.mogakgo.domain.user.domain.User;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(readOnly = true)
@RequiredArgsConstructor
public class CertService {

private final UserGeoService userGeoService;
private final UserCommonService userCommonService;

@Transactional
public Long certificate(Long tokenUserId, Long userId, int areaCode) {
User tokenUser = validateToken(tokenUserId);
validateCertificator(tokenUser, userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
import io.oeid.mogakgo.core.properties.KakaoProperties;
import io.oeid.mogakgo.domain.geo.domain.enums.Region;
import io.oeid.mogakgo.domain.geo.exception.GeoException;
import io.oeid.mogakgo.domain.geo.feign.KakaoFeignClient;
import io.oeid.mogakgo.domain.geo.feign.dto.AddressDocument;
import io.oeid.mogakgo.domain.geo.feign.dto.AddressInfoDto;
import io.oeid.mogakgo.domain.geo.application.feign.KakaoFeignClient;
import io.oeid.mogakgo.domain.geo.application.feign.dto.AddressDocument;
import io.oeid.mogakgo.domain.geo.application.feign.dto.AddressInfoDto;
import io.oeid.mogakgo.domain.user.application.UserCommonService;
import io.oeid.mogakgo.domain.user.domain.User;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(readOnly = true)
@RequiredArgsConstructor
public class GeoService {

Expand All @@ -39,6 +41,14 @@ public AddressDocument getAddressInfoAboutAreaCode(Double x, Double y) {
return response.getDocuments()[0];
}

private String generateKey(KakaoProperties kakaoProperties) {
return kakaoProperties.getPrefix() + SEPERATOR + kakaoProperties.getRestApiKey();
}

private int extractAreaCode(AddressDocument document) {
return Integer.parseInt(document.getCode().substring(0, 5));
}

private int validateCoordinatesCoverage(Double x, Double y) {
int areaCode = getAreaCodeAboutCoordinates(x, y);
validateCodeCoverage(areaCode);
Expand All @@ -51,14 +61,6 @@ private void validateCodeCoverage(int areaCode) {
}
}

private String generateKey(KakaoProperties kakaoProperties) {
return kakaoProperties.getPrefix() + SEPERATOR + kakaoProperties.getRestApiKey();
}

private int extractAreaCode(AddressDocument document) {
return Integer.parseInt(document.getCode().substring(0, 5));
}

private User validateToken(Long userId) {
return userCommonService.getUserById(userId);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.oeid.mogakgo.domain.geo.feign;
package io.oeid.mogakgo.domain.geo.application.feign;

import io.oeid.mogakgo.domain.geo.feign.dto.AddressInfoDto;
import io.oeid.mogakgo.domain.geo.application.feign.dto.AddressInfoDto;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.oeid.mogakgo.domain.geo.feign.dto;
package io.oeid.mogakgo.domain.geo.application.feign.dto;

import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.oeid.mogakgo.domain.geo.feign.dto;
package io.oeid.mogakgo.domain.geo.application.feign.dto;

import lombok.Getter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public CursorPaginationResult<UserPublicApiResponse> getRandomOrderedProfileCard
return profiles;
}

@Transactional
public void increaseTotalLikeAmount(Long userId) {
var profileCard = getProfileCard(userId);
profileCard.addLike();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public CursorPaginationResult<UserPublicApiResponse> findByConditionWithPaginati
.where(
cursorIdCondition(pageable.getCursorId()),
userIdEq(userId),
regionEq(region)
regionEq(region),
deletedProfileCardEq()
)
.limit(pageable.getPageSize() + 1)
.fetch();
Expand Down Expand Up @@ -70,4 +71,8 @@ private BooleanExpression userIdEq(Long userId) {
private BooleanExpression cursorIdCondition(Long cursorId) {
return cursorId != null ? profileCard.id.gt(cursorId) : null;
}

private BooleanExpression deletedProfileCardEq() {
return profileCard.user.deletedAt.isNull();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
public enum ErrorCode401 implements ErrorCode{

AUTH_MISSING_CREDENTIALS("E010201", "사용자의 인증 정보를 찾을 수 없습니다."),
USER_ACCOUNT_DISABLED("E020201", "탈퇴한 사용자입니다."),
AUTH_TOKEN_EXPIRED("E010202", "토큰이 만료되었습니다."),
;

Expand Down
Loading