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

[Feature] 이동봉사자, 이동봉사 중개 Entity 분리 #15

Merged
merged 3 commits into from
Oct 27, 2023
Merged
Changes from 1 commit
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
Next Next commit
feat: 이동봉사자, 이동봉사 중개 Entity 분리 (#13)
  • Loading branch information
kyeong-hyeok committed Oct 27, 2023
commit 436e75844e745b638f3cd8d965c8193496f86e93
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.pawwithu.connectdog.domain.intermediary.entity;

import jakarta.persistence.*;
import lombok.*;
import org.springframework.security.crypto.password.PasswordEncoder;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
@Entity
public class Intermediary {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String email; // 이메일
private String password; // 비밀번호
@Column(length = 20, nullable = false)
private String name; // 중개자 이름/중개 단체명
@Column(columnDefinition = "TEXT")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

우와 columnDefinition에 대해서 처음 알았어요.
해당 컬럼이 데이터베이스에 어떻게 생성될 것인지를 직접 지정할 수 있는 어노테이션이고, "TEXT"는 대용량의 문자열을 저장할 수 있는 데이터 타입을 의미하는 것 맞나요?

Copy link
Member Author

@kyeong-hyeok kyeong-hyeok Oct 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

맞습니다! 근데 columnDefinition = "TEXT"는 String으로 지정했을 때 varchar(255) 제한을 해제하는 건데, 이미지 url에는 사용을 안 해도 될 것 같아서 지우는 게 좋을 것 같아요! (보통 게시판 글의 내용의 제한을 해제할 때 썼습니다!)
이름의 length는 20으로 지정해두고 다른 컬럼은 따로 지정 안 했는데, 이 부분은 자세한 정보까지 나오면 바꿀게요!

private String url; // 이동봉사 계정 링크
@Column(columnDefinition = "TEXT")
private String authImage; // 인증 사진
@Enumerated(EnumType.STRING)
private IntermediaryRole role; // 권한
private Boolean isOptionAgr; // 선택 이용약관 체크 여부

@Builder
public Intermediary(String email, String password, String name, String url, String authImage, IntermediaryRole role, Boolean isOptionAgr) {
this.email = email;
this.password = password;
this.name = name;
this.url = url;
this.authImage = authImage;
this.role = role;
this.isOptionAgr = isOptionAgr;
}

public void passwordEncode(PasswordEncoder passwordEncoder) {
this.password = passwordEncoder.encode(this.password);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.pawwithu.connectdog.domain.intermediary.entity;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum IntermediaryRole {

INTERMEDIARY("ROLE_INTERMEDIARY"), AUTH_INTERMEDIARY("ROLE_AUTH_INTERMEDIARY");

private final String key;
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.pawwithu.connectdog.domain.volunteer.entity;

public enum SocialType {
KAKAO, NAVER
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.pawwithu.connectdog.domain.member.entity;
package com.pawwithu.connectdog.domain.volunteer.entity;

import jakarta.persistence.*;
import lombok.*;
@@ -8,46 +8,36 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
@Entity
public class Member {
public class Volunteer {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private String email; // 이메일
private String password; // 비밀번호
@Column(length = 15, nullable = false)
private String nickname; // 닉네임
@Column(length = 10, nullable = false)
private String name; // 이름
private String phone; // 이동봉사자 휴대폰 번호
private String url; // 이동봉사 단체 링크
private Boolean isOptionAgr; // 선택 이용약관 체크 여부

@Enumerated(EnumType.STRING)
private Role role;

private VolunteerRole role; // 권한
@Enumerated(EnumType.STRING)
private SocialType socialType; // KAKAO, NAVER

private String socialId; // 로그인한 소셜 타입 식별자 값 (일반 로그인의 경우 null)
private Boolean isOptionAgr; // 선택 이용약관 체크 여부

@Builder
public Member(String email, String password, String nickname, String name, String phone, String url, Boolean isOptionAgr, Role role, SocialType socialType, String socialId) {
public Volunteer(String email, String password, String nickname, VolunteerRole role, Boolean isOptionAgr) {
this.email = email;
this.password = password;
this.nickname = nickname;
this.name = name;
this.phone = phone;
this.url = url;
this.isOptionAgr = isOptionAgr;
this.role = role;
this.socialType = socialType;
this.socialId = socialId;
this.isOptionAgr = isOptionAgr;
}

public void passwordEncode(PasswordEncoder passwordEncoder) {
this.password = passwordEncoder.encode(this.password);
}



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.pawwithu.connectdog.domain.volunteer.entity;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum VolunteerRole {

USER("ROLE_USER"), AUTH_USER("ROLE_AUTH_USER");

private final String key;

}