Skip to content
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

refactor: timetableV2 리펙토링 #1085

Merged
merged 10 commits into from
Nov 25, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import in.koreatech.koin.domain.timetableV2.dto.TimeTableLecturesDeleteRequest;
import in.koreatech.koin.domain.timetableV2.dto.TimetableFrameCreateRequest;
import in.koreatech.koin.domain.timetableV2.dto.TimetableFrameResponse;
import in.koreatech.koin.domain.timetableV2.dto.TimetableFrameUpdateRequest;
import in.koreatech.koin.domain.timetableV2.dto.TimetableFrameUpdateResponse;
import in.koreatech.koin.domain.timetableV2.dto.TimetableLectureCreateRequest;
import in.koreatech.koin.domain.timetableV2.dto.TimetableLectureResponse;
import in.koreatech.koin.domain.timetableV2.dto.TimetableLectureUpdateRequest;
import in.koreatech.koin.domain.timetableV2.dto.request.TimetableFrameCreateRequest;
import in.koreatech.koin.domain.timetableV2.dto.request.TimetableFrameUpdateRequest;
import in.koreatech.koin.domain.timetableV2.dto.request.TimetableLectureCreateRequest;
import in.koreatech.koin.domain.timetableV2.dto.request.TimetableLectureUpdateRequest;
import in.koreatech.koin.domain.timetableV2.dto.response.TimetableFrameResponse;
import in.koreatech.koin.domain.timetableV2.dto.response.TimetableFrameUpdateResponse;
import in.koreatech.koin.domain.timetableV2.dto.response.TimetableLectureResponse;
import in.koreatech.koin.global.auth.Auth;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
Expand Down Expand Up @@ -62,8 +61,8 @@ ResponseEntity<TimetableFrameResponse> createTimetablesFrame(
@SecurityRequirement(name = "Jwt Authentication")
@PutMapping("/v2/timetables/frame/{id}")
ResponseEntity<TimetableFrameUpdateResponse> updateTimetableFrame(
@Valid @RequestBody TimetableFrameUpdateRequest request,
@PathVariable(value = "id") Integer timetableFrameId,
@Valid @RequestBody TimetableFrameUpdateRequest timetableFrameUpdateRequest,
@Auth(permit = {STUDENT}) Integer userId
);

Expand Down Expand Up @@ -109,7 +108,7 @@ ResponseEntity<Void> deleteTimetablesFrame(
)
@Operation(summary = "시간표 프레임 모두 삭제")
@DeleteMapping("/v2/all/timetables/frame")
public ResponseEntity<Void> deleteAllTimetablesFrame(
ResponseEntity<Void> deleteAllTimetablesFrame(
@RequestParam(name = "semester") String semester,
@Auth(permit = {STUDENT}) Integer userId
);
Expand All @@ -122,11 +121,7 @@ public ResponseEntity<Void> deleteAllTimetablesFrame(
@ApiResponse(responseCode = "404", content = @Content(schema = @Schema(hidden = true)))
}
)
@Operation(summary = "시간표에 강의 정보 추가",
description = """
lecture_id가 있는 경우 class_title, class_time, professor은 null, grades는 '0'으로 입력해야합니다.\n
lecture_id가 없는 경우 class_title, class_time, professor, grades을 선택적으로 입력합니다.
""")
@Operation(summary = "시간표에 강의 정보 추가")
@SecurityRequirement(name = "Jwt Authentication")
@PostMapping("/v2/timetables/lecture")
ResponseEntity<TimetableLectureResponse> createTimetableLecture(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import in.koreatech.koin.domain.timetableV2.dto.TimeTableLecturesDeleteRequest;
import in.koreatech.koin.domain.timetableV2.dto.TimetableFrameCreateRequest;
import in.koreatech.koin.domain.timetableV2.dto.TimetableFrameResponse;
import in.koreatech.koin.domain.timetableV2.dto.TimetableFrameUpdateRequest;
import in.koreatech.koin.domain.timetableV2.dto.TimetableFrameUpdateResponse;
import in.koreatech.koin.domain.timetableV2.dto.TimetableLectureCreateRequest;
import in.koreatech.koin.domain.timetableV2.dto.TimetableLectureResponse;
import in.koreatech.koin.domain.timetableV2.dto.TimetableLectureUpdateRequest;
import in.koreatech.koin.domain.timetableV2.service.TimetableServiceV2;
import in.koreatech.koin.domain.timetableV2.dto.request.TimetableFrameCreateRequest;
import in.koreatech.koin.domain.timetableV2.dto.request.TimetableFrameUpdateRequest;
import in.koreatech.koin.domain.timetableV2.dto.request.TimetableLectureCreateRequest;
import in.koreatech.koin.domain.timetableV2.dto.request.TimetableLectureUpdateRequest;
import in.koreatech.koin.domain.timetableV2.dto.response.TimetableFrameResponse;
import in.koreatech.koin.domain.timetableV2.dto.response.TimetableFrameUpdateResponse;
import in.koreatech.koin.domain.timetableV2.dto.response.TimetableLectureResponse;
import in.koreatech.koin.domain.timetableV2.service.TimetableFrameService;
import in.koreatech.koin.domain.timetableV2.service.TimetableLectureService;
import in.koreatech.koin.global.auth.Auth;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
Expand All @@ -31,43 +31,43 @@
@RequiredArgsConstructor
public class TimetableControllerV2 implements TimetableApiV2 {

private final TimetableServiceV2 timetableServiceV2;
private final TimetableFrameService frameServiceV2;
private final TimetableLectureService lectureServiceV2;

@PostMapping("/v2/timetables/frame")
public ResponseEntity<TimetableFrameResponse> createTimetablesFrame(
@Valid @RequestBody TimetableFrameCreateRequest request,
@Auth(permit = {STUDENT}) Integer userId
) {
TimetableFrameResponse response = timetableServiceV2.createTimetablesFrame(userId, request);
TimetableFrameResponse response = frameServiceV2.createTimetablesFrame(userId, request);
return ResponseEntity.ok(response);
}

@PutMapping("/v2/timetables/frame/{id}")
public ResponseEntity<TimetableFrameUpdateResponse> updateTimetableFrame(
@Valid @RequestBody TimetableFrameUpdateRequest request,
@PathVariable(value = "id") Integer timetableFrameId,
@Valid @RequestBody TimetableFrameUpdateRequest timetableFrameUpdateRequest,
@Auth(permit = {STUDENT}) Integer userId
) {
TimetableFrameUpdateResponse timetableFrameUpdateResponse =
timetableServiceV2.updateTimetableFrame(timetableFrameId, timetableFrameUpdateRequest, userId);
return ResponseEntity.ok(timetableFrameUpdateResponse);
TimetableFrameUpdateResponse response = frameServiceV2.updateTimetableFrame(request, timetableFrameId, userId);
return ResponseEntity.ok(response);
}

@GetMapping("/v2/timetables/frames")
public ResponseEntity<List<TimetableFrameResponse>> getTimetablesFrame(
@RequestParam(name = "semester") String semester,
@Auth(permit = {STUDENT}) Integer userId
) {
List<TimetableFrameResponse> timeTableFrameResponse = timetableServiceV2.getTimetablesFrame(userId, semester);
return ResponseEntity.ok(timeTableFrameResponse);
List<TimetableFrameResponse> response = frameServiceV2.getTimetablesFrame(userId, semester);
return ResponseEntity.ok(response);
}

@DeleteMapping("/v2/timetables/frame")
public ResponseEntity<Void> deleteTimetablesFrame(
@RequestParam(name = "id") Integer frameId,
@Auth(permit = {STUDENT}) Integer userId
) {
timetableServiceV2.deleteTimetablesFrame(userId, frameId);
frameServiceV2.deleteTimetablesFrame(userId, frameId);
return ResponseEntity.noContent().build();
}

Expand All @@ -76,7 +76,7 @@ public ResponseEntity<Void> deleteAllTimetablesFrame(
@RequestParam(name = "semester") String semester,
@Auth(permit = {STUDENT}) Integer userId
) {
timetableServiceV2.deleteAllTimetablesFrame(userId, semester);
frameServiceV2.deleteAllTimetablesFrame(userId, semester);
return ResponseEntity.noContent().build();
}

Expand All @@ -85,36 +85,34 @@ public ResponseEntity<TimetableLectureResponse> createTimetableLecture(
@Valid @RequestBody TimetableLectureCreateRequest request,
@Auth(permit = {STUDENT}) Integer userId
) {
TimetableLectureResponse timeTableLectureResponse = timetableServiceV2.createTimetableLectures(userId, request);
return ResponseEntity.ok(timeTableLectureResponse);
TimetableLectureResponse response = lectureServiceV2.createTimetableLectures(userId, request);
return ResponseEntity.ok(response);
}

@PutMapping("/v2/timetables/lecture")
public ResponseEntity<TimetableLectureResponse> updateTimetableLecture(
@Valid @RequestBody TimetableLectureUpdateRequest request,
@Auth(permit = {STUDENT}) Integer userId
) {
TimetableLectureResponse timetableLectureResponse = timetableServiceV2.updateTimetablesLectures(userId,
request);
return ResponseEntity.ok(timetableLectureResponse);
TimetableLectureResponse response = lectureServiceV2.updateTimetablesLectures(userId, request);
return ResponseEntity.ok(response);
}

@GetMapping("/v2/timetables/lecture")
public ResponseEntity<TimetableLectureResponse> getTimetableLecture(
@RequestParam(name = "timetable_frame_id") Integer timetableFrameId,
@Auth(permit = {STUDENT}) Integer userId
) {
TimetableLectureResponse timetableLectureResponse = timetableServiceV2.getTimetableLectures(userId,
timetableFrameId);
return ResponseEntity.ok(timetableLectureResponse);
TimetableLectureResponse response = lectureServiceV2.getTimetableLectures(userId, timetableFrameId);
return ResponseEntity.ok(response);
}

@DeleteMapping("/v2/timetables/lecture/{id}")
public ResponseEntity<Void> deleteTimetableLecture(
@PathVariable(value = "id") Integer timetableLectureId,
@Auth(permit = {STUDENT}) Integer userId
) {
timetableServiceV2.deleteTimetableLecture(userId, timetableLectureId);
lectureServiceV2.deleteTimetableLecture(userId, timetableLectureId);
return ResponseEntity.noContent().build();
}

Expand All @@ -123,7 +121,7 @@ public ResponseEntity<Void> deleteTimetableLectures(
@RequestParam(name = "timetable_lecture_ids") List<Integer> request,
@Auth(permit = {STUDENT}) Integer userId
) {
timetableServiceV2.deleteTimetableLectures(request, userId);
lectureServiceV2.deleteTimetableLectures(request, userId);
return ResponseEntity.noContent().build();
}

Expand All @@ -133,7 +131,7 @@ public ResponseEntity<Void> deleteTimetableLectureByFrameId(
@PathVariable(value = "lectureId") Integer lectureId,
@Auth(permit = {STUDENT}) Integer userId
) {
timetableServiceV2.deleteTimetableLectureByFrameId(frameId, lectureId, userId);
lectureServiceV2.deleteTimetableLectureByFrameId(frameId, lectureId, userId);
return ResponseEntity.noContent().build();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package in.koreatech.koin.domain.timetableV2.dto;
package in.koreatech.koin.domain.timetableV2.dto.request;

import static com.fasterxml.jackson.databind.PropertyNamingStrategies.*;
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.NOT_REQUIRED;
Expand All @@ -12,7 +12,7 @@
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;

@JsonNaming(SnakeCaseStrategy.class)
@JsonNaming(value = SnakeCaseStrategy.class)
public record TimetableFrameCreateRequest(
@Schema(description = "학기 정보", example = "20192", requiredMode = REQUIRED)
@NotBlank(message = "학기 정보를 입력해주세요")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package in.koreatech.koin.domain.timetableV2.dto;
package in.koreatech.koin.domain.timetableV2.dto.request;

import static com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy;
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package in.koreatech.koin.domain.timetableV2.dto;
package in.koreatech.koin.domain.timetableV2.dto.request;

import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.NOT_REQUIRED;
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package in.koreatech.koin.domain.timetableV2.dto;
package in.koreatech.koin.domain.timetableV2.dto.request;

import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.NOT_REQUIRED;
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package in.koreatech.koin.domain.timetableV2.dto;
package in.koreatech.koin.domain.timetableV2.dto.response;

import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package in.koreatech.koin.domain.timetableV2.dto;
package in.koreatech.koin.domain.timetableV2.dto.response;

import static com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy;
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
Expand All @@ -19,11 +19,11 @@ public record TimetableFrameUpdateResponse(
@Schema(description = "메인 시간표 여부", example = "false", requiredMode = REQUIRED)
Boolean isMain
) {

public static TimetableFrameUpdateResponse from(TimetableFrame timetableFrame) {
return new TimetableFrameUpdateResponse(
timetableFrame.getId(),
timetableFrame.getName(),
timetableFrame.isMain());
timetableFrame.isMain()
);
}
}
Loading
Loading