-
Notifications
You must be signed in to change notification settings - Fork 0
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
114 학생 활동 상세 조회 api 개발 #122
Changes from 5 commits
eadca2e
0e754ed
fa09e24
fe05ac5
9d1834e
697aaf5
3148dff
40dff6d
427d8e2
0de932d
3d2abb0
57e8c99
8996998
a19ccb7
e271f52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import org.springframework.data.domain.Page | |
import team.msg.common.enums.ApproveStatus | ||
import team.msg.domain.student.model.StudentActivity | ||
import team.msg.domain.user.model.User | ||
import java.time.LocalDateTime | ||
import java.util.* | ||
|
||
data class StudentActivityResponse( | ||
|
@@ -25,6 +26,15 @@ data class StudentActivityResponse( | |
) | ||
} | ||
|
||
fun detailOf(studentActivity: StudentActivity): StudentActivityDetailResponse = | ||
StudentActivityDetailResponse( | ||
id = studentActivity.id, | ||
title = studentActivity.title, | ||
content = studentActivity.content, | ||
credit = studentActivity.credit, | ||
activityDate = studentActivity.activityDate, | ||
modifiedAt = studentActivity.modifiedAt | ||
) | ||
} | ||
} | ||
|
||
|
@@ -34,4 +44,13 @@ data class AllStudentActivitiesResponse( | |
|
||
data class StudentActivitiesByStudentResponse( | ||
val activities: Page<StudentActivityResponse> | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이것도 ByStudentResponse 말고 StudentActivitiesResponse 하나로 써주시는게 좋을 것 같아요 StudentsReponse처럼요 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 변경하였습니다 |
||
|
||
data class StudentActivityDetailResponse( | ||
val id: UUID, | ||
val title: String, | ||
val content: String, | ||
val credit: Int, | ||
val activityDate: LocalDateTime, | ||
val modifiedAt: LocalDateTime | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,15 +11,18 @@ import team.msg.domain.student.event.UpdateStudentActivityEvent | |
import team.msg.domain.student.exception.ForbiddenStudentActivityException | ||
import team.msg.domain.student.exception.StudentActivityNotFoundException | ||
import team.msg.domain.student.exception.StudentNotFoundException | ||
import team.msg.domain.student.model.Student | ||
import team.msg.domain.student.model.StudentActivity | ||
import team.msg.domain.student.presentation.data.request.CreateStudentActivityRequest | ||
import team.msg.domain.student.presentation.data.request.UpdateStudentActivityRequest | ||
import team.msg.domain.student.presentation.data.response.AllStudentActivitiesResponse | ||
import team.msg.domain.student.presentation.data.response.StudentActivitiesByStudentResponse | ||
import team.msg.domain.student.presentation.data.response.StudentActivityDetailResponse | ||
import team.msg.domain.student.presentation.data.response.StudentActivityResponse | ||
import team.msg.domain.student.repository.StudentActivityRepository | ||
import team.msg.domain.student.repository.StudentRepository | ||
import team.msg.domain.teacher.exception.TeacherNotFoundException | ||
import team.msg.domain.teacher.model.Teacher | ||
import team.msg.domain.teacher.repository.TeacherRepository | ||
import java.util.* | ||
|
||
|
@@ -227,4 +230,32 @@ class StudentActivityServiceImpl( | |
return response | ||
} | ||
|
||
/** | ||
* 학생 활동의 상세 정보를 조회하는 비즈니스 로직 | ||
* @param 학생 활동을 조회하기 위한 id | ||
*/ | ||
@Transactional(rollbackFor = [Exception::class]) | ||
ani2689 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
override fun queryStudentActivityDetail(id: UUID): StudentActivityDetailResponse { | ||
val user = userUtil.queryCurrentUser() | ||
|
||
val entity = userUtil.getAuthorityEntityAndOrganization(user).first | ||
|
||
val studentActivity = studentActivityRepository.findByIdOrNull(id) | ||
?: throw StudentActivityNotFoundException("학생 활동을 찾을 수 없습니다") | ||
ani2689 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
when(entity) { | ||
is Student -> { | ||
if(entity != studentActivity.student) | ||
throw ForbiddenStudentActivityException("해당 학생 활동에 대한 권한이 없습니다. info : [ userId = ${user.id} ]") | ||
} | ||
is Teacher -> { | ||
if(entity != studentActivity.teacher) | ||
throw ForbiddenStudentActivityException("해당 학생 활동에 대한 권한이 없습니다. info : [ userId = ${user.id} ]") | ||
} | ||
Comment on lines
+250
to
+258
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. else일때도 처리해줘야하지 않을까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. else 분기도 처리하였는데 검증로직이 따로 필요 없는 어드민의 경우에는 아무것도 수행하지 않도록 하였는데 어떻게 처리할지 좋은 생각이 있으시다면 피드백 부탁드립니다 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. else일때 말고 그럼 GOVERNMENT, COMPANY_INSTRUCTOR .... -> forbidden 이런식으로 가도 되고 when 대신 assert나 require, check 사용해서 해결해도 될거같네요 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 0de932d There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. InvalidRoleException을 던지는 것 보단 ForbiddenStudentActivityException을 던지는게 맞지 않을까 싶어요 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 변경했습니다 |
||
} | ||
|
||
val response = StudentActivityResponse.detailOf(studentActivity) | ||
|
||
return response | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
detail 붙인 이유가 무엇인가요? id에 GET 하면 되는거 아닌가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
학생 활동을 학생 단위로 조회하는 api와 endpoint가 겹쳐서 detail을 붙이게 되었습니다