Skip to content

Commit c8753ea

Browse files
authored
Merge branch 'develop' into refactor/2053-admin-history
2 parents e140dd0 + d6a6e3b commit c8753ea

File tree

11 files changed

+167
-227
lines changed

11 files changed

+167
-227
lines changed

src/main/java/in/koreatech/koin/domain/graduation/controller/GraduationApi.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import in.koreatech.koin.domain.graduation.dto.GraduationCourseCalculationResponse;
1616
import in.koreatech.koin.domain.graduation.model.GeneralEducationArea;
1717
import in.koreatech.koin.global.auth.Auth;
18-
import in.koreatech.koin.global.validation.FileTypeValid;
1918
import io.swagger.v3.oas.annotations.Operation;
2019
import io.swagger.v3.oas.annotations.media.Content;
2120
import io.swagger.v3.oas.annotations.media.Schema;
@@ -54,7 +53,7 @@ ResponseEntity<Void> createStudentCourseCalculation(
5453
@SecurityRequirement(name = "Jwt Authentication")
5554
@PostMapping("/graduation/excel/upload")
5655
ResponseEntity<String> uploadStudentGradeExcelFile(
57-
@FileTypeValid(extensions = {"xls", "xlsx"}) @RequestParam(value = "file") MultipartFile file,
56+
@RequestParam(value = "file") MultipartFile file,
5857
@Auth(permit = {STUDENT}) Integer userId
5958
);
6059

src/main/java/in/koreatech/koin/domain/graduation/controller/GraduationController.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
package in.koreatech.koin.domain.graduation.controller;
22

3-
import static in.koreatech.koin.domain.user.model.UserType.COUNCIL;
4-
import static in.koreatech.koin.domain.user.model.UserType.STUDENT;
5-
63
import java.io.IOException;
74
import java.util.List;
85

6+
import static in.koreatech.koin.domain.user.model.UserType.COUNCIL;
7+
import static in.koreatech.koin.domain.user.model.UserType.STUDENT;
8+
99
import org.springframework.http.ResponseEntity;
10-
import org.springframework.validation.annotation.Validated;
1110
import org.springframework.web.bind.annotation.GetMapping;
1211
import org.springframework.web.bind.annotation.PostMapping;
1312
import org.springframework.web.bind.annotation.RequestParam;
@@ -21,10 +20,8 @@
2120
import in.koreatech.koin.domain.graduation.service.GraduationService;
2221
import in.koreatech.koin.domain.user.model.UserType;
2322
import in.koreatech.koin.global.auth.Auth;
24-
import in.koreatech.koin.global.validation.FileTypeValid;
2523
import lombok.RequiredArgsConstructor;
2624

27-
@Validated
2825
@RestController
2926
@RequiredArgsConstructor
3027
public class GraduationController implements GraduationApi {
@@ -40,7 +37,7 @@ public ResponseEntity<Void> createStudentCourseCalculation(
4037

4138
@PostMapping("/graduation/excel/upload")
4239
public ResponseEntity<String> uploadStudentGradeExcelFile(
43-
@FileTypeValid(extensions = {"xls", "xlsx"}) @RequestParam(value = "file") MultipartFile file,
40+
@RequestParam(value = "file") MultipartFile file,
4441
@Auth(permit = {UserType.STUDENT}) Integer userId
4542
) {
4643
try {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package in.koreatech.koin.domain.graduation.exception;
2+
3+
import in.koreatech.koin.global.exception.custom.DataNotFoundException;
4+
5+
public class ExcelFileCheckException extends DataNotFoundException {
6+
private static final String DEFAULT_MESSAGE = "엑셀 파일 형식이 아닙니다.";
7+
8+
public ExcelFileCheckException(String message) {
9+
super(message);
10+
}
11+
12+
public ExcelFileCheckException(String message, String detail) {
13+
super(message, detail);
14+
}
15+
16+
public static ExcelFileCheckException withDetail(String detail) {
17+
return new ExcelFileCheckException(DEFAULT_MESSAGE, detail);
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package in.koreatech.koin.domain.graduation.exception;
2+
3+
import in.koreatech.koin.global.exception.custom.DataNotFoundException;
4+
5+
public class ExcelFileNotFoundException extends DataNotFoundException {
6+
private static final String DEFAULT_MESSAGE = "엑셀 파일을 찾을 수 없습니다.";
7+
8+
public ExcelFileNotFoundException(String message) {
9+
super(message);
10+
}
11+
12+
public ExcelFileNotFoundException(String message, String detail) {
13+
super(message, detail);
14+
}
15+
16+
public static ExcelFileNotFoundException withDetail(String detail) {
17+
return new ExcelFileNotFoundException(DEFAULT_MESSAGE, detail);
18+
}
19+
}
Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package in.koreatech.koin.domain.graduation.model;
22

3-
import static in.koreatech.koin.global.code.ApiResponseCode.INVALID_SEMESTER_REGEX;
4-
5-
import in.koreatech.koin.global.exception.CustomException;
3+
import org.apache.poi.ss.usermodel.Cell;
4+
import org.apache.poi.ss.usermodel.Row;
65

76
public record GradeExcelData(
87
String year,
@@ -16,32 +15,29 @@ public record GradeExcelData(
1615
String grade,
1716
String retakeStatus
1817
) {
19-
20-
private static final String MIDDLE_TOTAL = "소 계";
21-
private static final String FAIL = "F";
22-
private static final String UNSATISFACTORY = "U";
23-
private static final String TOTAL = "합 계";
24-
private static final String FIRST_SEMESTER = "1";
25-
private static final String SECOND_SEMESTER = "2";
26-
private static final String SUMMER_SEMESTER = "하계";
27-
private static final String WINTER_SEMESTER = "동계";
28-
29-
public boolean isSkipRow() {
30-
return classTitle.equals(MIDDLE_TOTAL) ||
31-
grade.equals(FAIL) ||
32-
grade.equals(UNSATISFACTORY);
33-
}
34-
35-
public boolean isTotalRow() {
36-
return classTitle.equals(TOTAL);
18+
public static GradeExcelData fromRow(Row row) {
19+
return new GradeExcelData(
20+
getCellValueAsString(row.getCell(1)),
21+
getCellValueAsString(row.getCell(2)),
22+
getCellValueAsString(row.getCell(4)),
23+
getCellValueAsString(row.getCell(5)),
24+
getCellValueAsString(row.getCell(6)),
25+
getCellValueAsString(row.getCell(7)),
26+
getCellValueAsString(row.getCell(8)),
27+
getCellValueAsString(row.getCell(9)),
28+
getCellValueAsString(row.getCell(10)),
29+
getCellValueAsString(row.getCell(11))
30+
);
3731
}
3832

39-
public String getKoinSemester() {
40-
return switch (semester) {
41-
case FIRST_SEMESTER, SECOND_SEMESTER -> year + semester;
42-
case WINTER_SEMESTER -> year + "-" + "겨울";
43-
case SUMMER_SEMESTER -> year + "-" + "여름";
44-
default -> throw CustomException.of(INVALID_SEMESTER_REGEX);
33+
private static String getCellValueAsString(Cell cell) {
34+
if (cell == null) {
35+
return "";
36+
}
37+
return switch (cell.getCellType()) {
38+
case STRING -> cell.getStringCellValue();
39+
case NUMERIC -> String.valueOf((int)cell.getNumericCellValue());
40+
default -> "";
4541
};
4642
}
4743
}

src/main/java/in/koreatech/koin/domain/graduation/service/GraduationExcelService.java

Lines changed: 0 additions & 68 deletions
This file was deleted.

0 commit comments

Comments
 (0)