diff --git a/src/main/java/dmu/dasom/api/domain/somkathon/dto/SomParticipantRequestDto.java b/src/main/java/dmu/dasom/api/domain/somkathon/dto/SomParticipantRequestDto.java index 177c8a9..c166979 100644 --- a/src/main/java/dmu/dasom/api/domain/somkathon/dto/SomParticipantRequestDto.java +++ b/src/main/java/dmu/dasom/api/domain/somkathon/dto/SomParticipantRequestDto.java @@ -54,4 +54,10 @@ public class SomParticipantRequestDto { @URL(protocol = "https", message = "포트폴리오 URL이 올바르지 않습니다.") @Schema(description = "포트폴리오 주소", example = "https://portfolio.com/username", required = true) private final String portfolioLink; // 포트폴리오 주소 -} + + @Schema(description = "컴퓨터공학부 내 전과 여부 (true: 컴퓨터공학부 내에서 전과함, false: 다른 학부에서 전과함, null: 전과 안 함)", example = "null") + private final Boolean isTransferredInCS; + + @Schema(description = "학생회비 납부 여부 (true: 납부, false: 미납, null: 선택 안 함)", example = "null") + private final Boolean isPaid; +} \ No newline at end of file diff --git a/src/main/java/dmu/dasom/api/domain/somkathon/dto/SomParticipantResponseDto.java b/src/main/java/dmu/dasom/api/domain/somkathon/dto/SomParticipantResponseDto.java index fe0befe..b831b50 100644 --- a/src/main/java/dmu/dasom/api/domain/somkathon/dto/SomParticipantResponseDto.java +++ b/src/main/java/dmu/dasom/api/domain/somkathon/dto/SomParticipantResponseDto.java @@ -3,10 +3,8 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Builder; import lombok.Getter; -import lombok.Setter; @Getter -@Setter @Builder @Schema(description = "솜커톤 참가자 응답 DTO") public class SomParticipantResponseDto { @@ -37,4 +35,10 @@ public class SomParticipantResponseDto { @Schema(description = "포트폴리오 주소", example = "https://portfolio.com/username", required = true) private String portfolioLink; // 포트폴리오 주소 + + @Schema(description = "컴퓨터공학부 내 전과 여부 (true: 컴퓨터공학부 내에서 전과함, false: 다른 학부에서 전과함, null: 전과 안 함)", example = "null") + private Boolean isTransferredInCS; // 컴퓨터공학부 내 전과 여부 + + @Schema(description = "학생회비 납부 여부 (true: 납부, false: 미납, null: 선택 안 함)", example = "null") + private Boolean isPaid; // 학생회비 납부 여부 } \ No newline at end of file diff --git a/src/main/java/dmu/dasom/api/domain/somkathon/entity/SomParticipant.java b/src/main/java/dmu/dasom/api/domain/somkathon/entity/SomParticipant.java index 23eba69..1125bfc 100644 --- a/src/main/java/dmu/dasom/api/domain/somkathon/entity/SomParticipant.java +++ b/src/main/java/dmu/dasom/api/domain/somkathon/entity/SomParticipant.java @@ -46,6 +46,12 @@ public class SomParticipant extends BaseEntity { @Column(nullable = false) private String portfolioLink; // 포트폴리오 링크 + @Column + private Boolean isTransferredInCS; // 컴퓨터공학부 내 전과 여부 + + @Column + private Boolean isPaid; // 학생회비 납부 여부 + public void update(SomParticipantRequestDto requestDto) { this.participantName = requestDto.getParticipantName(); this.studentId = requestDto.getStudentId(); @@ -55,22 +61,26 @@ public void update(SomParticipantRequestDto requestDto) { this.email = requestDto.getEmail(); this.githubLink = requestDto.getGithubLink(); this.portfolioLink = requestDto.getPortfolioLink(); + this.isTransferredInCS = requestDto.getIsTransferredInCS(); + this.isPaid = requestDto.getIsPaid(); } /** * Entity → Response DTO 변환 메서드 */ - public SomParticipantResponseDto toResponseDto(SomParticipant participant) { + public SomParticipantResponseDto toResponseDto() { return SomParticipantResponseDto.builder() - .id(participant.getId()) - .participantName(participant.getParticipantName()) - .studentId(participant.getStudentId()) - .department(participant.getDepartment()) - .grade(participant.getGrade()) - .contact(participant.getContact()) - .email(participant.getEmail()) - .githubLink(participant.getGithubLink()) - .portfolioLink(participant.getPortfolioLink()) + .id(this.getId()) + .participantName(this.getParticipantName()) + .studentId(this.getStudentId()) + .department(this.getDepartment()) + .grade(this.getGrade()) + .contact(this.getContact()) + .email(this.getEmail()) + .githubLink(this.getGithubLink()) + .portfolioLink(this.getPortfolioLink()) + .isTransferredInCS(this.getIsTransferredInCS()) + .isPaid(this.getIsPaid()) .build(); } -} +} \ No newline at end of file diff --git a/src/main/java/dmu/dasom/api/domain/somkathon/service/SomParticipantService.java b/src/main/java/dmu/dasom/api/domain/somkathon/service/SomParticipantService.java index d67edcc..1b2750b 100644 --- a/src/main/java/dmu/dasom/api/domain/somkathon/service/SomParticipantService.java +++ b/src/main/java/dmu/dasom/api/domain/somkathon/service/SomParticipantService.java @@ -31,11 +31,13 @@ public SomParticipantResponseDto createParticipant(SomParticipantRequestDto requ .email(requestDto.getEmail()) .githubLink(requestDto.getGithubLink()) .portfolioLink(requestDto.getPortfolioLink()) + .isTransferredInCS(requestDto.getIsTransferredInCS()) + .isPaid(requestDto.getIsPaid()) .build(); SomParticipant saved = somParticipantRepository.save(participant); - return saved.toResponseDto(saved); + return saved.toResponseDto(); } /** @@ -43,7 +45,7 @@ public SomParticipantResponseDto createParticipant(SomParticipantRequestDto requ */ public List getAllParticipants() { return somParticipantRepository.findAll().stream() - .map(p -> p.toResponseDto(p)) + .map(SomParticipant::toResponseDto) .collect(Collectors.toList()); } @@ -53,7 +55,7 @@ public List getAllParticipants() { public SomParticipantResponseDto getParticipant(Long id){ SomParticipant participant = findParticipantById(id); - return participant.toResponseDto(participant); + return participant.toResponseDto(); } /** @@ -64,7 +66,7 @@ public SomParticipantResponseDto updateParticipant(Long id, SomParticipantReques participant.update(requestDto); - return participant.toResponseDto(participant); + return participant.toResponseDto(); } /** diff --git a/src/test/java/dmu/dasom/api/domain/somkathon/SomParticipantServiceTest.java b/src/test/java/dmu/dasom/api/domain/somkathon/SomParticipantServiceTest.java index 47c4b63..f45b19f 100644 --- a/src/test/java/dmu/dasom/api/domain/somkathon/SomParticipantServiceTest.java +++ b/src/test/java/dmu/dasom/api/domain/somkathon/SomParticipantServiceTest.java @@ -44,6 +44,8 @@ void createParticipant_success() { .email("hong@example.com") .githubLink("https://github.com/username") .portfolioLink("https://drive.google.com/file") + .isTransferredInCS(null) // null 테스트 + .isPaid(true) // true 테스트 .build(); when(repository.findByStudentId("20250001")).thenReturn(Optional.empty()); @@ -60,6 +62,8 @@ void createParticipant_success() { assertEquals("hong@example.com", response.getEmail()); assertEquals("https://github.com/username", response.getGithubLink()); assertEquals("https://drive.google.com/file", response.getPortfolioLink()); + assertNull(response.getIsTransferredInCS()); + assertTrue(response.getIsPaid()); verify(repository, times(1)).findByStudentId("20250001"); verify(repository, times(1)).save(any(SomParticipant.class)); @@ -96,6 +100,8 @@ void getAllParticipants_success() { .email("hong@example.com") .githubLink("https://github.com/hong") .portfolioLink("https://drive.google.com/file") + .isTransferredInCS(null) + .isPaid(true) .build(); SomParticipant p2 = SomParticipant.builder() .participantName("김철수") @@ -106,6 +112,8 @@ void getAllParticipants_success() { .email("kim@example.com") .githubLink("https://github.com/kim") .portfolioLink("https://notion.site") + .isTransferredInCS(false) + .isPaid(false) .build(); when(repository.findAll()).thenReturn(List.of(p1, p2)); @@ -117,6 +125,10 @@ void getAllParticipants_success() { assertEquals("김철수", list.get(1).getParticipantName()); assertEquals("https://github.com/hong", list.get(0).getGithubLink()); assertEquals("https://notion.site", list.get(1).getPortfolioLink()); + assertNull(list.get(0).getIsTransferredInCS()); + assertTrue(list.get(0).getIsPaid()); + assertFalse(list.get(1).getIsPaid()); + assertFalse(list.get(1).getIsTransferredInCS()); verify(repository, times(1)).findAll(); } @@ -133,6 +145,8 @@ void getParticipant_success() { .email("hong@example.com") .githubLink("https://github.com/username") .portfolioLink("https://drive.google.com/file") + .isTransferredInCS(true) + .isPaid(false) .build(); when(repository.findById(1L)).thenReturn(Optional.of(participant)); @@ -141,6 +155,8 @@ void getParticipant_success() { assertEquals("홍길동", response.getParticipantName()); assertEquals("20250001", response.getStudentId()); + assertTrue(response.getIsTransferredInCS()); + assertFalse(response.getIsPaid()); verify(repository, times(1)).findById(1L); } @@ -171,6 +187,8 @@ void updateParticipant_success() { .email("hong@example.com") .githubLink("https://github.com/username") .portfolioLink("https://drive.google.com/file") + .isTransferredInCS(false) + .isPaid(false) .build(); SomParticipantRequestDto updateRequest = SomParticipantRequestDto.builder() @@ -182,6 +200,8 @@ void updateParticipant_success() { .email("hong2@example.com") .githubLink("https://github.com/username2") .portfolioLink("https://drive.google.com/file2") + .isTransferredInCS(true) + .isPaid(null) .build(); when(repository.findById(1L)).thenReturn(Optional.of(existing)); @@ -196,6 +216,8 @@ void updateParticipant_success() { assertEquals("hong2@example.com", response.getEmail()); assertEquals("https://github.com/username2", response.getGithubLink()); assertEquals("https://drive.google.com/file2", response.getPortfolioLink()); + assertTrue(response.getIsTransferredInCS()); + assertNull(response.getIsPaid()); verify(repository, times(1)).findById(1L); }