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.
1. POSIX New Line 적용 2. 컨트롤러 객체에 빌더 스타일 적용으로 가독성 향상 3. 보안성을 위해 엔티티 객체들의 @NoArgsConstructor 어노테이션에 (access = AccessLevel.PROTECTED) 속성 추가 4. 그외 개행, import문 정리 등 코드 스타일 개선
- Loading branch information
Showing
41 changed files
with
654 additions
and
688 deletions.
There are no files selected for viewing
Binary file added
BIN
+35.2 KB
KIMTAEWOO/GDGWeek4AssignmentKTW/postman/강의/courseId로 강의 삭제.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+52.7 KB
KIMTAEWOO/GDGWeek4AssignmentKTW/postman/강의/courseId로 강의 업데이트.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+49.5 KB
KIMTAEWOO/GDGWeek4AssignmentKTW/postman/강의/courseId로 강의 조회.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+38.5 KB
...GDGWeek4AssignmentKTW/postman/수강/courseRegistrationId로 수강신청 조회.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+33.4 KB
...GDGWeek4AssignmentKTW/postman/수강/courseRegistrationId로 수강신청 취소.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+56.2 KB
...nmentKTW/postman/수강/studentNumber로 그 학생의 수강신청 내역 확인.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+48 KB
KIMTAEWOO/GDGWeek4AssignmentKTW/postman/수강/모든 수강신청 확인.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+35.1 KB
KIMTAEWOO/GDGWeek4AssignmentKTW/postman/학생/studentId로 학생 삭제.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+50 KB
KIMTAEWOO/GDGWeek4AssignmentKTW/postman/학생/studentId로 학생 업데이트.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+44.4 KB
KIMTAEWOO/GDGWeek4AssignmentKTW/postman/학생/studentId로 학생 조회.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+47.1 KB
KIMTAEWOO/GDGWeek4AssignmentKTW/postman/학생/모든 학생 확인.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
110 changes: 52 additions & 58 deletions
110
.../main/java/org/example/gdgweek4assignmentktw/controller/CourseRegistrationController.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,58 +1,52 @@ | ||
package org.example.gdgweek4assignmentktw.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.example.gdgweek4assignmentktw.domain.Course; | ||
import org.example.gdgweek4assignmentktw.domain.Student; | ||
import org.example.gdgweek4assignmentktw.dto.courseRegistration.request.CourseRegistrationRequestDto; | ||
import org.example.gdgweek4assignmentktw.dto.courseRegistration.response.CourseRegistrationListResponseDto; | ||
import org.example.gdgweek4assignmentktw.dto.courseRegistration.response.CourseRegistrationResponseDto; | ||
import org.example.gdgweek4assignmentktw.repository.CourseRepository; | ||
import org.example.gdgweek4assignmentktw.repository.StudentRepository; | ||
import org.example.gdgweek4assignmentktw.service.CourseRegistrationService; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/courseRegistration") | ||
public class CourseRegistrationController { | ||
|
||
private final CourseRegistrationService courseRegistrationService; | ||
private final CourseRepository courseRepository; | ||
private final StudentRepository studentRepository; | ||
|
||
// 수강신청 등록 | ||
@PostMapping | ||
public ResponseEntity<CourseRegistrationResponseDto> doRegistration(@RequestBody CourseRegistrationRequestDto dto) { | ||
CourseRegistrationResponseDto responseDto = courseRegistrationService.doRegistration(dto); | ||
return new ResponseEntity<>(responseDto, HttpStatus.OK); | ||
} | ||
|
||
// courseRegistrationId 로 수강신청 조회 | ||
@GetMapping("/{courseRegistrationId}") | ||
public ResponseEntity<CourseRegistrationResponseDto> checkRegistration(@PathVariable Long courseRegistrationId) { | ||
return new ResponseEntity<>(courseRegistrationService.checkByCourseRegistrationId(courseRegistrationId),HttpStatus.OK); | ||
} | ||
|
||
// 전체 수강신청 조회 | ||
@GetMapping("/findAll") | ||
public ResponseEntity<CourseRegistrationListResponseDto> findAllRegistrations() { | ||
return new ResponseEntity<>(courseRegistrationService.findAllRegistrations(), HttpStatus.OK); | ||
} | ||
|
||
// 수강신청 취소 | ||
@DeleteMapping("/{courseRegistrationId}") | ||
public ResponseEntity<String> cancelRegistration(@PathVariable Long courseRegistrationId) { | ||
courseRegistrationService.cancelByCourseRegistrationId(courseRegistrationId); | ||
String cancelResponseMessage = "요청하신 " + courseRegistrationId + "번 수강신청의 취소가 완료되었습니다"; | ||
return new ResponseEntity<>(cancelResponseMessage,HttpStatus.OK); | ||
} | ||
|
||
// 학번을 통해 해당 학생의 수강신청 내역 조회 | ||
@GetMapping("/findAll/{studentNumber}") | ||
public ResponseEntity<CourseRegistrationListResponseDto> findAllRegistrationsByStudnetNumber(@PathVariable Long studentNumber) { | ||
return new ResponseEntity<>(courseRegistrationService.findAllRegistrationsByStudentNumber(studentNumber),HttpStatus.OK); | ||
} | ||
|
||
} | ||
package org.example.gdgweek4assignmentktw.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.example.gdgweek4assignmentktw.dto.courseRegistration.request.CourseRegistrationRequestDto; | ||
import org.example.gdgweek4assignmentktw.dto.courseRegistration.response.CourseRegistrationListResponseDto; | ||
import org.example.gdgweek4assignmentktw.dto.courseRegistration.response.CourseRegistrationResponseDto; | ||
import org.example.gdgweek4assignmentktw.service.CourseRegistrationService; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/courseRegistration") | ||
public class CourseRegistrationController { | ||
private final CourseRegistrationService courseRegistrationService; | ||
|
||
// 수강신청 등록 | ||
@PostMapping | ||
public ResponseEntity<CourseRegistrationResponseDto> doRegistration(@RequestBody CourseRegistrationRequestDto dto) { | ||
return ResponseEntity.ok() | ||
.body(courseRegistrationService.doRegistration(dto)); | ||
} | ||
|
||
// courseRegistrationId 로 수강신청 조회 | ||
@GetMapping("/{courseRegistrationId}") | ||
public ResponseEntity<CourseRegistrationResponseDto> checkRegistration(@PathVariable Long courseRegistrationId) { | ||
return ResponseEntity.ok() | ||
.body(courseRegistrationService.checkByCourseRegistrationId(courseRegistrationId)); | ||
} | ||
|
||
// 전체 수강신청 조회 | ||
@GetMapping("/findAll") | ||
public ResponseEntity<CourseRegistrationListResponseDto> findAllRegistrations() { | ||
return ResponseEntity.ok() | ||
.body(courseRegistrationService.findAllRegistrations()); | ||
} | ||
|
||
// 수강신청 취소 | ||
@DeleteMapping("/{courseRegistrationId}") | ||
public ResponseEntity<String> cancelRegistration(@PathVariable Long courseRegistrationId) { | ||
return ResponseEntity.ok() | ||
.body(courseRegistrationService.cancelByCourseRegistrationId(courseRegistrationId)); | ||
} | ||
|
||
// 학번을 통해 해당 학생의 수강신청 내역 조회 | ||
@GetMapping("/findAll/{studentNumber}") | ||
public ResponseEntity<CourseRegistrationListResponseDto> findAllRegistrationsByStudnetNumber(@PathVariable Long studentNumber) { | ||
return ResponseEntity.ok() | ||
.body(courseRegistrationService.findAllRegistrationsByStudentNumber(studentNumber)); | ||
} | ||
|
||
} |
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
128 changes: 64 additions & 64 deletions
128
.../GDGWeek4AssignmentKTW/src/main/java/org/example/gdgweek4assignmentktw/domain/Course.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,64 +1,64 @@ | ||
package org.example.gdgweek4assignmentktw.domain; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.example.gdgweek4assignmentktw.dto.course.request.CourseSaveRequestDto; | ||
|
||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor | ||
public class Course { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) // 1씩 자동으로 올라가도록 설정 | ||
@Column(name = "course_id") | ||
private Long courseId; | ||
|
||
@Column(name = "course_number") | ||
private Long courseNumber; | ||
|
||
@Column(name = "course_name") | ||
private String courseName; // 운영체제 | ||
|
||
@Column(name = "course_room") | ||
private String courseRoom; // M404 | ||
|
||
@Column(name = "course_time") | ||
private String courseTime; // 12:00 ~ 13:15 와 같이 String으로 저장 | ||
|
||
@Column(name = " course_professor") | ||
private String courseProfessor; | ||
|
||
/* | ||
연관관계의 주인은 별도의 설정을 할 필요 없다. | ||
OneToOne 과 ManyToOne의 fetch 속성의 기본값은 EAGER 이다. | ||
EAGAR 일 때 : lecture을 조회할 때마다 lecture과 연관된 student 정보가 항상 같이 로드된다 | ||
LAZY 일 때 : Lecture 만 조회할 때는 student 정보가 로드되지 않고, | ||
실제로 student 필드에 접근하는 시점에 정보가 조회된다 | ||
*/ | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private Student student; | ||
|
||
@Builder | ||
public Course(Long courseNumber, String courseName, String courseRoom | ||
, String courseTime, String courseProfessor, Student student){ | ||
this.courseNumber = courseNumber; | ||
this.courseName = courseName; | ||
this.courseRoom = courseRoom; | ||
this.courseTime = courseTime; | ||
this.courseProfessor = courseProfessor; | ||
this.student = student; | ||
} | ||
|
||
public void update(CourseSaveRequestDto dto) { | ||
this.courseNumber = dto.getCourseNumber(); | ||
this.courseName = dto.getCourseName(); | ||
this.courseRoom = dto.getCourseRoom(); | ||
this.courseTime = dto.getCourseTime(); | ||
this.courseProfessor = dto.getCourseProfessor(); | ||
} | ||
|
||
} | ||
package org.example.gdgweek4assignmentktw.domain; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.example.gdgweek4assignmentktw.dto.course.request.CourseSaveRequestDto; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class Course { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) // 1씩 자동으로 올라가도록 설정 | ||
@Column(name = "course_id") | ||
private Long courseId; | ||
|
||
@Column(name = "course_number") | ||
private Long courseNumber; | ||
|
||
@Column(name = "course_name") | ||
private String courseName; // 운영체제 | ||
|
||
@Column(name = "course_room") | ||
private String courseRoom; // M404 | ||
|
||
@Column(name = "course_time") | ||
private String courseTime; // 12:00 ~ 13:15 와 같이 String으로 저장 | ||
|
||
@Column(name = " course_professor") | ||
private String courseProfessor; | ||
|
||
/* | ||
연관관계의 주인은 별도의 설정을 할 필요 없다. | ||
OneToOne 과 ManyToOne의 fetch 속성의 기본값은 EAGER 이다. | ||
EAGAR 일 때 : lecture을 조회할 때마다 lecture과 연관된 student 정보가 항상 같이 로드된다 | ||
LAZY 일 때 : Lecture 만 조회할 때는 student 정보가 로드되지 않고, | ||
실제로 student 필드에 접근하는 시점에 정보가 조회된다 | ||
*/ | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private Student student; | ||
|
||
@Builder | ||
public Course(Long courseNumber, String courseName, String courseRoom | ||
, String courseTime, String courseProfessor, Student student){ | ||
this.courseNumber = courseNumber; | ||
this.courseName = courseName; | ||
this.courseRoom = courseRoom; | ||
this.courseTime = courseTime; | ||
this.courseProfessor = courseProfessor; | ||
this.student = student; | ||
} | ||
|
||
public void update(CourseSaveRequestDto dto) { | ||
this.courseNumber = dto.getCourseNumber(); | ||
this.courseName = dto.getCourseName(); | ||
this.courseRoom = dto.getCourseRoom(); | ||
this.courseTime = dto.getCourseTime(); | ||
this.courseProfessor = dto.getCourseProfessor(); | ||
} | ||
|
||
} |
Oops, something went wrong.