generated from GDG-on-Campus-SKHU/24-25-Assignment-template
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
667d1c2
commit ceed138
Showing
20 changed files
with
80 additions
and
130 deletions.
There are no files selected for viewing
42 changes: 17 additions & 25 deletions
42
Kiwoong/src/main/java/com/example/kiwoong/controller/EnrolmentController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,37 @@ | ||
package com.example.kiwoong.controller; | ||
|
||
import com.example.kiwoong.dto.Enrolment.request.EnrolmentRequestDto; | ||
import com.example.kiwoong.dto.Enrolment.response.EnrolmentInfoResponseDto; | ||
import com.example.kiwoong.dto.Enrolment.response.EnrolmentListResponseDto; | ||
import com.example.kiwoong.service.EnrolmentService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/api/enrolments") | ||
@RequiredArgsConstructor | ||
@RequestMapping("/enrolment") | ||
public class EnrolmentController { | ||
|
||
private final EnrolmentService enrolmentService; | ||
|
||
// 수강 신청 | ||
@PostMapping("/register") | ||
public ResponseEntity<Void> registerEnrolment(@RequestParam Long studentId, @RequestParam Long coursesId) { | ||
enrolmentService.enrolment(studentId, coursesId); | ||
return ResponseEntity.ok().build(); // 200 OK 응답 | ||
@PostMapping | ||
public ResponseEntity<EnrolmentInfoResponseDto> save(@RequestBody EnrolmentRequestDto enrolmentRequestDto){ | ||
return new ResponseEntity<>(enrolmentService.save(enrolmentRequestDto), HttpStatus.CREATED); | ||
} | ||
|
||
// 강의별 학생 조회 | ||
@GetMapping("/students/{coursesId}") | ||
public ResponseEntity<List<EnrolmentInfoResponseDto>> getStudentsByCourses(@PathVariable Long coursesId) { | ||
List<EnrolmentInfoResponseDto> response = enrolmentService.getStudentsByCourses(coursesId); | ||
return ResponseEntity.ok(response); // 학생 리스트 반환 | ||
@GetMapping("{id}") | ||
public ResponseEntity<EnrolmentInfoResponseDto> findByEnrolmentId(@PathVariable(name="id") Long id){ | ||
return new ResponseEntity<>(enrolmentService.findByEnrolmentId(id), HttpStatus.OK); | ||
} | ||
|
||
// 학생별 강의 조회 | ||
@GetMapping("/courses/{studentId}") | ||
public ResponseEntity<List<EnrolmentInfoResponseDto>> getCoursesByStudent(@PathVariable Long studentId) { | ||
List<EnrolmentInfoResponseDto> response = enrolmentService.getCoursesByStudent(studentId); | ||
return ResponseEntity.ok(response); // 강의 리스트 반환 | ||
@DeleteMapping("{id}") | ||
public ResponseEntity<EnrolmentInfoResponseDto> deleteByEnrolmentId(@PathVariable(name="id") Long id){ | ||
enrolmentService.deleteByEnrolmentId(id); | ||
return new ResponseEntity<>(HttpStatus.OK); | ||
} | ||
|
||
// 수강 신청 취소 | ||
@DeleteMapping("/cancel") | ||
public ResponseEntity<Void> cancelLectureRegistration(@RequestParam Long studentId, @RequestParam Long lectureId) { | ||
enrolmentService.cancelEnrolment(studentId, lectureId); | ||
return ResponseEntity.ok().build(); // 200 OK 응답 | ||
@GetMapping | ||
public ResponseEntity<EnrolmentListResponseDto> findAllEnrolmentId(){ | ||
return new ResponseEntity<>(enrolmentService.findAllEnrolmentId(), HttpStatus.OK); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
Kiwoong/src/main/java/com/example/kiwoong/dto/Enrolment/request/EnrolmentRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,13 @@ | ||
package com.example.kiwoong.dto.Enrolment.request; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@AllArgsConstructor | ||
@Getter | ||
@NoArgsConstructor | ||
public class EnrolmentRequestDto { | ||
|
||
private Long studentId; | ||
|
||
private Long courseId; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
Kiwoong/src/main/java/com/example/kiwoong/repository/EnrolmentRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.