Skip to content

Commit

Permalink
[MERGE/#58] - 도메인 엔티티 작성 코드 리뷰 반영
Browse files Browse the repository at this point in the history
[FIX] #58 - 도메인 엔티티 작성 코드 리뷰 반영
  • Loading branch information
ckkim817 authored Jul 10, 2024
2 parents a3256f0 + 7f5450d commit 3b84a7d
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,37 +30,40 @@ public class Appointment {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "appointment_id")
private Long appointmentId;
@Column(name = "id")
private Long id;

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

@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "senior_id", referencedColumnName = "senior_id", nullable = false)
@JoinColumn(name = "senior_id", referencedColumnName = "id", nullable = false)
private Senior senior;

@Enumerated(EnumType.STRING)
@Column(name = "appointment_status", nullable = false)
private AppointmentStatus appointmentStatus;

@Column(name = "time_list", columnDefinition = "jsonb", nullable = false)
@Convert(converter = JsonConverter.class)
private Map<String, Object> timeList;

@Column(name = "topic", length = 255)
@Column(name = "topic")
private String topic;

@Column(name = "personal_topic", length = 255)
@Column(name = "personal_topic")
private String personalTopic;

@Column(name = "reject_reason", length = 255)
private String rejectReason;
@Enumerated(EnumType.STRING)
@Column(name = "appointment_status", nullable = false)
private AppointmentStatus appointmentStatus;

@Column(name = "google_meet_link", length = 255)
@Column(name = "google_meet_link")
private String googleMeetLink;

@Column(name = "reject_reason")
private String rejectReason;

@Column(name = "reject_detail")
private String rejectDetail;

@Builder(access = AccessLevel.PRIVATE)
private Appointment(
Member member,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 +25,38 @@ public class Member {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "member_id")
private Long memberId;
@Column(name = "id")
private Long id;

@Enumerated(EnumType.STRING)
@Column(name = "social_type", nullable = false)
private SocialType socialType;

@Column(name = "social_id", nullable = false, length = 255)
@Column(name = "social_id", nullable = false)
private String socialId;

@Column(name = "email", nullable = false, length = 255)
@Column(name = "email", nullable = false)
private String email;

@Column(name = "is_subscribed")
private Boolean isSubscribed;

@Column(name = "nickname", length = 20)
@Column(name = "nickname")
private String nickname;

@Column(name = "image", length = 255)
@Column(name = "image")
private String image;

@Column(name = "phone_number", length = 255)
@Column(name = "phone_number")
private String phoneNumber;

@Column(name = "univ_name", length = 255)
@Column(name = "univ_name")
private String univName;

@Column(name = "field", length = 255)
@Column(name = "field")
private String field;

@Column(name = "department", length = 255)
@Column(name = "department")
private String department;

@OneToOne(mappedBy = "member", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ public Long createMember(final MemberInfoResponse memberInfoResponse) {
memberInfoResponse.email()
);

return memberRepository.save(member).getMemberId();
return memberRepository.save(member).getId();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public Long getMemberIdBySocialId(
() -> new CustomException(ErrorType.NOT_FOUND_MEMBER_ERROR)
);

return member.getMemberId();
return member.getId();
}

public LoginSuccessResponse getTokenByMemberId(final Long id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,68 +25,79 @@ public class Senior {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "senior_id")
private Long seniorId;
@Column(name = "id")
private Long id;

@OneToOne(optional = false)
@JoinColumn(name = "member_id", referencedColumnName = "member_id", nullable = false)
@JoinColumn(name = "member_id", referencedColumnName = "id", nullable = false)
private Member member;

@Column(name = "business_card", nullable = false, length = 255)
@Column(name = "business_card", nullable = false)
private String businessCard;

@Column(name = "company", length = 255)
@Column(name = "company")
private String company;

@Column(name = "position", length = 255)
@Column(name = "position")
private String position;

@Column(name = "detail_position", nullable = false, length = 255)
@Column(name = "detail_position", nullable = false)
private String detailPosition;

@Column(name = "level", nullable = false)
private Integer level;
private int level;

@Column(name = "catchphrase", length = 255)
@Column(name = "catchphrase")
private String catchphrase;

@Column(name = "career", length = 255)
@Column(name = "career")
private String career;

@Column(name = "award", length = 255)
@Column(name = "award")
private String award;

@Column(name = "story", length = 255)
@Column(name = "story")
private String story;

@Column(name = "preffered_time_list", columnDefinition = "jsonb")
@Column(name = "is_day_of_week", nullable = false)
private Boolean isDayOfWeek;

@Column(name = "preferred_time_list", columnDefinition = "jsonb")
@Convert(converter = JsonConverter.class)
private Map<String, Object> prefferedTimeList;
private Map<String, Object> preferredTimeList;

@Builder(access = AccessLevel.PRIVATE)
private Senior(
Member member,
String businessCard,
String detailPosition,
Integer level
int level,
Boolean isDayOfWeek,
Map<String, Object> preferredTimeList
) {
this.member = member;
this.businessCard = businessCard;
this.detailPosition = detailPosition;
this.level = level;
this.isDayOfWeek = isDayOfWeek;
this.preferredTimeList = preferredTimeList;
}

public static Senior createSenior(
Member member,
String businessCard,
String detailPosition,
Integer level
int level,
Boolean isDayOfWeek,
Map<String, Object> preferredTimeList
) {
return Senior.builder()
.member(member)
.businessCard(businessCard)
.detailPosition(detailPosition)
.level(level)
.isDayOfWeek(isDayOfWeek)
.preferredTimeList(preferredTimeList)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ public class Department {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "dept_id")
private Long deptId;
@Column(name = "id")
private Long id;

@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "univ_id", referencedColumnName = "univ_id", nullable = false)
@JoinColumn(name = "univ_id", referencedColumnName = "id", nullable = false)
private University university;

@Column(name = "dept_name", nullable = false, length = 20)
@Column(name = "dept_name", nullable = false)
private String deptName;

@Column(name = "is_closed", nullable = false)
private Boolean isClosed;
private boolean isClosed;

@Builder(access = AccessLevel.PRIVATE)
private Department(
final University university,
final String deptName,
final Boolean isClosed
final boolean isClosed
) {
this.university = university;
this.deptName = deptName;
Expand All @@ -49,7 +49,7 @@ private Department(
public static Department createDepartment(
final University university,
final String deptName,
final Boolean isClosed
final boolean isClosed
) {
return Department.builder()
.university(university)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public class University {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "univ_id")
private Long univId;
@Column(name = "id")
private Long id;

@Column(name = "univ_name", nullable = false, length = 255)
@Column(name = "univ_name", nullable = false)
private String univName;

@OneToMany(mappedBy = "university", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.sopt.seonyakServer.global.exception.enums.ErrorType;
import org.sopt.seonyakServer.global.exception.model.CustomException;

@Converter
public class JsonConverter implements AttributeConverter<Map<String, Object>, String> {
Expand All @@ -18,7 +20,7 @@ public String convertToDatabaseColumn(Map<String, Object> attribute) {
try {
return objectMapper.writeValueAsString(attribute);
} catch (JsonProcessingException e) {
throw new RuntimeException("Error converting map to JSON string.", e);
throw new CustomException(ErrorType.MAP_TO_JSON_ERROR);
}
}

Expand All @@ -27,7 +29,7 @@ public Map<String, Object> convertToEntityAttribute(String dbData) {
try {
return objectMapper.readValue(dbData, HashMap.class);
} catch (IOException e) {
throw new RuntimeException("Error converting JSON string to map.", e);
throw new CustomException(ErrorType.JSON_TO_MAP_ERROR);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public enum ErrorType {
INVALID_CODE_HEADER_ERROR(HttpStatus.BAD_REQUEST, "40007", "code 헤더값의 형식이 잘못되었습니다."),
INVALID_SOCIAL_TYPE_ERROR(HttpStatus.BAD_REQUEST, "40008", "유효하지 않은 Social Type입니다."),
BEARER_LOST_ERROR(HttpStatus.BAD_REQUEST, "40009", "요청한 토큰이 Bearer 토큰이 아닙니다."),
MAP_TO_JSON_ERROR(HttpStatus.BAD_REQUEST, "40016", "Map을 JSON 문자열로 변환하는 중 오류가 발생했습니다."),
JSON_TO_MAP_ERROR(HttpStatus.BAD_REQUEST, "40017", "JSON 문자열을 Map으로 변환하는 중 오류가 발생했습니다."),

// S3 관련 오류
IMAGE_EXTENSION_ERROR(HttpStatus.BAD_REQUEST, "40051", "이미지 확장자는 jpg, png, webp만 가능합니다."),
Expand Down

0 comments on commit 3b84a7d

Please sign in to comment.