Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ public ResponseEntity<?> deleteClubApplicationForm(@PathVariable String applicat
return Response.ok("success delete application");
}

@PostMapping("/application/{applicationFormId}/duplicate")
@Operation(summary = "클럽 지원서 양식 복제", description = "클럽의 지원서 양식을 복제합니다")
@PreAuthorize("isAuthenticated()")
@SecurityRequirement(name = "BearerAuth")
public ResponseEntity<?> duplicateClubApplicationForm(@PathVariable String applicationFormId,
@CurrentUser CustomUserDetails user) {
clubApplyAdminService.duplicateClubApplicationForm(applicationFormId, user);
return Response.ok("success duplicate application");
}

@GetMapping("/apply/info/{applicationFormId}")
@Operation(summary = "클럽 지원자 현황", description = "클럽 지원자 현황을 불러옵니다")
@PreAuthorize("isAuthenticated()")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
@Getter
@Builder(toBuilder = true)
public class ClubApplicationForm implements Persistable<String> {
private static final String[] externalApplicationUrlAllowed = {"https://forms.gle", "https://docs.google.com/forms", "https://form.naver.com", "https://naver.me"};
private static final String[] externalApplicationUrlAllowed = {"https://forms.gle", "https://docs.google.com/forms", "https://form.naver.com", "https://naver.me", "https://everytime.kr"};

@Id
private String id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import lombok.extern.slf4j.Slf4j;
import moadong.club.entity.*;
import moadong.club.enums.SemesterTerm;
import moadong.club.payload.dto.*;
import moadong.club.payload.dto.ApplicantStatusEvent;
import moadong.club.payload.dto.ClubApplicantsResult;
import moadong.club.payload.request.*;
import moadong.club.payload.response.ClubApplicationFormsResponse;
import moadong.club.payload.response.ClubApplyInfoResponse;
Expand Down Expand Up @@ -128,6 +129,23 @@ public void deleteClubApplicationForm(String applicationFormId, CustomUserDetail
clubApplicationFormsRepository.delete(applicationForm);
}

@Transactional
public void duplicateClubApplicationForm(String applicationFormId, CustomUserDetails user) {
ClubApplicationForm oldApplicationForm = clubApplicationFormsRepository.findByClubIdAndId(user.getClubId(), applicationFormId)
.orElseThrow(() -> new RestApiException(ErrorCode.APPLICATION_NOT_FOUND));

ClubApplicationForm newApplicationForm = ClubApplicationForm.builder()
.title("무제")
.clubId(oldApplicationForm.getClubId())
.description(oldApplicationForm.getDescription())
.formMode(oldApplicationForm.getFormMode())
.questions(oldApplicationForm.getQuestions())
.externalApplicationUrl(oldApplicationForm.getExternalApplicationUrl())
.build();
Comment on lines +137 to +144
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

얕은 복사로 인한 데이터 손상 위험

oldApplicationForm.getQuestions()를 직접 전달하면 두 폼이 동일한 리스트 참조를 공유합니다. ClubApplicationForm.updateQuestions()this.questions.clear()를 호출하므로, 한 폼의 질문을 수정하면 다른 폼의 질문도 함께 삭제됩니다.

🐛 새 리스트로 복사하여 수정
         ClubApplicationForm newApplicationForm = ClubApplicationForm.builder()
                 .title("무제")
                 .clubId(oldApplicationForm.getClubId())
                 .description(oldApplicationForm.getDescription())
                 .formMode(oldApplicationForm.getFormMode())
-                .questions(oldApplicationForm.getQuestions())
+                .questions(new ArrayList<>(oldApplicationForm.getQuestions()))
                 .externalApplicationUrl(oldApplicationForm.getExternalApplicationUrl())
                 .build();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ClubApplicationForm newApplicationForm = ClubApplicationForm.builder()
.title("무제")
.clubId(oldApplicationForm.getClubId())
.description(oldApplicationForm.getDescription())
.formMode(oldApplicationForm.getFormMode())
.questions(oldApplicationForm.getQuestions())
.externalApplicationUrl(oldApplicationForm.getExternalApplicationUrl())
.build();
ClubApplicationForm newApplicationForm = ClubApplicationForm.builder()
.title("무제")
.clubId(oldApplicationForm.getClubId())
.description(oldApplicationForm.getDescription())
.formMode(oldApplicationForm.getFormMode())
.questions(new ArrayList<>(oldApplicationForm.getQuestions()))
.externalApplicationUrl(oldApplicationForm.getExternalApplicationUrl())
.build();
🤖 Prompt for AI Agents
In `@backend/src/main/java/moadong/club/service/ClubApplyAdminService.java` around
lines 137 - 144, The new ClubApplicationForm is being built using
oldApplicationForm.getQuestions() which shares the same List reference and can
be cleared by ClubApplicationForm.updateQuestions(); change the builder step
that sets questions in ClubApplicationForm to pass a new copy of the list (e.g.,
new ArrayList<>(oldApplicationForm.getQuestions())) or perform a deep copy of
individual question objects if they are mutable, so newApplicationForm has its
own independent questions collection.


clubApplicationFormsRepository.save(newApplicationForm);
}

public ClubApplyInfoResponse getClubApplyInfo(String applicationFormId, CustomUserDetails user) {
ClubApplicationForm applicationForm = clubApplicationFormsRepository.findByClubIdAndId(user.getClubId(), applicationFormId)
.orElseThrow(() -> new RestApiException(ErrorCode.APPLICATION_NOT_FOUND));
Expand Down