Skip to content

Commit

Permalink
FIX: User 역할에 따른 Application 조회 로직 간소화 (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
oxdjww authored Nov 9, 2024
1 parent e15a20e commit ab57a78
Show file tree
Hide file tree
Showing 3 changed files with 310 additions and 298 deletions.
51 changes: 29 additions & 22 deletions src/main/java/com/soongsil/CoffeeChat/entity/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,42 @@
//@Inheritance(strategy = InheritanceType.JOINED) //자식 : Mentor, Mentee
//@DiscriminatorColumn // 하위 테이블의 구분 컬럼 생성(default = DTYPE)
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "user_id")
private Long id;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "user_id")
private Long id;

@Column
private String username;
@Column
private String username;

@Column
private String name;
@Column
private String name;

@Column
private String email;
@Column
private String email;

@Column
private String role;
@Column
private String role;

@Column
private String phoneNum; //전화번호
@Column
private String phoneNum; //전화번호

@Column
private String picture;
@Column
private String picture;

@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "user_mentor", referencedColumnName = "mentor_id")
private Mentor mentor;
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "user_mentor", referencedColumnName = "mentor_id")
private Mentor mentor;

@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "user_mentee", referencedColumnName = "mentee_id")
private Mentee mentee;
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "user_mentee", referencedColumnName = "mentee_id")
private Mentee mentee;

public boolean isMentor() {
return this.mentor != null;
}

public boolean isMentee() {
return this.mentee != null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import java.util.List;

import com.soongsil.CoffeeChat.entity.Mentee;
import org.springframework.data.jpa.repository.JpaRepository;

import com.soongsil.CoffeeChat.entity.Application;
import com.soongsil.CoffeeChat.entity.Mentor;

public interface ApplicationRepository extends JpaRepository<Application, Long> {
List<Application> findApplicationByMentor(Mentor mentor);
List<Application> findApplicationByMentee(Mentee mentee);
}
Loading

0 comments on commit ab57a78

Please sign in to comment.