-
Notifications
You must be signed in to change notification settings - Fork 0
[feat] 솜커톤 모집 API 생성 #73
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
639bbe9
fix: 면접 예약 API 면접 일정 조회시 status도 같이 반환
hodoon 0027cfd
Merge branch 'fix/#59-1' into dev
hodoon 2ea02c0
fix: 면접 예약 API 예약자 명단 조회 API 추가
hodoon 7112252
fix: 면접 예약 API 예약되어있는 슬롯은 삭제하지 않는 기능 추가
hodoon 5e118c7
Merge branch 'dev' of https://github.com/DASOM-GitHub/dasom-web-backe…
hodoon 311122c
fix: 면접 예약자 조회 API 면접일, 면접시간, 면접을 예약한 날짜과 시간 추가
hodoon 5ed900c
Merge branch 'dev' of https://github.com/DASOM-GitHub/dasom-web-backe…
hodoon 47e6d4f
Merge branch 'feat/#61-1' into dev
hodoon 0672e0c
Merge branch 'fix/#59-2' into dev
hodoon 47e2cc7
Merge remote-tracking branch 'origin/dev' into dev
hodoon e82390b
feat: 솜커톤 참가자 모집 API 생성
hodoon a37ee6f
feat: 솜커톤 참가자 모집 API 요청 URL에 somkathon 추가
hodoon e217b99
fix: 솜커톤 참가자 모집 API comment 해결
hodoon d66be52
fix: 솜커톤 참가자 모집 API comment 해결
hodoon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...itoty/InterviewReservationRepository.java → ...itory/InterviewReservationRepository.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...w/repositoty/InterviewSlotRepository.java → ...w/repository/InterviewSlotRepository.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
src/main/java/dmu/dasom/api/domain/somkathon/controller/SomParticipantController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| package dmu.dasom.api.domain.somkathon.controller; | ||
|
|
||
| import dmu.dasom.api.domain.somkathon.dto.SomParticipantRequestDto; | ||
| import dmu.dasom.api.domain.somkathon.dto.SomParticipantResponseDto; | ||
| import dmu.dasom.api.domain.somkathon.service.SomParticipantService; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.media.Content; | ||
| import io.swagger.v3.oas.annotations.media.ExampleObject; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
| import jakarta.validation.Valid; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.ErrorResponse; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @RestController | ||
| @RequestMapping("/api/somkathon/participants") | ||
| @RequiredArgsConstructor | ||
| public class SomParticipantController { | ||
|
|
||
| private final SomParticipantService somParticipantService; | ||
|
|
||
| /** | ||
| * 참가자 등록 | ||
| */ | ||
| @Operation(summary = "솜커톤 참가자 등록", description = "솜커톤 참가자를 등록합니다.") | ||
| @ApiResponses(value = { | ||
| @ApiResponse(responseCode = "200", description = "참가자 등록 성공"), | ||
| @ApiResponse(responseCode = "400", description = "중복 학번 또는 필수 값 누락", | ||
| content = @Content( | ||
| mediaType = "application/json", | ||
| schema = @Schema(implementation = ErrorResponse.class), | ||
| examples = { | ||
| @ExampleObject( | ||
| name = "중복된 학번", | ||
| value = "{ \"code\": \"C002\", \"message\": \"이미 등록된 학번입니다.\" }" | ||
| ), | ||
| @ExampleObject( | ||
| name = "필수 값 누락", | ||
| value = "{ \"code\": \"C001\", \"message\": \"요청한 값이 올바르지 않습니다.\" }" | ||
| )}))}) | ||
| @PostMapping("/create") | ||
| public ResponseEntity<SomParticipantResponseDto> create(@Valid @RequestBody final SomParticipantRequestDto request) { | ||
| final SomParticipantResponseDto responseDto = somParticipantService.createParticipant(request); | ||
| return ResponseEntity.ok(responseDto); | ||
hodoon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| /** | ||
| * 모든 참가자 조회 | ||
| */ | ||
| @Operation(summary = "솜커톤 참가자 목록 조회", description = "모든 솜커톤 참가자를 조회합니다.") | ||
| @ApiResponses(value = { | ||
| @ApiResponse(responseCode = "200", description = "참가자 목록 조회 성공")}) | ||
| @GetMapping | ||
| public ResponseEntity<List<SomParticipantResponseDto>> findAll() { | ||
| final List<SomParticipantResponseDto> participants = somParticipantService.getAllParticipants(); | ||
| return ResponseEntity.ok(participants); | ||
hodoon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| /** | ||
| * 특정 참가자 조회 | ||
| */ | ||
| @Operation(summary = "솜커톤 참가자 상세 조회", description = "특정 솜커톤 참가자의 상세 정보를 조회합니다.") | ||
| @ApiResponses(value = { | ||
| @ApiResponse(responseCode = "200", description = "참가자 상세 조회 성공"), | ||
| @ApiResponse(responseCode = "400", description = "존재하지 않는 ID", | ||
| content = @Content( | ||
| mediaType = "application/json", | ||
| schema = @Schema(implementation=ErrorResponse.class), | ||
| examples={ | ||
| @ExampleObject( | ||
| name="존재하지 않는 ID", | ||
| value="{\"code\":\"C004\",\"message\":\"참가자를 찾을 수 없습니다.\"}")}))}) | ||
| @GetMapping("/{id}") | ||
| public ResponseEntity<SomParticipantResponseDto> getById(@PathVariable final Long id) { | ||
| final SomParticipantResponseDto responseDto = somParticipantService.getParticipant(id); | ||
| return ResponseEntity.ok(responseDto); | ||
| } | ||
|
|
||
| /** | ||
| * 참가자 정보 수정 | ||
| */ | ||
| @Operation(summary = "솜커톤 참가자 정보 수정", description = "특정 솜커톤 참가자의 정보를 수정합니다.") | ||
| @ApiResponses(value = { | ||
| @ApiResponse(responseCode = "200", description = "참가자 정보 수정 성공"), | ||
| @ApiResponse(responseCode = "400", description = "중복 학번 또는 존재하지 않는 ID", | ||
| content = @Content( | ||
| mediaType = "application/json", | ||
| schema=@Schema(implementation=ErrorResponse.class), | ||
| examples={ | ||
| @ExampleObject( | ||
| name="중복된 학번", | ||
| value="{\"code\":\"C002\",\"message\":\"이미 등록된 학번입니다.\"}"), | ||
| @ExampleObject( | ||
| name="존재하지 않는 ID", | ||
| value="{\"code\":\"C004\",\"message\":\"참가자를 찾을 수 없습니다.\"}")}))}) | ||
| @PutMapping("/{id}") | ||
| public ResponseEntity<SomParticipantResponseDto> update(@PathVariable final Long id, | ||
| @Valid @RequestBody final SomParticipantRequestDto request) { | ||
| final SomParticipantResponseDto responseDto = somParticipantService.updateParticipant(id, request); | ||
| return ResponseEntity.ok(responseDto); | ||
| } | ||
|
|
||
| /** | ||
| * 참가자 삭제 (Delete) | ||
| */ | ||
| @Operation(summary = "솜커톤 참가자 삭제", description = "특정 솜커톤 참가자를 삭제합니다.") | ||
| @ApiResponses(value={ | ||
| @ApiResponse(responseCode="204",description="참가자 삭제 성공"), | ||
| @ApiResponse(responseCode="400",description="존재하지 않는 ID", | ||
| content=@Content( | ||
| mediaType="application/json", | ||
| schema=@Schema(implementation=ErrorResponse.class), | ||
| examples={ | ||
| @ExampleObject( | ||
| name="존재하지 않는 ID", | ||
| value="{\"code\":\"C004\",\"message\":\"참가자를 찾을 수 없습니다.\"}")}))}) | ||
| @DeleteMapping("/{id}") | ||
| public ResponseEntity<Void> delete(@PathVariable final Long id) { | ||
| somParticipantService.deleteParticipant(id); | ||
| return ResponseEntity.noContent().build(); | ||
| } | ||
|
|
||
| } | ||
15 changes: 15 additions & 0 deletions
15
src/main/java/dmu/dasom/api/domain/somkathon/dto/SomParticipantRequestDto.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package dmu.dasom.api.domain.somkathon.dto; | ||
|
|
||
| import lombok.Getter; | ||
| import lombok.Setter; | ||
|
|
||
| @Getter | ||
| @Setter | ||
| public class SomParticipantRequestDto { | ||
| private String participantName; // 참가자 이름 | ||
| private String studentId; | ||
| private String department; // 학과 | ||
| private String grade; // 학년 | ||
| private String contact; // 연락처 | ||
| private String email; // 이메일 | ||
hodoon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
21 changes: 21 additions & 0 deletions
21
src/main/java/dmu/dasom/api/domain/somkathon/dto/SomParticipantResponseDto.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package dmu.dasom.api.domain.somkathon.dto; | ||
|
|
||
| import dmu.dasom.api.domain.somkathon.entity.SomParticipant; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.Setter; | ||
|
|
||
| @Getter | ||
| @Setter | ||
| @Builder | ||
| public class SomParticipantResponseDto { | ||
| private Long id; // 참가자 ID | ||
| private String participantName; // 참가자 이름 | ||
| private String studentId; // 학번 | ||
| private String department; // 학과 | ||
| private String grade; // 학년 | ||
| private String contact; // 연락처 | ||
| private String email; // 이메일 | ||
hodoon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| } | ||
40 changes: 40 additions & 0 deletions
40
src/main/java/dmu/dasom/api/domain/somkathon/entity/SomParticipant.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| package dmu.dasom.api.domain.somkathon.entity; | ||
|
|
||
| import dmu.dasom.api.domain.common.BaseEntity; | ||
| import jakarta.persistence.*; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
|
||
| @AllArgsConstructor | ||
| @Builder | ||
| @Entity | ||
| @EntityListeners(AuditingEntityListener.class) | ||
| @Getter | ||
| @NoArgsConstructor | ||
| public class SomParticipant extends BaseEntity { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @Column(nullable = false) | ||
| private String participantName; // 참가자 이름 | ||
|
|
||
| @Column(nullable = false, unique = true) | ||
| private String studentId; // 학번 | ||
|
|
||
| @Column(nullable = false) | ||
| private String department; // 학과 | ||
|
|
||
| @Column(nullable = false) | ||
| private String grade; // 학년 | ||
|
|
||
| @Column(nullable = false) | ||
| private String contact; // 연락처 | ||
|
|
||
| @Column(nullable = false) | ||
| private String email; // 이메일 | ||
| } |
12 changes: 12 additions & 0 deletions
12
src/main/java/dmu/dasom/api/domain/somkathon/repository/SomParticipantRepository.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package dmu.dasom.api.domain.somkathon.repository; | ||
|
|
||
| import dmu.dasom.api.domain.somkathon.entity.SomParticipant; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| import java.util.Optional; | ||
|
|
||
| @Repository | ||
| public interface SomParticipantRepository extends JpaRepository<SomParticipant, Long> { | ||
| Optional<SomParticipant> findByStudentId(String studentId); // 학번으로 참가자 조회 | ||
| } |
101 changes: 101 additions & 0 deletions
101
src/main/java/dmu/dasom/api/domain/somkathon/service/SomParticipantService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,101 @@ | ||||||||||||||||||||||||||||||||
| package dmu.dasom.api.domain.somkathon.service; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| import dmu.dasom.api.domain.common.exception.CustomException; | ||||||||||||||||||||||||||||||||
| import dmu.dasom.api.domain.common.exception.ErrorCode; | ||||||||||||||||||||||||||||||||
| import dmu.dasom.api.domain.somkathon.dto.SomParticipantRequestDto; | ||||||||||||||||||||||||||||||||
| import dmu.dasom.api.domain.somkathon.dto.SomParticipantResponseDto; | ||||||||||||||||||||||||||||||||
| import dmu.dasom.api.domain.somkathon.entity.SomParticipant; | ||||||||||||||||||||||||||||||||
| import dmu.dasom.api.domain.somkathon.repository.SomParticipantRepository; | ||||||||||||||||||||||||||||||||
| import lombok.RequiredArgsConstructor; | ||||||||||||||||||||||||||||||||
| import org.springframework.stereotype.Service; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| import java.util.List; | ||||||||||||||||||||||||||||||||
| import java.util.stream.Collectors; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| @Service | ||||||||||||||||||||||||||||||||
| @RequiredArgsConstructor | ||||||||||||||||||||||||||||||||
| public class SomParticipantService { | ||||||||||||||||||||||||||||||||
hodoon marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||
| private final SomParticipantRepository somParticipantRepository; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // 참가자 등록 | ||||||||||||||||||||||||||||||||
| public SomParticipantResponseDto createParticipant(SomParticipantRequestDto requestDto) { | ||||||||||||||||||||||||||||||||
| if(somParticipantRepository.findByStudentId(requestDto.getStudentId()).isPresent()) { | ||||||||||||||||||||||||||||||||
hodoon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||
| throw new CustomException(ErrorCode.DUPLICATED_STUDENT_NO); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| SomParticipant participant = SomParticipant.builder() | ||||||||||||||||||||||||||||||||
| .participantName(requestDto.getParticipantName()) | ||||||||||||||||||||||||||||||||
| .studentId(requestDto.getStudentId()) | ||||||||||||||||||||||||||||||||
| .department(requestDto.getDepartment()) | ||||||||||||||||||||||||||||||||
| .grade(requestDto.getGrade()) | ||||||||||||||||||||||||||||||||
| .contact(requestDto.getContact()) | ||||||||||||||||||||||||||||||||
| .email(requestDto.getEmail()) | ||||||||||||||||||||||||||||||||
| .build(); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| SomParticipant saved = somParticipantRepository.save(participant); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| return toResponseDto(saved); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||
| * 모든 참가자 조회 (Read) | ||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||
| public List<SomParticipantResponseDto> getAllParticipants() { | ||||||||||||||||||||||||||||||||
| return somParticipantRepository.findAll().stream() | ||||||||||||||||||||||||||||||||
| .map(this::toResponseDto) | ||||||||||||||||||||||||||||||||
| .collect(Collectors.toList()); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||
| * 특정 참가자 조회 (Read) | ||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||
| public SomParticipantResponseDto getParticipant(Long id){ | ||||||||||||||||||||||||||||||||
| SomParticipant participant = somParticipantRepository.findById(id).orElseThrow(() -> new CustomException(ErrorCode.NOT_FOUND_PARTICIPANT)); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| return toResponseDto(participant); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| public SomParticipantResponseDto updateParticipant(Long id, SomParticipantRequestDto requestDto){ | ||||||||||||||||||||||||||||||||
| SomParticipant participant = somParticipantRepository.findById(id).orElseThrow(() -> new CustomException(ErrorCode.NOT_FOUND_PARTICIPANT)); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| participant = SomParticipant.builder() | ||||||||||||||||||||||||||||||||
| .id(participant.getId()) | ||||||||||||||||||||||||||||||||
| .participantName(requestDto.getParticipantName()) | ||||||||||||||||||||||||||||||||
| .studentId(requestDto.getStudentId()) | ||||||||||||||||||||||||||||||||
| .department(requestDto.getDepartment()) | ||||||||||||||||||||||||||||||||
| .grade(requestDto.getGrade()) | ||||||||||||||||||||||||||||||||
| .contact(requestDto.getContact()) | ||||||||||||||||||||||||||||||||
| .email(requestDto.getEmail()) | ||||||||||||||||||||||||||||||||
| .build(); | ||||||||||||||||||||||||||||||||
hodoon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
| participant = SomParticipant.builder() | |
| .id(participant.getId()) | |
| .participantName(requestDto.getParticipantName()) | |
| .studentId(requestDto.getStudentId()) | |
| .department(requestDto.getDepartment()) | |
| .grade(requestDto.getGrade()) | |
| .contact(requestDto.getContact()) | |
| .email(requestDto.getEmail()) | |
| .build(); | |
| participant.setParticipantName(requestDto.getParticipantName()); | |
| participant.setStudentId(requestDto.getStudentId()); | |
| participant.setDepartment(requestDto.getDepartment()); | |
| participant.setGrade(requestDto.getGrade()); | |
| participant.setContact(requestDto.getContact()); | |
| participant.setEmail(requestDto.getEmail()); |
hodoon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
hodoon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.