Skip to content

Commit ed270a9

Browse files
authored
Merge pull request #13 from enjoy-hack/Daeun
Feat : 유저 API 추가
2 parents 8e9a256 + 04bac06 commit ed270a9

File tree

9 files changed

+134
-242
lines changed

9 files changed

+134
-242
lines changed

build.gradle

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ configurations {
2121

2222
repositories {
2323
mavenCentral()
24+
maven {
25+
name = 'chuseok22NexusRelease'
26+
url = uri('https://nexus.chuseok22.com/repository/maven-releases/')
27+
metadataSources {
28+
mavenPom()
29+
artifact()
30+
}
31+
}
2432
}
2533

2634
dependencies {
@@ -52,6 +60,12 @@ dependencies {
5260
// Jsoup (HTML 파싱)
5361
implementation 'org.jsoup:jsoup:1.18.1'
5462

63+
developmentOnly 'org.springframework.boot:spring-boot-devtools'
64+
annotationProcessor 'org.projectlombok:lombok'
65+
testImplementation 'org.springframework.boot:spring-boot-starter-test'
66+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
67+
implementation 'com.chuseok22:sejong-portal-login:1.0.0'
68+
5569
}
5670

5771
tasks.named('test') {

src/main/java/com/example/enjoy/controller/LoginController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class LoginController {
2929
public ResponseEntity<MemberDto> loginAndGetUserInfo(@RequestBody @Valid MemberCommand command) {
3030
try {
3131
log.info("세종대 포털 로그인 요청: {}", command.getSejongPortalId());
32-
MemberDto memberInfo = sejongLoginService.getMemberAuthInfos(command);
32+
MemberDto memberInfo = sejongLoginService.login(command);
3333
log.info("사용자 정보 조회 성공: {}", memberInfo.getStudentName());
3434
return ResponseEntity.ok(memberInfo);
3535
} catch (Exception e) {

src/main/java/com/example/enjoy/controller/UserController.java

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.example.enjoy.controller;
22

33
import com.example.enjoy.dto.AddManualCourseRequest;
4+
import com.example.enjoy.dto.StudentCourseResponse;
45
import com.example.enjoy.dto.StudentCourseStatus;
56
import com.example.enjoy.dto.loginDto.MemberCommand;
67
import com.example.enjoy.dto.loginDto.MemberDto;
@@ -31,7 +32,7 @@ public UserController(SejongLoginService sejongLoginService, UserService userSer
3132
}
3233

3334
@Operation(summary = "학생 정보 조회", description = "세종대학교 포털 인증을 통해 학생 정보를 조회합니다.")
34-
@GetMapping("/detail")
35+
@PostMapping("/detail")
3536
public ResponseEntity<MemberDto> getStudentDetail(@RequestBody MemberCommand command) throws IOException {
3637
MemberDto memberInfo = sejongLoginService.getMemberAuthInfos(command);
3738
return ResponseEntity.ok(memberInfo);
@@ -44,6 +45,48 @@ public ResponseEntity<Void> addManualCourse(@Valid @RequestBody AddManualCourseR
4445
return ResponseEntity.ok().build();
4546
}
4647

48+
@Operation(summary = "수동 과목 조회", description = "학생이 수동으로 등록한 과목 목록을 조회합니다.")
49+
@GetMapping("/{studentId}/courses/manual")
50+
public ResponseEntity<List<StudentCourseResponse>> getManualCourses(@PathVariable String studentId) {
51+
List<StudentCourse> manualCourses = userService.getManualCourses(studentId);
52+
if (manualCourses.isEmpty()) {
53+
return ResponseEntity.noContent().build();
54+
}
55+
return ResponseEntity.ok(
56+
manualCourses.stream()
57+
.map(course -> new StudentCourseResponse(course.getCourseName(), course.getStatus()))
58+
.toList()
59+
);
60+
}
61+
62+
@Operation(summary = "진행 예정 과목 조회", description = "학생이 수강 예정인 과목 목록을 조회합니다.")
63+
@GetMapping("/{studentId}/courses/planned")
64+
public ResponseEntity<List<StudentCourseResponse>> getPlannedCourses(@PathVariable String studentId) {
65+
List<StudentCourse> plannedCourses = userService.getPlannedCourses(studentId);
66+
if (plannedCourses.isEmpty()) {
67+
return ResponseEntity.noContent().build();
68+
}
69+
return ResponseEntity.ok(
70+
plannedCourses.stream()
71+
.map(course -> new StudentCourseResponse(course.getCourseName(), course.getStatus()))
72+
.toList()
73+
);
74+
}
75+
76+
@Operation(summary = "수강 중인 과목 조회", description = "학생이 현재 수강 중인 과목 목록을 조회합니다.")
77+
@GetMapping("/{studentId}/courses/inprogress")
78+
public ResponseEntity<List<StudentCourseResponse>> getInProgressCourses(@PathVariable String studentId) {
79+
List<StudentCourse> inProgressCourses = userService.getInProgressCourses(studentId);
80+
if (inProgressCourses.isEmpty()) {
81+
return ResponseEntity.noContent().build();
82+
}
83+
return ResponseEntity.ok(
84+
inProgressCourses.stream()
85+
.map(course -> new StudentCourseResponse(course.getCourseName(), course.getStatus()))
86+
.toList()
87+
);
88+
}
89+
4790
@Operation(summary = "수동 과목 삭제", description = "수동으로 등록한 과목을 삭제합니다.")
4891
@DeleteMapping("/courses")
4992
public ResponseEntity<Void> removeManualCourse(
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.example.enjoy.dto;
2+
3+
import com.example.enjoy.entity.StudentCourse;
4+
import io.swagger.v3.oas.annotations.media.Schema;
5+
import lombok.Getter;
6+
import lombok.NoArgsConstructor;
7+
8+
@Getter
9+
@NoArgsConstructor
10+
@Schema(description = "학생 수강 과목 응답")
11+
public class StudentCourseResponse {
12+
13+
@Schema(description = "과목명")
14+
private String courseName;
15+
16+
@Schema(description = "이수 상태")
17+
private StudentCourseStatus status;
18+
19+
public StudentCourseResponse(String courseName, StudentCourseStatus status) {
20+
this.courseName = courseName;
21+
this.status = status;
22+
}
23+
24+
public static StudentCourseResponse from(StudentCourse entity) {
25+
return new StudentCourseResponse(
26+
entity.getCourseName(),
27+
entity.getStatus()
28+
);
29+
}
30+
}

src/main/java/com/example/enjoy/dto/loginDto/MemberDto.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class MemberDto {
99
private String major;
1010
private String studentIdString;
1111
private String studentName;
12-
private String academicYear;
13-
private String enrollmentStatus;
12+
private String grade;
13+
private String completedSemester;
1414

1515
}

src/main/java/com/example/enjoy/exception/ErrorCode.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public enum ErrorCode {
1717
SEJONG_AUTH_CREDENTIALS_INVALID(HttpStatus.UNAUTHORIZED, "세종대학교 인증 정보가 유효하지 않습니다"),
1818
SEJONG_AUTH_DATA_FETCH_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "세종대학교 인증 데이터 가져오기 실패");
1919

20+
2021
private final String message;
2122
private final int status;
2223

src/main/java/com/example/enjoy/repository/StudentCourseRepository.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ public interface StudentCourseRepository extends JpaRepository<StudentCourse, Lo
2222

2323
Optional<StudentCourse> findByStudentIdAndCourseName(String studentId, String courseName);
2424

25+
List<StudentCourse> findAllByStudentIdAndManualIsTrue(String studentId);
26+
2527
}

0 commit comments

Comments
 (0)