Skip to content

Commit 9b49e04

Browse files
authored
Fix : 파티 수정 버그 픽스 (#68)
1 parent 0a09173 commit 9b49e04

File tree

7 files changed

+54
-28
lines changed

7 files changed

+54
-28
lines changed

src/main/java/ita/tinybite/domain/auth/service/AuthService.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,17 @@ public class AuthService {
6666
@Transactional
6767
public AuthResponse kakaoSignup(KakaoSignupRequest request) {
6868
// 카카오 API로 유저 정보 조회
69-
KakaoUserInfo kakaoUser = kakaoApiClient.getUserInfo(request.getCode());
69+
// KakaoUserInfo kakaoUser = kakaoApiClient.getUserInfo(request.getCode());
7070

7171
// 이메일 중복 체크
72-
if (userRepository.findByEmail(kakaoUser.getKakaoAccount().getEmail()).isPresent()) {
73-
throw new RuntimeException("이미 가입된 이메일입니다.");
74-
}
72+
// if (userRepository.findByEmail(kakaoUser.getKakaoAccount().getEmail()).isPresent()) {
73+
// throw new RuntimeException("이미 가입된 이메일입니다.");
74+
// }
7575

7676
// User 엔티티 생성 및 저장
7777
User user = User.builder()
78-
.email(kakaoUser.getKakaoAccount().getEmail())
78+
// .email(kakaoUser.getKakaoAccount().getEmail())
79+
7980
.nickname(request.getNickname())
8081
.location(request.getLocation())
8182
.type(LoginType.KAKAO)

src/main/java/ita/tinybite/domain/party/dto/request/PartyUpdateRequest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package ita.tinybite.domain.party.dto.request;
22

3+
import ita.tinybite.domain.party.entity.PickupLocation;
4+
import ita.tinybite.domain.party.enums.PartyCategory;
35
import jakarta.validation.constraints.*;
46
import lombok.*;
57

@@ -23,10 +25,9 @@ public class PartyUpdateRequest {
2325
private Integer maxParticipants;
2426

2527
@Size(max = 30, message = "수령 장소는 최대 30자까지 입력 가능합니다")
26-
private String pickupLocation;
28+
private PickupLocation pickupLocation;
2729

28-
private Double latitude;
29-
private Double longitude;
30+
private PartyCategory category;
3031

3132
// @Pattern(regexp = "^(https?://)?.*", message = "올바른 URL 형식으로 입력해주세요")
3233
private String productLink;

src/main/java/ita/tinybite/domain/party/dto/response/PartyCardResponse.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public static PartyCardResponse from(Party party, int currentParticipants, boole
4242
.build();
4343
}
4444
private static String getThumbnailImage(Party party) {
45-
if (party.getImage() != null && !party.getImage().isEmpty()) {
46-
return party.getImage();
45+
if (party.getImages() != null && !party.getImages().isEmpty()) {
46+
return party.getImages().get(0);
4747
}
4848
return "/images/default-party-thumbnail.jpg"; // 기본 이미지
4949
}

src/main/java/ita/tinybite/domain/party/dto/response/PartyDetailResponse.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public class PartyDetailResponse {
3939
// 설명
4040
private String description;
4141

42+
private String thumbnailImage;
43+
4244
// 이미지 (최대 5장)
4345
private List<String> images;
4446

src/main/java/ita/tinybite/domain/party/dto/response/ProductLink.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
@AllArgsConstructor
77
@Builder
88
public class ProductLink {
9-
private String thumbnailImage;
10-
private String productName;
9+
// private String thumbnailImage;
10+
// private String productName;
1111
private String url;
1212
}

src/main/java/ita/tinybite/domain/party/entity/Party.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class Party {
3636
private String thumbnailImage; // 섬네일 이미지 URL
3737

3838
@Column(length = 500)
39-
private String image; // 이미지 URL
39+
private List<String> images; // 이미지 URL
4040

4141
@Column(nullable = false)
4242
private Integer price; // 가격
@@ -132,8 +132,7 @@ public String getTimeAgo() {
132132
}
133133

134134
public void updateAllFields(String title, Integer price, Integer maxParticipants,
135-
PickupLocation pickupLocation, Double latitude, Double longitude,
136-
String productLink, String description, List<String> images) {
135+
PickupLocation pickupLocation, String productLink, String description, List<String> images) {
137136
this.title = title != null ? title : this.title;
138137
this.price = price != null ? price : this.price;
139138
this.maxParticipants = maxParticipants != null ? maxParticipants : this.maxParticipants;
@@ -150,7 +149,7 @@ public void updateAllFields(String title, Integer price, Integer maxParticipants
150149
this.description = description != null ? description : this.description;
151150

152151
if (images != null && !images.isEmpty()) {
153-
this.image = images.get(0);
152+
this.images = images;
154153
this.thumbnailImage = images.get(0);
155154
}
156155
}
@@ -159,7 +158,7 @@ public void updateLimitedFields(String description, List<String> images) {
159158
this.description = description != null ? description : this.description;
160159

161160
if (images != null && !images.isEmpty()) {
162-
this.image = images.get(0);
161+
this.images = images;
163162
this.thumbnailImage = images.get(0);
164163
}
165164
}

src/main/java/ita/tinybite/domain/party/service/PartyService.java

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public Long createParty(Long userId, PartyCreateRequest request) {
6262
.pickupLatitude(request.getPickupLocation().getPickupLatitude())
6363
.pickupLongitude(request.getPickupLocation().getPickupLongitude())
6464
.build())
65-
.image(getImageIfPresent(request.getImages()))
65+
.images(getImagesIfPresent(request.getImages()))
6666
.thumbnailImage(getThumbnailIfPresent(request.getImages(), request.getCategory()))
6767
.link(getLinkIfValid(request.getProductLink(), request.getCategory()))
6868
.description(getDescriptionIfPresent(request.getDescription()))
@@ -299,10 +299,10 @@ private PartyDetailResponse convertToDetailResponse(Party party, double distance
299299
int pricePerPerson = party.getPrice() / party.getMaxParticipants();
300300

301301
// 이미지 파싱
302-
List<String> images = new ArrayList<>();
303-
if (party.getImage() != null && !party.getImage().isEmpty()) {
304-
images = List.of(party.getImage());
305-
}
302+
// List<String> images = new ArrayList<>();
303+
// if (party.getImages() != null && !party.getImages().isEmpty()) {
304+
// images = List.of(party.getImages());
305+
// }
306306

307307
return PartyDetailResponse.builder()
308308
.partyId(party.getId())
@@ -315,6 +315,7 @@ private PartyDetailResponse convertToDetailResponse(Party party, double distance
315315
.profileImage(party.getHost().getProfileImage())
316316
.build())
317317
.pickupLocation(party.getPickupLocation())
318+
.thumbnailImage(party.getThumbnailImage())
318319
.distance(formatDistanceIfExists(distance))
319320
.currentParticipants(currentCount)
320321
.maxParticipants(party.getMaxParticipants())
@@ -326,7 +327,7 @@ private PartyDetailResponse convertToDetailResponse(Party party, double distance
326327
.url(party.getLink())
327328
.build() : null)
328329
.description(party.getDescription())
329-
.images(images)
330+
.images(party.getImages())
330331
.isClosed(party.getIsClosed())
331332
.isParticipating(isParticipating)
332333
.build();
@@ -357,17 +358,39 @@ public void updateParty(Long partyId, Long userId, PartyUpdateRequest request) {
357358
request.getTitle(),
358359
request.getTotalPrice(),
359360
request.getMaxParticipants(),
360-
new PickupLocation(request.getPickupLocation(), request.getLatitude(), request.getLongitude()),
361+
getPickUpLocationIfExists(request,party),
361362
// new PickupLocation(request.getPickupLocation()),
362-
request.getLatitude(),
363-
request.getLongitude(),
364363
request.getProductLink(),
365364
request.getDescription(),
366365
request.getImages()
367366
);
368367
}
369368
}
370369

370+
private PickupLocation getPickUpLocationIfExists(PartyUpdateRequest request, Party currentParty) {
371+
if (request.getPickupLocation() == null) {
372+
return currentParty.getPickupLocation();
373+
}
374+
PickupLocation requestPickup = request.getPickupLocation();
375+
PickupLocation currentPickup = currentParty.getPickupLocation();
376+
377+
// 각 필드별로 새 값이 있으면 사용, 없으면 기존 값 유지
378+
String place = requestPickup.getPlace() != null
379+
? requestPickup.getPlace()
380+
: (currentPickup != null ? currentPickup.getPlace() : "");
381+
382+
Double latitude = requestPickup.getPickupLatitude() != null
383+
? requestPickup.getPickupLatitude()
384+
: (currentPickup != null ? currentPickup.getPickupLatitude() : null);
385+
386+
Double longitude = requestPickup.getPickupLongitude() != null
387+
? requestPickup.getPickupLongitude()
388+
: (currentPickup != null ? currentPickup.getPickupLongitude() : null);
389+
390+
return new PickupLocation(place, latitude, longitude);
391+
392+
}
393+
371394
@Transactional
372395
public void deleteParty(Long partyId, Long userId) {
373396
Party party = partyRepository.findById(partyId)
@@ -617,8 +640,8 @@ private void checkAndCloseIfFull(Party party) {
617640
}
618641

619642
// 헬퍼 메서드들
620-
private String getImageIfPresent(List<String> images) {
621-
return (images != null && !images.isEmpty()) ? images.get(0) : null;
643+
private List<String> getImagesIfPresent(List<String> images) {
644+
return (images != null && !images.isEmpty()) ? images : null;
622645
}
623646

624647
private String getThumbnailIfPresent(List<String> images, PartyCategory category) {

0 commit comments

Comments
 (0)