Skip to content
Open
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 @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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; // 학생회비 납부 여부
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,21 @@ 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();
}

/**
* 모든 참가자 조회 (Read)
*/
public List<SomParticipantResponseDto> getAllParticipants() {
return somParticipantRepository.findAll().stream()
.map(p -> p.toResponseDto(p))
.map(SomParticipant::toResponseDto)
.collect(Collectors.toList());
}

Expand All @@ -53,7 +55,7 @@ public List<SomParticipantResponseDto> getAllParticipants() {
public SomParticipantResponseDto getParticipant(Long id){
SomParticipant participant = findParticipantById(id);

return participant.toResponseDto(participant);
return participant.toResponseDto();
}

/**
Expand All @@ -64,7 +66,7 @@ public SomParticipantResponseDto updateParticipant(Long id, SomParticipantReques

participant.update(requestDto);

return participant.toResponseDto(participant);
return participant.toResponseDto();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ void createParticipant_success() {
.email("[email protected]")
.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());
Expand All @@ -60,6 +62,8 @@ void createParticipant_success() {
assertEquals("[email protected]", 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));
Expand Down Expand Up @@ -96,6 +100,8 @@ void getAllParticipants_success() {
.email("[email protected]")
.githubLink("https://github.com/hong")
.portfolioLink("https://drive.google.com/file")
.isTransferredInCS(null)
.isPaid(true)
.build();
SomParticipant p2 = SomParticipant.builder()
.participantName("김철수")
Expand All @@ -106,6 +112,8 @@ void getAllParticipants_success() {
.email("[email protected]")
.githubLink("https://github.com/kim")
.portfolioLink("https://notion.site")
.isTransferredInCS(false)
.isPaid(false)
.build();

when(repository.findAll()).thenReturn(List.of(p1, p2));
Expand All @@ -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();
}
Expand All @@ -133,6 +145,8 @@ void getParticipant_success() {
.email("[email protected]")
.githubLink("https://github.com/username")
.portfolioLink("https://drive.google.com/file")
.isTransferredInCS(true)
.isPaid(false)
.build();

when(repository.findById(1L)).thenReturn(Optional.of(participant));
Expand All @@ -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);
}
Expand Down Expand Up @@ -171,6 +187,8 @@ void updateParticipant_success() {
.email("[email protected]")
.githubLink("https://github.com/username")
.portfolioLink("https://drive.google.com/file")
.isTransferredInCS(false)
.isPaid(false)
.build();

SomParticipantRequestDto updateRequest = SomParticipantRequestDto.builder()
Expand All @@ -182,6 +200,8 @@ void updateParticipant_success() {
.email("[email protected]")
.githubLink("https://github.com/username2")
.portfolioLink("https://drive.google.com/file2")
.isTransferredInCS(true)
.isPaid(null)
.build();

when(repository.findById(1L)).thenReturn(Optional.of(existing));
Expand All @@ -196,6 +216,8 @@ void updateParticipant_success() {
assertEquals("[email protected]", 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);
}
Expand Down
Loading