Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public class CertificateFacade {
private final GraduationUserQueryService graduationUserQueryService;
private final GraduationUserCommandService graduationUserCommandService;

public Long submitCertificate(MultipartFile file, Long scheduleId) {
Long certificateId = certificateCommandService.submitCertificate(file,scheduleId);
public Long submitCertificate(MultipartFile file) {
Long certificateId = certificateCommandService.submitCertificate(file);
GraduationUser graduationUser = graduationUserQueryService.me();
graduationUserCommandService.updateCertificate(graduationUser, certificateId);
return certificateId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
package kgu.developers.api.certificate.presentation;

import static org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import kgu.developers.api.certificate.presentation.request.CertificateSubmitRequest;
import kgu.developers.api.certificate.presentation.response.CertificatePersistResponse;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import static org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE;

@Tag(name = "Certificate", description = "자격증 관련 API")
public interface CertificateController {
Expand All @@ -32,7 +30,6 @@ ResponseEntity<CertificatePersistResponse> submitCertificateAndSaveFile(
description = "자격증 첨부 파일",
content = @Content(mediaType = MULTIPART_FORM_DATA_VALUE),
required = true
) @RequestPart(value = "file") MultipartFile file,
@RequestPart CertificateSubmitRequest request
) @RequestPart(value = "file") MultipartFile file
);
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package kgu.developers.api.certificate.presentation;

import static org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE;

import kgu.developers.api.certificate.application.CertificateFacade;
import kgu.developers.api.certificate.presentation.response.CertificatePersistResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import kgu.developers.api.certificate.presentation.request.CertificateSubmitRequest;
import kgu.developers.api.certificate.presentation.response.CertificatePersistResponse;
import lombok.RequiredArgsConstructor;
import static org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE;

@RestController
@RequestMapping("/api/v1/certificate")
Expand All @@ -20,10 +21,9 @@ public class CertificateControllerImpl implements CertificateController {
@Override
@PostMapping(consumes = MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<CertificatePersistResponse> submitCertificateAndSaveFile(
@RequestPart(value = "file") MultipartFile file,
@RequestPart CertificateSubmitRequest request
@RequestPart(value = "file") MultipartFile file
) {
Long id = certificateFacade.submitCertificate(file, request.scheduleId());
Long id = certificateFacade.submitCertificate(file);
return ResponseEntity.ok(
CertificatePersistResponse.of(id)
);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import kgu.developers.domain.graduationUser.domain.GraduationUser;
import kgu.developers.domain.schedule.application.query.ScheduleQueryService;
import kgu.developers.domain.schedule.domain.Schedule;
import kgu.developers.domain.schedule.domain.SubmissionType;
import kgu.developers.domain.thesis.application.command.ThesisCommandService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
Expand All @@ -19,13 +20,11 @@ public class ThesisFacade {
private final ScheduleQueryService scheduleQueryService;
private final GraduationUserCommandService graduationUserCommandService;

public Long submitThesis(MultipartFile file, Long scheduleId) {
Long thesisId = thesisCommandService.submitThesis(file,scheduleId);
public Long submitThesis(MultipartFile file, SubmissionType thesisType) {
Long thesisId = thesisCommandService.submitThesis(file,thesisType);
GraduationUser graduationUser = graduationUserQueryService.me();

Schedule schedule = scheduleQueryService.getScheduleManagement(scheduleId);

graduationUserCommandService.updateThesis(graduationUser, thesisId, schedule);
graduationUserCommandService.updateThesis(graduationUser, thesisId, thesisType);
return thesisId;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public ResponseEntity<ThesisPersistResponse> submitThesisAndSaveFile(
@RequestPart(value = "file") MultipartFile file,
@RequestPart ThesisSubmitRequest request
) {
Long id = thesisFacade.submitThesis(file, request.scheduleId());
Long id = thesisFacade.submitThesis(file, request.type());
return ResponseEntity.ok(
ThesisPersistResponse.of(id)
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package kgu.developers.api.thesis.presentation.request;

import jakarta.validation.constraints.NotNull;
import kgu.developers.domain.schedule.domain.SubmissionType;

public record ThesisSubmitRequest(
@NotNull(message = "졸업 논문 일정 id는 필수입니다.")
Long scheduleId
@NotNull(message = "졸업 논문 유형은 필수입니다.")
SubmissionType type
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import kgu.developers.domain.graduationUser.domain.GraduationUser;
import kgu.developers.domain.schedule.application.query.ScheduleQueryService;
import kgu.developers.domain.schedule.domain.Schedule;
import kgu.developers.domain.schedule.domain.SubmissionType;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -30,8 +31,8 @@ public class CertificateCommandService {
private final ScheduleQueryService scheduleQueryService;
private final GraduationUserQueryService graduationUserQueryService;

public Long submitCertificate(MultipartFile file, Long scheduleId) {
Schedule schedule = scheduleQueryService.getScheduleManagement(scheduleId);
public Long submitCertificate(MultipartFile file) {
Schedule schedule = scheduleQueryService.getBySubmissionType(SubmissionType.CERTIFICATE);

GraduationUser graduationUser = graduationUserQueryService.me();

Expand All @@ -48,7 +49,7 @@ public Long submitCertificate(MultipartFile file, Long scheduleId) {
String storedPath = fileStorageService.store(file, FileDomain.CERTIFICATE);
Long fileId = fileCommandService.saveFile(file, storedPath).getId();

Certificate certificate = Certificate.create(scheduleId, fileId);
Certificate certificate = Certificate.create(schedule.getId(), fileId);
return certificateRepository.save(certificate);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import kgu.developers.domain.graduationUser.domain.GraduationUser;
import kgu.developers.domain.graduationUser.domain.GraduationUserRepository;
import kgu.developers.domain.graduationUser.exception.GraduationUserIdDuplicateException;
import kgu.developers.domain.schedule.domain.Schedule;
import kgu.developers.domain.schedule.domain.SubmissionType;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand Down Expand Up @@ -48,8 +48,8 @@ public void updateCertificate(GraduationUser graduationUser, Long certificateId)
graduationUserRepository.save(graduationUser);
}

public void updateThesis(GraduationUser graduationUser, Long thesisId, Schedule schedule) {
switch (schedule.getSubmissionType()) {
public void updateThesis(GraduationUser graduationUser, Long thesisId, SubmissionType thesisType) {
switch (thesisType) {
case MIDTHESIS -> graduationUser.updateMidThesisId(thesisId);
case FINALTHESIS -> graduationUser.updateFinalThesisId(thesisId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
import kgu.developers.domain.graduationUser.domain.GraduationUser;
import kgu.developers.domain.schedule.application.query.ScheduleQueryService;
import kgu.developers.domain.schedule.domain.Schedule;
import kgu.developers.domain.schedule.domain.SubmissionType;
import kgu.developers.domain.thesis.domain.Thesis;
import kgu.developers.domain.thesis.domain.ThesisRepository;
import kgu.developers.domain.thesis.exception.ThesisInvalidGraduationTypeException;
import kgu.developers.domain.thesis.exception.ThesisInvalidSubmissionTypeException;
import kgu.developers.domain.thesis.exception.ThesisNotFoundException;
import kgu.developers.domain.thesis.exception.ThesisNotInSubmissionPeriodException;
import lombok.RequiredArgsConstructor;
Expand All @@ -30,8 +32,13 @@ public class ThesisCommandService {
private final ScheduleQueryService scheduleQueryService;
private final GraduationUserQueryService graduationUserQueryService;

public Long submitThesis(MultipartFile file, Long scheduleId) {
Schedule schedule = scheduleQueryService.getScheduleManagement(scheduleId);
public Long submitThesis(MultipartFile file, SubmissionType thesisType) {

if(thesisType != SubmissionType.MIDTHESIS && thesisType != SubmissionType.FINALTHESIS) {
throw new ThesisInvalidSubmissionTypeException();
}

Schedule schedule = scheduleQueryService.getBySubmissionType(thesisType);
LocalDateTime referenceTime = LocalDateTime.now();

GraduationUser graduationUser = graduationUserQueryService.me();
Expand All @@ -47,7 +54,7 @@ public Long submitThesis(MultipartFile file, Long scheduleId) {
String storedPath = fileStorageService.store(file, FileDomain.THESIS);
Long fileId = fileCommandService.saveFile(file, storedPath).getId();

Thesis thesis = Thesis.create(scheduleId, fileId);
Thesis thesis = Thesis.create(schedule.getId(), fileId);
return thesisRepository.save(thesis);
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public enum ThesisDomainExceptionCode implements ExceptionCode {
THESIS_NOT_FOUND(BAD_REQUEST, "해당 논문을 찾을 수 없습니다."),
THESIS_NOT_IN_SUBMISSION_PERIOD_EXCEPTION(BAD_REQUEST, "현재 논문 제출 기간이 아닙니다."),
THESIS_INVALID_GRADUATION_TYPE_EXCEPTION(BAD_REQUEST, "선택하신 제출 방식이 논문이 아닙니다."),
THESIS_INVALID_SUBMISSION_TYPE_EXCEPTION(BAD_REQUEST, "요청하신 제출 유형이 논문이 아닙니다."),
;

private final HttpStatus status;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package kgu.developers.domain.thesis.exception;

import kgu.developers.common.exception.CustomException;

import static kgu.developers.domain.thesis.exception.ThesisDomainExceptionCode.THESIS_INVALID_SUBMISSION_TYPE_EXCEPTION;

public class ThesisInvalidSubmissionTypeException extends CustomException {
public ThesisInvalidSubmissionTypeException() {
super(THESIS_INVALID_SUBMISSION_TYPE_EXCEPTION);
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package carousel.application;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import kgu.developers.domain.carousel.application.command.CarouselCommandService;
import kgu.developers.domain.carousel.domain.Carousel;
import kgu.developers.domain.file.application.query.FileQueryService;
import kgu.developers.domain.file.domain.FileModel;
import mock.repository.FakeCarouselRepository;
import mock.repository.FakeFileRepository;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

public class CarouselCommandServiceTest {
private CarouselCommandService carouselCommandService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package carousel.application;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.List;

import kgu.developers.domain.carousel.application.query.CarouselQueryService;
import kgu.developers.domain.carousel.domain.Carousel;
import mock.repository.FakeCarouselRepository;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import kgu.developers.domain.carousel.application.query.CarouselQueryService;
import kgu.developers.domain.carousel.domain.Carousel;
import mock.repository.FakeCarouselRepository;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class CarouselQueryServiceTest {
private CarouselQueryService carouselQueryService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ public void updateThesis_Success() {
.build();

//when
graduationUserCommandService.updateThesis(graduationUser, midThesisId, midSchedule);
graduationUserCommandService.updateThesis(graduationUser, finalThesisId, finalSchedule);
graduationUserCommandService.updateThesis(graduationUser, midThesisId, SubmissionType.MIDTHESIS);
graduationUserCommandService.updateThesis(graduationUser, finalThesisId, SubmissionType.FINALTHESIS);

//then
assertEquals(graduationUser.getMidThesisId(), midThesisId);
Expand Down