-
Notifications
You must be signed in to change notification settings - Fork 0
✨[CCI-54] 게스트 로그인 API #55
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package cloudcomputinginha.demo.config.auth; | ||
|
|
||
| import cloudcomputinginha.demo.repository.MemberRepository; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.scheduling.annotation.Scheduled; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
| import java.time.LocalDateTime; | ||
|
|
||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class GuestAccountCleaner { | ||
| private final MemberRepository memberRepository; | ||
|
|
||
| @Scheduled(fixedDelay = 3600000) | ||
| @Transactional | ||
| public void deleteOldGuestAccounts() { | ||
| LocalDateTime threshold = LocalDateTime.now().minusHours(1); | ||
| memberRepository.deleteByIsGuestTrueAndCreatedAtBefore(threshold); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package cloudcomputinginha.demo.config.auth.dto; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Getter | ||
| @Builder | ||
| @AllArgsConstructor | ||
| @NoArgsConstructor | ||
| public class GuestLoginResponse { | ||
| private String accessToken; | ||
| private Long memberId; | ||
| private String randomName; | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,8 @@ | |||||||||||
| import cloudcomputinginha.demo.domain.common.BaseEntity; | ||||||||||||
| import jakarta.persistence.*; | ||||||||||||
| import lombok.*; | ||||||||||||
| import java.util.ArrayList; | ||||||||||||
| import java.util.List; | ||||||||||||
|
|
||||||||||||
| @Entity | ||||||||||||
| @Getter | ||||||||||||
|
|
@@ -21,6 +23,9 @@ public class Coverletter extends BaseEntity { | |||||||||||
| @JoinColumn(name = "member_id", nullable = false) | ||||||||||||
| private Member member; | ||||||||||||
|
|
||||||||||||
| @OneToMany(mappedBy = "coverletter", cascade = CascadeType.ALL, orphanRemoval = true) | ||||||||||||
| private List<Qna> qnas = new ArrayList<>(); | ||||||||||||
|
|
||||||||||||
|
Comment on lines
+26
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Ensure non-null When the entity is created through Lombok’s - @OneToMany(mappedBy = "coverletter", cascade = CascadeType.ALL, orphanRemoval = true)
- private List<Qna> qnas = new ArrayList<>();
+ @OneToMany(mappedBy = "coverletter", cascade = CascadeType.ALL, orphanRemoval = true)
+ @Builder.Default
+ private List<Qna> qnas = new ArrayList<>();📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||
| @Column(length = 100) | ||||||||||||
| private String corporateName; | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,8 @@ | |
| import org.hibernate.annotations.DynamicUpdate; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| @Entity | ||
| @Getter | ||
|
|
@@ -42,12 +44,17 @@ public class Interview extends BaseEntity { | |
| @Column(columnDefinition = "VARCHAR(20)") | ||
| private StartType startType; | ||
|
|
||
| private Long hostId; | ||
| // private Long hostId; | ||
|
|
||
| @Builder.Default | ||
| @Column(nullable = false) | ||
| private Integer currentParticipants = 1; | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "host_id", nullable = false) | ||
| private Member host; | ||
|
|
||
|
Comment on lines
+53
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing
🤖 Prompt for AI Agents |
||
|
|
||
| @Builder.Default | ||
| private Integer maxParticipants = 1; //일대일 면접을 기준으로 초기화 | ||
|
|
||
|
|
@@ -58,10 +65,14 @@ public class Interview extends BaseEntity { | |
|
|
||
| private LocalDateTime endedAt; | ||
|
|
||
| @OneToOne(fetch = FetchType.LAZY) | ||
| @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE, orphanRemoval = true) | ||
| @JoinColumn(name = "interview_option_id", unique = true, nullable = false) | ||
| private InterviewOption interviewOption; | ||
|
|
||
| @OneToMany(mappedBy = "interview", cascade = CascadeType.REMOVE, orphanRemoval = true) | ||
| private List<MemberInterview> memberInterviews = new ArrayList<>(); | ||
|
|
||
|
|
||
| public void updateStartedAt(LocalDateTime startedAt) { | ||
| this.startedAt = startedAt; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,8 +3,10 @@ | |
| import cloudcomputinginha.demo.domain.common.BaseEntity; | ||
| import cloudcomputinginha.demo.domain.enums.SocialProvider; | ||
| import jakarta.persistence.*; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import lombok.*; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.UUID; | ||
|
|
||
| @Entity | ||
| @Getter | ||
|
|
@@ -33,15 +35,28 @@ public class Member extends BaseEntity { | |
| private String introduction; | ||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| @Column(length = 10, nullable = false) | ||
| @Column(length = 10) | ||
| private SocialProvider socialProvider; | ||
|
|
||
| @Column(length = 100, nullable = false) | ||
| @Column(length = 100) | ||
| private String providerId; | ||
|
|
||
| @Column(columnDefinition = "TEXT") | ||
| private String refreshToken; | ||
|
|
||
| @OneToMany(mappedBy = "member", cascade = CascadeType.REMOVE, orphanRemoval = true) | ||
| private List<Coverletter> coverLetters = new ArrayList<>(); | ||
|
|
||
| @OneToMany(mappedBy = "member", cascade = CascadeType.REMOVE, orphanRemoval = true) | ||
| private List<Resume> resumes = new ArrayList<>(); | ||
|
|
||
| @OneToMany(mappedBy = "member", cascade = CascadeType.REMOVE, orphanRemoval = true) | ||
| private List<MemberInterview> memberInterviews = new ArrayList<>(); | ||
|
|
||
| @OneToMany(mappedBy = "host", cascade = CascadeType.REMOVE, orphanRemoval = true) | ||
| private List<Interview> hostedInterviews = new ArrayList<>(); | ||
|
|
||
|
|
||
| public void setRefreshToken(String refreshToken) { | ||
| this.refreshToken = refreshToken; | ||
| } | ||
|
|
@@ -58,4 +73,15 @@ public void updateInfo(String name, String phone, String jobType, String introdu | |
| this.jobType = jobType; | ||
| this.introduction = introduction; | ||
| } | ||
|
|
||
| // 게스트 로그인 | ||
| private boolean isGuest; | ||
|
|
||
| public static Member createGuest(String randomName) { | ||
| Member member = new Member(); | ||
| member.email = "guest_" + UUID.randomUUID().toString().substring(0, 5)+ "@guest.com"; | ||
| member.name = randomName; | ||
| member.isGuest = true; | ||
| return member; | ||
| } | ||
|
Comment on lines
+78
to
+86
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add column annotation & reduce collision risk in guest email generation
-member.email = "guest_" + UUID.randomUUID().toString().substring(0, 5) + "@guest.com";
+member.email = "guest_" + UUID.randomUUID().toString().substring(0, 10) + "@guest.com";🤖 Prompt for AI Agents |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Use
SecureRandom+ transactional save for guest creationRandomisn’t cryptographically strong.SecureRandomprevents predictable guest names.@Transactional(or handle rollback manually).savefor clarity.📝 Committable suggestion
🤖 Prompt for AI Agents