Skip to content

Commit

Permalink
[PC-000] fix: 프로필 연락처 Map 키 Enum 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
Lujaec committed Jan 30, 2025
1 parent 749e8b9 commit 2990761
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.yapp.core.auth.AuthenticationService;
import org.yapp.core.domain.match.MatchInfo;
import org.yapp.core.domain.match.enums.MatchStatus;
import org.yapp.core.domain.profile.ContactType;
import org.yapp.core.domain.profile.Profile;
import org.yapp.core.domain.profile.ProfileValuePick;
import org.yapp.core.domain.profile.ProfileValueTalk;
Expand Down Expand Up @@ -252,7 +253,7 @@ public void acceptMatch() {
}

@Transactional(readOnly = true)
public Map<String, String> getContacts() {
public Map<ContactType, String> getContacts() {
Long userId = authenticationService.getUserId();
MatchInfo matchInfo = getMatchInfo(userId);
if (!matchInfo.getUser1Accepted() || !matchInfo.getUser2Accepted()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.yapp.core.domain.profile.ContactType;
import org.yapp.domain.block.application.DirectBlockService;
import org.yapp.domain.match.application.MatchService;
import org.yapp.domain.match.presentation.dto.response.ContactResponse;
Expand Down Expand Up @@ -90,7 +91,7 @@ public ResponseEntity<CommonResponse<Void>> acceptMatch() {
@GetMapping("/contacts")
@Operation(summary = "매칭 상대 연락처 조회", description = "매칭 상대의 연락처를 조회합니다", tags = {"매칭"})
public ResponseEntity<CommonResponse<ContactResponse>> getContacts() {
Map<String, String> contacts = matchService.getContacts();
Map<ContactType, String> contacts = matchService.getContacts();
ContactResponse contactResponse = new ContactResponse(contacts);
return ResponseEntity.status(HttpStatus.OK)
.body(CommonResponse.createSuccess(contactResponse));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.yapp.core.domain.profile.ContactType;

@AllArgsConstructor
@NoArgsConstructor
@Getter
public class ContactResponse {

private Map<String, String> contacts;
private Map<ContactType, String> contacts;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import jakarta.validation.constraints.Pattern;
import java.time.LocalDate;
import java.util.Map;
import org.yapp.core.domain.profile.ContactType;
import org.yapp.core.domain.profile.ProfileBasic;

public record ProfileBasicUpdateRequest(@NotBlank(message = "닉네임은 비어있을 수 없습니다.") String nickname,
Expand All @@ -32,7 +33,7 @@ public record ProfileBasicUpdateRequest(@NotBlank(message = "닉네임은 비어
@Pattern(regexp = "^https?://.*", message = "이미지 URL은 유효한 형식이어야 합니다.")
String imageUrl,

Map<String, String> contacts) {
Map<ContactType, String> contacts) {

public ProfileBasic toProfileBasic() {
return ProfileBasic.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
import org.yapp.core.domain.profile.ContactType;

public record ProfileCreateRequest(

Expand Down Expand Up @@ -40,7 +41,7 @@ public record ProfileCreateRequest(
@Pattern(regexp = "^(활동|은둔)$", message = "SNS 활동 수준은 '활동', '은둔' 중 하나여야 합니다.")
String snsActivityLevel,

Map<String, String> contacts,
Map<ContactType, String> contacts,

@Pattern(regexp = "\\d{10,11}", message = "유효한 핸드폰 번호를 입력해야 합니다.")
String phoneNumber,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.yapp.domain.profile.presentation.response;

import java.util.Map;
import org.yapp.core.domain.profile.ContactType;
import org.yapp.core.domain.profile.Profile;
import org.yapp.core.domain.profile.ProfileBasic;
import org.yapp.domain.profile.application.util.DateUtils;
Expand All @@ -11,7 +12,7 @@ public record ProfileBasicResponse(String nickname, String description, int age,
String location,
String smokingStatus, Integer weight, String snsActivityLevel,
String imageUrl,
Map<String, String> contacts) {
Map<ContactType, String> contacts) {

public static ProfileBasicResponse from(Profile profile) {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.yapp.core.domain.profile;

public enum ContactType {
KAKAO_TALK_ID,
OPEN_CHAT_URL,
INSTAGRAM_ID,
PHONE_NUMBER
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,12 @@ public class Profile extends BaseEntity {
@Embedded
private ProfileBasic profileBasic;

@Embedded
private ProfileBio profileBio;

@OneToMany(mappedBy = "profile", cascade = CascadeType.ALL, orphanRemoval = true)
private List<ProfileValueTalk> profileValueTalks;

@OneToMany(mappedBy = "profile", cascade = CascadeType.ALL, orphanRemoval = true)
private List<ProfileValuePick> profileValuePicks;

@Deprecated
public void updateBio(ProfileBio profileBio) {
this.profileBio = profileBio;
}

public void updateBasic(ProfileBasic profileBasic) {
this.profileBasic = profileBasic;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class ProfileBasic {

@Type(JsonType.class)
@Column(columnDefinition = "json")
private Map<String, String> contacts;
private Map<ContactType, String> contacts;

@Column(name = "image_url")
private String imageUrl;
Expand Down

0 comments on commit 2990761

Please sign in to comment.