Skip to content

Commit

Permalink
๐Ÿ› ๋กœ๊ทธ์ธ ๋กœ์ง ์ผ๋ถ€์ˆ˜์ •, ์ผ๋ถ€ recordํƒ€์ž… classํƒ€์ž…์œผ๋กœ ๋ณ€๊ฒฝ
Browse files Browse the repository at this point in the history
* ๋กœ๊ทธ์ธ ์„ฑ๊ณต์‹œ RTR๋กœ ํ† ํฐ์„ ๊ด€๋ฆฌํ•˜๋ฉฐ ์ด๋ฏธ ์กด์žฌํ•˜๋Š” ๋ฆฌํ”„๋ ˆ์‹œ ํ† ํฐ์ด ์žˆ์„๋•Œ๋„ ์ƒˆ๋กญ๊ฒŒ ๋ฆฌํ”„๋ ˆ์‹œ ํ† ํฐ์„ ๋ฐœ๊ธ‰ํ•ด์ฃผ๊ธฐ์œ„ํ•ด ๋ณ€๊ฒฝ

* ๋นˆ photo๋ฅผ ๋ณด๋ƒˆ์„๋–„ ์„œ๋น„์Šค layer์—์„œ ๊ฒ€์ฆ๋กœ์ง ์ถ”๊ฐ€
  • Loading branch information
youngreal committed Sep 5, 2024
1 parent 8519081 commit 5c364fd
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 12 deletions.
14 changes: 11 additions & 3 deletions src/main/java/com/dnd/dndtravel/auth/service/JwtTokenService.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,23 @@ public class JwtTokenService {
public TokenResponse generateTokens(Long memberId) {
RefreshToken refreshToken = refreshTokenRepository.findByMemberId(memberId);

// ๋ฆฌํ”„๋ ˆ์‹œ ํ† ํฐ์ด ์—†๋Š”๊ฒฝ์šฐ
if (refreshToken == null) {
String newRefreshToken = jwtProvider.refreshToken();
refreshTokenRepository.save(RefreshToken.of(memberId, newRefreshToken)); // refreshToken์€ DB์— ์ €์žฅ
return new TokenResponse(jwtProvider.accessToken(memberId), newRefreshToken);
} else if (refreshToken.isExpire()) {
}

// ๋ฆฌํ”„๋ ˆ์‹œ ํ† ํฐ์ด ๋งŒ๋ฃŒ๋์œผ๋ฉด ์žฌ๋ฐœ๊ธ‰ ๋ฐ›์œผ๋ผ๊ณ  ๋ฉ˜ํŠธ์คŒ
if (refreshToken.isExpire()) {
return null;
}

return new TokenResponse(jwtProvider.accessToken(memberId), null);

// ๋ฆฌํ”„๋ ˆ์‹œ ํ† ํฐ์ด DB์— ์กด์žฌํ•˜๊ณ  ์œ ํšจํ•œ๊ฒฝ์šฐ
refreshTokenRepository.delete(refreshToken);
String newRefreshToken = jwtProvider.refreshToken();
refreshTokenRepository.save(RefreshToken.of(refreshToken.getMemberId(), newRefreshToken));
return new TokenResponse(jwtProvider.accessToken(memberId), newRefreshToken);
}

@Transactional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,45 @@
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
public record RecordRequest(
import lombok.Getter;
import lombok.Setter;

/**
* recordํƒ€์ž…์€ multipart๋กœ ๋ฐ›์„๋•Œ Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of
* `*.request.RecordRequest` (although at least one Creator exists):
* no String-argument constructor/factory method to deserialize from String value ๋ฌธ์ œ๊ฐ€ ์žˆ์—ˆ์Œ
*
*/
@Getter
@Setter
public class RecordRequest {
@Schema(description = "์ง€์—ญ ์ด๋ฆ„", requiredMode = REQUIRED)
@RegionEnum(enumClass = RegionCondition.class)
String region,
String region;

@Schema(description = "๋ช…์†Œ๋ช…", requiredMode = REQUIRED)
@NotBlank(message = "๋ช…์†Œ๋ช…์€ ํ•„์ˆ˜ ์ž…๋‹ˆ๋‹ค.")
@Size(max = 10, message = "๋ช…์†Œ ์ด๋ฆ„์€ 10์ž ์ด๋‚ด์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค.")
String attractionName,
String attractionName;

@Schema(description = "๋ฉ”๋ชจ", requiredMode = NOT_REQUIRED)
@Size(max = 25, message = "๋ฉ”๋ชจ๋Š” 25์ž ์ด๋‚ด์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค.")
String memo,
String memo;

@Schema(description = "๋ฐฉ๋ฌธ๋‚ ์งœ, ISO Date(yyyy-MM-dd) ํ˜•์‹์œผ๋กœ ์ž…๋ ฅ", requiredMode = NOT_REQUIRED)
@NotNull(message = "๋‚ ์งœ๋Š” ํ•„์ˆ˜ ์ž…๋ ฅ ์‚ฌํ•ญ์ž…๋‹ˆ๋‹ค.")
LocalDate localDate
) {
LocalDate localDate;

public RecordRequest() {
}

public RecordRequest(String region, String attractionName, String memo, LocalDate localDate) {
this.region = region;
this.attractionName = attractionName;
this.memo = memo;
this.localDate = localDate;
}

public RecordDto toDto(List<MultipartFile> photos) {
return RecordDto.builder()
.region(this.region)
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/com/dnd/dndtravel/map/service/MapService.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,11 @@ private void updateRegionVisitCount(Member member, Region region) {
}

private void savePhotos(List<MultipartFile> photos, MemberAttraction memberAttractionEntity) {
for (MultipartFile photo : photos) {
String imageUrl = photoService.upload(photo);
photoRepository.save(Photo.of(memberAttractionEntity, imageUrl));
if (photos != null && !photos.isEmpty()) {
for (MultipartFile photo : photos) {
String imageUrl = photoService.upload(photo);
photoRepository.save(Photo.of(memberAttractionEntity, imageUrl));
}
}
}
}

0 comments on commit 5c364fd

Please sign in to comment.