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 @@ -38,15 +38,6 @@ public class ClubApplyControllerV1 {
private final ClubApplyServiceV1 clubApplyServiceV1;
private final ClubApplicationFormsRepository clubApplicationFormsRepository;

@GetMapping("/apply") //
@Operation(summary = "클럽 지원서 양식 불러오기",
description = "clubId를 기반으로 활성화된 최신 지원서를 반환합니다. <br>"
+ "<br>v2 api : /api/club/{clubId}/apply/{applicationFormId}")
public ResponseEntity<?> getClubApplication(@PathVariable String clubId) {

return clubApplyServiceV1.getClubApplicationForm(clubId, convertClubIdToFormId(clubId));
}

@PostMapping("/apply")
@Operation(summary = "클럽 지원", description = "clubId를 기반으로 활성화된 최신 지원서에 지원합니다. <br>"
+ "<br>v2 api : /api/club/{clubId}/apply/{applicationFormId}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ public ResponseEntity<?> applyToClub(@PathVariable String clubId,
return Response.ok("success apply");
}

/*@GetMapping("/apply")
@GetMapping("/apply")
@Operation(summary = "클럽의 활성화된 지원서 목록 불러오기", description = "클럽의 활성화된 모든 지원서 목록을 불러옵니다")
public ResponseEntity<?> getActiveApplicationForms(@PathVariable String clubId) {
return Response.ok(clubApplyService.getActiveApplicationForms(clubId));
}*/
return Response.ok(clubApplyPublicService.getActiveApplicationForms(clubId));
}



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
@Builder
public record ClubActiveFormResult(
String id,
String title,
String description
String title
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
public interface ClubActiveFormSlim {
String getId();
String getTitle();
String getDescription();
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public interface ClubApplicationFormsRepository extends MongoRepository<ClubAppl

@Query(
value = "{'clubId': ?0, 'status': 'ACTIVE'}",
fields = "{'_id': 1, 'title': 1, 'description': 1}"
fields = "{'_id': 1, 'title': 1}"
)
List<ClubActiveFormSlim> findClubActiveFormsByClubId(String clubId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,30 +176,6 @@ private static String termName(SemesterTerm term) {
private record SemesterKey(Integer year, SemesterTerm term) {
}


public ClubActiveFormsResponse getActiveApplicationForms(String clubId) {
List<ClubActiveFormSlim> forms = clubApplicationFormsRepository.findClubActiveFormsByClubId(clubId);

if (forms == null || forms.isEmpty())
throw new RestApiException(ErrorCode.ACTIVE_APPLICATION_NOT_FOUND);

List<ClubActiveFormResult> results = new ArrayList<>();
for (ClubActiveFormSlim form : forms) {
ClubActiveFormResult result = ClubActiveFormResult.builder()
.id(form.getId())
.title(form.getTitle())
.description(form.getDescription())
.build();
results.add(result);
}

return ClubActiveFormsResponse.builder()
.forms(results)
.build();

}

//V1
public ClubApplyInfoResponse getClubApplyInfo(String applicationFormId, CustomUserDetails user) {
ClubApplicationForm applicationForm = clubApplicationFormsRepository.findByClubIdAndId(user.getClubId(), applicationFormId)
.orElseThrow(() -> new RestApiException(ErrorCode.APPLICATION_NOT_FOUND));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
import moadong.club.entity.ClubApplicationFormQuestion;
import moadong.club.entity.ClubQuestionAnswer;
import moadong.club.enums.ClubApplicationQuestionType;
import moadong.club.payload.dto.ClubActiveFormResult;
import moadong.club.payload.dto.ClubActiveFormSlim;
import moadong.club.payload.request.ClubApplyRequest;
import moadong.club.payload.response.ClubActiveFormsResponse;
import moadong.club.payload.response.ClubApplicationFormResponse;
import moadong.club.repository.ClubApplicantsRepository;
import moadong.club.repository.ClubApplicationFormsRepository;
import moadong.club.repository.ClubApplicationFormsRepositoryCustom;
import moadong.global.exception.ErrorCode;
import moadong.global.exception.RestApiException;
import moadong.global.payload.Response;
Expand All @@ -30,9 +32,29 @@ public class ClubApplyPublicService {
private final ClubApplicationFormsRepository clubApplicationFormsRepository;
private final ClubApplicantsRepository clubApplicantsRepository;
private final AESCipher cipher;
private final ClubApplicationFormsRepositoryCustom clubApplicationFormsRepositoryCustom;


public ClubActiveFormsResponse getActiveApplicationForms(String clubId) {
List<ClubActiveFormSlim> forms = clubApplicationFormsRepository.findClubActiveFormsByClubId(clubId);

if (forms == null || forms.isEmpty())
throw new RestApiException(ErrorCode.ACTIVE_APPLICATION_NOT_FOUND);

List<ClubActiveFormResult> results = new ArrayList<>();
for (ClubActiveFormSlim form : forms) {
ClubActiveFormResult result = ClubActiveFormResult.builder()
.id(form.getId())
.title(form.getTitle())
.build();
results.add(result);
}

return ClubActiveFormsResponse.builder()
.forms(results)
.build();

}

public ResponseEntity<?> getClubApplicationForm(String clubId, String applicationFormId) {
ClubApplicationForm clubApplicationForm = clubApplicationFormsRepository.findByClubIdAndId(clubId, applicationFormId)
.orElseThrow(() -> new RestApiException(ErrorCode.APPLICATION_NOT_FOUND));
Expand Down
17 changes: 0 additions & 17 deletions backend/src/main/java/moadong/club/service/ClubApplyServiceV1.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,6 @@ public class ClubApplyServiceV1 {
private final ClubApplicantsRepository clubApplicantsRepository;
private final AESCipher cipher;

public ResponseEntity<?> getClubApplicationForm(String clubId, String applicationFormId) {
ClubApplicationForm clubApplicationForm = clubApplicationFormsRepository.findByClubIdAndId(clubId, applicationFormId)
.orElseThrow(() -> new RestApiException(ErrorCode.APPLICATION_NOT_FOUND));


ClubApplicationFormResponse clubApplicationFormResponse = ClubApplicationFormResponse.builder()
.title(clubApplicationForm.getTitle())
.description(Optional.ofNullable(clubApplicationForm.getDescription()).orElse(""))
.questions(clubApplicationForm.getQuestions())
.semesterYear(clubApplicationForm.getSemesterYear())
.semesterTerm(clubApplicationForm.getSemesterTerm())
.status(clubApplicationForm.getStatus())
.build();

return Response.ok(clubApplicationFormResponse);
}

public void applyToClub(String clubId, String applicationFormId, ClubApplyRequest request) {
ClubApplicationForm clubApplicationForm = clubApplicationFormsRepository.findByClubIdAndId(clubId, applicationFormId)
.orElseThrow(() -> new RestApiException(ErrorCode.APPLICATION_NOT_FOUND));
Expand Down
Loading