-
Notifications
You must be signed in to change notification settings - Fork 1
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
[DDING-107] 최종 합격 지원자 동아리원 명단 등록 API 구현 #247
Changes from 9 commits
127d48d
526bf35
a16b83f
a927c42
2ab53e0
ba53a19
51b952b
ecc1e7b
89b8511
62414a7
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 |
---|---|---|
@@ -1,10 +1,13 @@ | ||
package ddingdong.ddingdongBE.domain.form.service; | ||
|
||
import static ddingdong.ddingdongBE.domain.club.entity.Position.MEMBER; | ||
|
||
import ddingdong.ddingdongBE.common.exception.AuthenticationException.NonHaveAuthority; | ||
import ddingdong.ddingdongBE.common.exception.InvalidatedMappingException.InvalidFormPeriodException; | ||
import ddingdong.ddingdongBE.common.utils.TimeUtils; | ||
import ddingdong.ddingdongBE.domain.club.entity.Club; | ||
import ddingdong.ddingdongBE.domain.club.service.ClubService; | ||
import ddingdong.ddingdongBE.domain.clubmember.entity.ClubMember; | ||
import ddingdong.ddingdongBE.domain.form.entity.Form; | ||
import ddingdong.ddingdongBE.domain.form.entity.FormField; | ||
import ddingdong.ddingdongBE.domain.form.service.dto.command.CreateFormCommand; | ||
|
@@ -17,6 +20,8 @@ | |
import ddingdong.ddingdongBE.domain.form.service.dto.query.FormStatisticsQuery.ApplicantStatisticQuery; | ||
import ddingdong.ddingdongBE.domain.form.service.dto.query.FormStatisticsQuery.DepartmentStatisticQuery; | ||
import ddingdong.ddingdongBE.domain.form.service.dto.query.FormStatisticsQuery.FieldStatisticsQuery; | ||
import ddingdong.ddingdongBE.domain.formapplication.entity.FormApplication; | ||
import ddingdong.ddingdongBE.domain.formapplication.service.FormApplicationService; | ||
import ddingdong.ddingdongBE.domain.user.entity.User; | ||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
@@ -34,6 +39,7 @@ public class FacadeCentralFormServiceImpl implements FacadeCentralFormService { | |
private final FormFieldService formFieldService; | ||
private final ClubService clubService; | ||
private final FormStatisticService formStatisticService; | ||
private final FormApplicationService formApplicationService; | ||
|
||
@Transactional | ||
@Override | ||
|
@@ -102,6 +108,23 @@ public FormStatisticsQuery getStatisticsByForm(User user, Long formId) { | |
return new FormStatisticsQuery(totalCount, departmentStatisticQueries, applicantStatisticQueries, fieldStatisticsQuery); | ||
} | ||
|
||
@Override | ||
@Transactional | ||
public void registerApplicantAsMember(Long formId) { | ||
List<FormApplication> finalPassedFormApplications = formApplicationService.getAllFinalPassedByFormId(formId); | ||
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. p2) 제 의견은 상태 수정 API에서 hasInterview가 false일 경우 서류 통과시 First pass가 아닌 final pass로 변경되는게 좋아보입니다 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. hasInterview가 false일 경우 합격 처리가 되면 FINAL_PASS로 변경이 아닌 FIRST_PASS라는 뜻인가요??? 최종 합격 상태
이게 맞을까요?? 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. 네 최종합격을 판단하는 부분에서 위처럼 해도 좋을 것 같습니다. |
||
finalPassedFormApplications.forEach(formApplication -> { | ||
Club club = formApplication.getForm().getClub(); | ||
ClubMember clubMember = ClubMember.builder() | ||
.name(formApplication.getName()) | ||
.studentNumber(formApplication.getStudentNumber()) | ||
.department(formApplication.getDepartment()) | ||
.phoneNumber(formApplication.getPhoneNumber()) | ||
.position(MEMBER) | ||
.build(); | ||
club.addClubMember(clubMember); | ||
}); | ||
} | ||
Comment on lines
+111
to
+126
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. 보안 및 유효성 검사 추가 필요 다음 사항들을 고려해야 합니다:
다음과 같이 수정하는 것을 제안합니다: @Override
@Transactional
public void registerApplicantAsMember(Long formId) {
+ Form form = formService.getById(formId);
+ Club club = form.getClub();
+ User currentUser = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
+ validateEqualsClub(club, form);
List<FormApplication> finalPassedFormApplications = formApplicationService.getAllFinalPassedByFormId(formId);
finalPassedFormApplications.forEach(formApplication -> {
- Club club = formApplication.getForm().getClub();
+ if (isDuplicateClubMember(club, formApplication.getStudentNumber())) {
+ throw new DuplicateClubMemberException(formApplication.getStudentNumber());
+ }
ClubMember clubMember = ClubMember.builder()
.name(formApplication.getName())
.studentNumber(formApplication.getStudentNumber())
.department(formApplication.getDepartment())
.phoneNumber(formApplication.getPhoneNumber())
.position(MEMBER)
.build();
club.addClubMember(clubMember);
});
}
+ private boolean isDuplicateClubMember(Club club, String studentNumber) {
+ return club.getClubMembers().stream()
+ .anyMatch(member -> member.getStudentNumber().equals(studentNumber));
+ }
|
||
|
||
private FormListQuery buildFormListQuery(Form form) { | ||
boolean isActive = TimeUtils.isDateInRange(LocalDate.now(), form.getStartDate(), form.getEndDate()); | ||
return FormListQuery.from(form, isActive); | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -13,37 +13,45 @@ | |||||||||||||||||||||||||
@Getter | ||||||||||||||||||||||||||
public class FormApplication extends BaseEntity { | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
@Id | ||||||||||||||||||||||||||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||||||||||||||||||||||||||
private Long id; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
@Column(nullable = false) | ||||||||||||||||||||||||||
private String name; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
@Column(nullable = false) | ||||||||||||||||||||||||||
private String studentNumber; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
@Column(nullable = false) | ||||||||||||||||||||||||||
private String department; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
@Enumerated(EnumType.STRING) | ||||||||||||||||||||||||||
@Column(nullable = false, name = "status") | ||||||||||||||||||||||||||
private FormApplicationStatus status; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
@ManyToOne(fetch = FetchType.LAZY) | ||||||||||||||||||||||||||
private Form form; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
@Builder | ||||||||||||||||||||||||||
private FormApplication(String name, String studentNumber, String department, | ||||||||||||||||||||||||||
FormApplicationStatus status, Form form) { | ||||||||||||||||||||||||||
this.name = name; | ||||||||||||||||||||||||||
this.studentNumber = studentNumber; | ||||||||||||||||||||||||||
this.department = department; | ||||||||||||||||||||||||||
this.status = status; | ||||||||||||||||||||||||||
this.form = form; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
public void updateStatus(FormApplicationStatus status) { | ||||||||||||||||||||||||||
this.status = status; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
@Id | ||||||||||||||||||||||||||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||||||||||||||||||||||||||
private Long id; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
@Column(nullable = false) | ||||||||||||||||||||||||||
private String name; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
@Column(nullable = false) | ||||||||||||||||||||||||||
private String studentNumber; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
@Column(nullable = false) | ||||||||||||||||||||||||||
private String department; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
@Column(nullable = false) | ||||||||||||||||||||||||||
private String phoneNumber; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
@Column(nullable = false) | ||||||||||||||||||||||||||
private String email; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
Comment on lines
+29
to
+34
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 전화번호와 이메일 필드에 유효성 검증이 필요합니다. 전화번호와 이메일 형식에 대한 유효성 검증이 없습니다. 잘못된 형식의 데이터가 저장될 수 있으므로 다음과 같은 검증을 추가하는 것이 좋겠습니다: + @Pattern(regexp = "^\\d{3}-\\d{3,4}-\\d{4}$", message = "올바른 전화번호 형식이 아닙니다.")
@Column(nullable = false)
private String phoneNumber;
+ @Email(message = "올바른 이메일 형식이 아닙니다.")
@Column(nullable = false)
private String email; 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||
@Enumerated(EnumType.STRING) | ||||||||||||||||||||||||||
@Column(nullable = false, name = "status") | ||||||||||||||||||||||||||
private FormApplicationStatus status; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
@ManyToOne(fetch = FetchType.LAZY) | ||||||||||||||||||||||||||
private Form form; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
@Builder | ||||||||||||||||||||||||||
private FormApplication(String name, String studentNumber, String department, String phoneNumber, String email, | ||||||||||||||||||||||||||
FormApplicationStatus status, Form form) { | ||||||||||||||||||||||||||
this.name = name; | ||||||||||||||||||||||||||
this.studentNumber = studentNumber; | ||||||||||||||||||||||||||
this.department = department; | ||||||||||||||||||||||||||
this.phoneNumber = phoneNumber; | ||||||||||||||||||||||||||
this.email = email; | ||||||||||||||||||||||||||
this.status = status; | ||||||||||||||||||||||||||
this.form = form; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
public void updateStatus(FormApplicationStatus status) { | ||||||||||||||||||||||||||
this.status = status; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
} |
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
메서드 이름과 유효성 검사 개선 필요
메서드 이름이 목적을 명확하게 표현하지 않으며, club 매개변수에 대한 null 검사가 누락되었습니다.
다음과 같이 개선하는 것을 제안합니다:
📝 Committable suggestion