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 @@ -36,6 +36,7 @@ public enum ErrorCode {
SLOT_NOT_ACTIVE(400, "C027", "해당 슬롯이 비활성화 되었습니다."),
FILE_ENCODE_FAIL(400, "C028", "파일 인코딩에 실패하였습니다."),
RECRUITMENT_NOT_ACTIVE(400, "C029", "모집 기간이 아닙니다."),
NOT_FOUND_PARTICIPANT(400, "C030", "참가자를 찾을 수 없습니다.")
;

private final int status;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dmu.dasom.api.domain.interview.repositoty;
package dmu.dasom.api.domain.interview.repository;

import dmu.dasom.api.domain.interview.entity.InterviewReservation;
import org.springframework.data.jpa.repository.JpaRepository;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dmu.dasom.api.domain.interview.repositoty;
package dmu.dasom.api.domain.interview.repository;

import dmu.dasom.api.domain.interview.entity.InterviewSlot;
import dmu.dasom.api.domain.interview.enums.InterviewStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import dmu.dasom.api.domain.interview.entity.InterviewReservation;
import dmu.dasom.api.domain.interview.entity.InterviewSlot;
import dmu.dasom.api.domain.interview.enums.InterviewStatus;
import dmu.dasom.api.domain.interview.repositoty.InterviewReservationRepository;
import dmu.dasom.api.domain.interview.repositoty.InterviewSlotRepository;
import dmu.dasom.api.domain.interview.repository.InterviewReservationRepository;
import dmu.dasom.api.domain.interview.repository.InterviewSlotRepository;
import dmu.dasom.api.domain.recruit.service.RecruitServiceImpl;
import jakarta.persistence.EntityListeners;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
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.validation.annotation.Validated;
import org.springframework.web.ErrorResponse;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/somkathon/participants")
@RequiredArgsConstructor
@Validated
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) {
return ResponseEntity.ok(somParticipantService.createParticipant(request));
}

/**
* 모든 참가자 조회
*/
@Operation(summary = "솜커톤 참가자 목록 조회", description = "모든 솜커톤 참가자를 조회합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "참가자 목록 조회 성공")})
@GetMapping
public ResponseEntity<List<SomParticipantResponseDto>> findAll() {
return ResponseEntity.ok(somParticipantService.getAllParticipants());
}

/**
* 특정 참가자 조회
*/
@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) {
return ResponseEntity.ok(somParticipantService.getParticipant(id));
}

/**
* 참가자 정보 수정
*/
@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) {
return ResponseEntity.ok(somParticipantService.updateParticipant(id, request));
}

/**
* 참가자 삭제 (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();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package dmu.dasom.api.domain.somkathon.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@Schema(description = "솜커톤 참가자 요청 DTO")
public class SomParticipantRequestDto {
@NotBlank(message = "참가자 이름은 필수 입력 값입니다.")
@Size(max = 50, message = "참가자 이름은 최대 50자까지 입력 가능합니다.")
@Schema(description = "참가자 이름", example = "유승완", required = true)
private String participantName; // 참가자 이름

@NotBlank(message = "학번은 필수 입력 값입니다.")
@Pattern(regexp = "^[0-9]{8}$", message = "학번은 8자리 숫자여야 합니다.")
@Schema(description = "학번 (8자리 숫자)", example = "20250001", required = true)
private String studentId;

@NotBlank(message = "학과는 필수 입력 값입니다.")
@Size(max = 100, message = "학과는 최대 100자까지 입력 가능합니다.")
@Schema(description = "학과", example = "컴퓨터소프트웨어공학과", required = true)
private String department; // 학과

@NotBlank(message = "학년은 필수 입력 값입니다.")
@Pattern(regexp = "^[1-4]$", message = "학년은 1~4 사이의 숫자여야 합니다.")
@Schema(description = "학년 (1~4)", example = "3", required = true)
private String grade; // 학년

@NotBlank(message = "연락처는 필수 입력 값입니다.")
@Pattern(regexp = "^010-[0-9]{4}-[0-9]{4}$", message = "연락처는 '010-XXXX-XXXX' 형식이어야 합니다.")
@Schema(description = "연락처 (010-XXXX-XXXX 형식)", example = "010-1234-5678", required = true)
private String contact; // 연락처

@NotBlank(message = "이메일은 필수 입력 값입니다.")
@Email(message = "올바른 이메일 형식이 아닙니다.")
@Schema(description = "이메일 주소", example = "[email protected]", required = true)
private String email; // 이메일
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package dmu.dasom.api.domain.somkathon.dto;

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 {

@Schema(description = "참가자 ID", example = "1", required = true)
private Long id; // 참가자 ID

@Schema(description = "참가자 이름", example = "홍길동", required = true)
private String participantName; // 참가자 이름

@Schema(description = "학번 (8자리 숫자)", example = "20230001", required = true)
private String studentId; // 학번

@Schema(description = "학과", example = "컴퓨터공학과", required = true)
private String department; // 학과

@Schema(description = "학년 (1~4)", example = "3", required = true)
private String grade; // 학년

@Schema(description = "연락처 (010-XXXX-XXXX 형식)", example = "010-1234-5678", required = true)
private String contact; // 연락처

@Schema(description = "이메일 주소", example = "[email protected]", required = true)
private String email; // 이메일
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package dmu.dasom.api.domain.somkathon.entity;

import dmu.dasom.api.domain.common.BaseEntity;
import dmu.dasom.api.domain.somkathon.dto.SomParticipantRequestDto;
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; // 이메일

public void update(SomParticipantRequestDto requestDto) {
this.participantName = requestDto.getParticipantName();
this.studentId = requestDto.getStudentId();
this.department = requestDto.getDepartment();
this.grade = requestDto.getGrade();
this.contact = requestDto.getContact();
this.email = requestDto.getEmail();
}
}
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); // 학번으로 참가자 조회
}
Loading