Skip to content
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

master에 develop 변경사항 반영 #312

Merged
merged 57 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
c822385
:sparkles: 선생님 별 권한 추가
ani2689 Jan 18, 2024
e72dd75
:recycle: companion obj ref
ani2689 Jan 18, 2024
8ff4a6d
:sparkles: teacher entity & repository
ani2689 Jan 18, 2024
9fbb088
:sparkles: homeroom teacher entity & repository
ani2689 Jan 18, 2024
b5c20c2
:pencil2: 컬럼 이름 변경
ani2689 Jan 18, 2024
6396e08
Merge pull request #263 from GSM-MSG/feature/262-add-entity-modify-role
ani2689 Jan 19, 2024
07262de
:sparkles: teacher port 추상화
ani2689 Jan 19, 2024
2351297
:sparkles: teacher adapter 구현
ani2689 Jan 19, 2024
b625161
:sparkles: teacher domain obj
ani2689 Jan 20, 2024
47aa955
:sparkles: teacher mapper
ani2689 Jan 20, 2024
59e64ee
:sparkles: exist teacher by user
ani2689 Jan 20, 2024
7981854
:sparkles: check student
ani2689 Jan 20, 2024
dfb44da
:sparkles: check new teacher service
ani2689 Jan 20, 2024
0366346
:recycle: check new teacher
ani2689 Jan 20, 2024
f43611b
:bug: 권한 별 검증
ani2689 Jan 20, 2024
499c2af
:sparkles: 선생님 정보 존재 예외
ani2689 Jan 20, 2024
78d8866
:sparkles: 존재하는 선생님 예외
ani2689 Jan 21, 2024
256d961
:sparkles: teacher save
ani2689 Jan 21, 2024
347b90a
:sparkles: save teacher service
ani2689 Jan 21, 2024
e22072e
:sparkles: teacher signup usecase
ani2689 Jan 21, 2024
23770a4
:sparkles: teacher web adapter
ani2689 Jan 21, 2024
5c7a62c
:bug: 클래스 이름 변경
ani2689 Jan 21, 2024
168b333
:white_check_mark: Mock 추가
ani2689 Jan 21, 2024
d611a98
:recycle: when 문 통합 및 Role enum 사용
ani2689 Feb 9, 2024
2314421
:recycle: Void -> Unit 사용
ani2689 Feb 9, 2024
ee86f01
:recycle: return값 삭제
ani2689 Feb 9, 2024
a404be5
:white_check_mark: 매개변수 수정
ani2689 Feb 9, 2024
8c49f03
:bug: teacher id long -> uuid
ani2689 Feb 10, 2024
dc044e7
Merge pull request #265 from GSM-MSG/feature/264-signup-common-teacher
ani2689 Feb 16, 2024
8b86bd9
:sparkles: signup homeroom teacher web request
ani2689 Feb 16, 2024
882637e
:sparkles: homeroom teacher service
ani2689 Feb 16, 2024
088ca99
:white_check_mark: 함수명 변경
ani2689 Feb 16, 2024
ab29cb8
:recycle: 매개변수 변경
ani2689 Feb 16, 2024
920635a
:sparkles: homeroom port
ani2689 Feb 16, 2024
d231c88
:sparkles: web request
ani2689 Feb 16, 2024
fa6e4a6
:sparkles: homeroom persistence adapter
ani2689 Feb 16, 2024
b0c991b
:sparkles: check homeroom teacher service 구현
ani2689 Feb 16, 2024
4482ed2
:sparkles: save homeroom teacher
ani2689 Feb 16, 2024
eb0718f
:sparkles: save homeroom teacher usecase
ani2689 Feb 16, 2024
98fba80
:bug: cascade 중복되어 저장되는 문제
ani2689 Feb 16, 2024
5b5cbfb
:recycle: 중복 역할 슬래쉬로 구분
ani2689 Feb 16, 2024
2bbba37
:recycle: 중복 역할 슬래쉬로 구분 주석 추가
ani2689 Feb 18, 2024
43d6511
Merge pull request #267 from GSM-MSG/feature/266-signup-homeroom-teacher
ani2689 Feb 18, 2024
0e89038
:sparkles: 유저 권한 저장 service
ani2689 Feb 18, 2024
5d34197
:recycle: teacher 객체 받아서 저장
ani2689 Feb 18, 2024
196b64d
:recycle: homeroom teacher 객체 반환
ani2689 Feb 18, 2024
1e50ba8
:sparkles: 부장 선생님으로 회원가입 usecase
ani2689 Feb 18, 2024
26ce915
:sparkles: 부장 선생님으로 회원가입 endpoint 추가
ani2689 Feb 18, 2024
2b2b94a
Merge pull request #269 from GSM-MSG/feature/268-signup-director-teacher
ani2689 Feb 18, 2024
ec5eb91
:sparkles: 교장, 교감 선생님으로 가입 service
ani2689 Feb 18, 2024
4a7bda5
:sparkles: 교장, 교감 선생님으로 가입 usecase
ani2689 Feb 18, 2024
60393ba
:sparkles: 교장, 교감 선생님으로 가입 endpoint
ani2689 Feb 18, 2024
2b8515e
Merge pull request #271 from GSM-MSG/feature/270-signup-deputy-princi…
ani2689 Feb 18, 2024
e340854
Merge branch 'feature/teacher-api' into feature/311-master-teacher-merge
ani2689 May 24, 2024
66edfc6
update :: 졸업생도 학번을 null로 받도록
ani2689 May 20, 2024
ab95ed1
update :: 졸업생도 학번을 null로 받도록
ani2689 May 20, 2024
bb6068c
Merge branch 'teacher' into feature/311-master-teacher-merge
ani2689 May 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@ package team.msg.sms.domain.auth.model

enum class Role(description: String) {
ROLE_STUDENT("학생"),
ROLE_TEACHER("선생님")
ROLE_TEACHER("선생님"),
ROLE_PRINCIPAL("교장선생님"),
ROLE_DEPUTY_PRINCIPAL("교감선생님"),
ROLE_DIRECTOR("부장선생님"),
ROLE_HOMEROOM("담임선생님")
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import team.msg.sms.domain.auth.model.RefreshToken
import team.msg.sms.domain.auth.model.Role
import team.msg.sms.domain.auth.spi.JwtPort
import team.msg.sms.domain.auth.spi.RefreshTokenPort
import team.msg.sms.domain.student.service.StudentService
import team.msg.sms.domain.user.exception.InternalServerErrorException
import team.msg.sms.domain.user.model.User
import team.msg.sms.domain.user.service.UserService
Expand All @@ -23,8 +22,7 @@ class SignInUseCase(
private val gAuthPort: GAuthPort,
private val jwtPort: JwtPort,
private val refreshTokenPort: RefreshTokenPort,
private val userService: UserService,
private val studentService: StudentService
private val userService: UserService
) {

fun execute(request: SignInRequestData): SignInResponseData =
Expand All @@ -49,15 +47,15 @@ class SignInUseCase(

refreshTokenPort.saveRefreshToken(RefreshToken(refreshToken, user.id))

val isStudent = studentService.checkNewStudent(user, role.name)
val isExist = userService.checkNewUser(user)

SignInResponseData(
accessToken = accessToken,
accessTokenExp = accessTokenExp,
refreshToken = refreshToken,
refreshTokenExp = refreshTokenExp,
role = role,
isExist = isStudent
isExist = isExist
)
}.getOrElse { error ->
when (error) {
Expand All @@ -75,6 +73,6 @@ class SignInUseCase(
}

private fun getStuNumValid(role: Role, gAuthUserInfo: GAuthUserInfo) =
if (role.name != "ROLE_TEACHER") "${gAuthUserInfo.grade}${gAuthUserInfo.classNum}${gAuthUserInfo.getNumber()}" else ""
if (role.name == "ROLE_STUDENT") "${gAuthUserInfo.grade}${gAuthUserInfo.classNum}${gAuthUserInfo.getNumber()}" else ""

private fun GAuthUserInfo.getNumber() = String.format("%02d", this.num)
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@ package team.msg.sms.domain.auth.usecase

import team.msg.sms.common.annotation.UseCase
import team.msg.sms.domain.auth.dto.res.VerifyAccessResponseData
import team.msg.sms.domain.student.service.StudentService
import team.msg.sms.domain.user.service.UserService

@UseCase
class VerifyAccessUseCase(
private val userService: UserService,
private val studentService: StudentService
private val userService: UserService
) {
/**
* Role에 대한 반환 타입이 list가 아닌 단일 string이라 슬래시로 구분해두었습니다.
* 추후 response를 변경하게 되면 바꿔도 괜찮을 거 같아요!
*/
fun execute(): VerifyAccessResponseData =
userService.getCurrentUser()
.let {
VerifyAccessResponseData(
studentService.checkNewStudent(it, it.roles[0].name),
it.roles[0].name
userService.checkNewUser(it),
it.roles.joinToString("/")
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import team.msg.sms.domain.user.model.User
interface CheckStudentService {
fun checkStudentExistsByUser(user: User)
fun studentExistsByUser(user: User): Boolean
fun checkNewStudent(user: User, role: String): Boolean

fun checkNewStudent(user: User): Boolean
fun checkStudentDataMismatch(student: Student, modifyStudentData: Student): Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import team.msg.sms.domain.student.exception.StudentAlreadyException
import team.msg.sms.domain.student.model.Student
import team.msg.sms.domain.student.service.CheckStudentService
import team.msg.sms.domain.student.spi.StudentPort
import team.msg.sms.domain.user.exception.RoleNotExistsException
import team.msg.sms.domain.user.model.User

@Service
Expand All @@ -19,13 +18,8 @@ class CheckStudentServiceImpl (
override fun studentExistsByUser(user: User): Boolean =
studentPort.existsStudentByUser(user)

override fun checkNewStudent(user: User, role: String): Boolean {
return when (role) {
"ROLE_STUDENT" -> studentPort.existsStudentByUser(user)
"ROLE_TEACHER" -> true
else -> throw RoleNotExistsException
}
}
override fun checkNewStudent(user: User): Boolean =
studentPort.existsStudentByUser(user)

override fun checkStudentDataMismatch(student: Student, modifyStudentData: Student): Boolean {
return if(student.contactEmail != modifyStudentData.contactEmail) true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package team.msg.sms.domain.teacher.dto.req

data class SignUpHomeroomTeacherRequestData(
val grade: Int,
val classNum: Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package team.msg.sms.domain.teacher.exception

import team.msg.sms.common.error.SmsException
import team.msg.sms.domain.teacher.exception.error.TeacherErrorCode

object HomeroomTeacherAlreadyException : SmsException(
TeacherErrorCode.HOMEROOM_TEACHER_ALREADY
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package team.msg.sms.domain.teacher.exception

import team.msg.sms.common.error.SmsException
import team.msg.sms.domain.teacher.exception.error.TeacherErrorCode

object TeacherAlreadyException: SmsException(
TeacherErrorCode.TEACHER_ALREADY
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package team.msg.sms.domain.teacher.exception.error

import team.msg.sms.common.error.ErrorProperty
import team.msg.sms.common.error.ErrorStatus

enum class TeacherErrorCode(
private val status: Int,
private val message: String
) : ErrorProperty {

TEACHER_ALREADY(ErrorStatus.CONFLICT, "선생님 정보가 존재하는 유저입니다."),
HOMEROOM_TEACHER_ALREADY(ErrorStatus.CONFLICT, "동일 정보의 담임선생님이 존재합니다."),
;

override fun status(): Int = status
override fun message(): String = message
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package team.msg.sms.domain.teacher.model

import team.msg.sms.common.annotation.Aggregate
import java.util.*

@Aggregate
data class HomeroomTeacher (
val id: Long = 0,
val grade: Int,
val classNum: Int,
val teacherId: UUID,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package team.msg.sms.domain.teacher.model

import team.msg.sms.common.annotation.Aggregate
import java.util.UUID

@Aggregate
data class Teacher (
val id: UUID,
val userId: UUID,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package team.msg.sms.domain.teacher.service

interface CheckHomeroomTeacherService {
fun checkHomeroomTeacherExistsByGradeAndClassNum(grade: Int, classNum: Int)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package team.msg.sms.domain.teacher.service

import team.msg.sms.domain.user.model.User

interface CheckTeacherService{
fun checkTeacherExistsByUser(user: User)
fun checkNewTeacher(user: User): Boolean
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package team.msg.sms.domain.teacher.service

import team.msg.sms.domain.teacher.model.HomeroomTeacher
import team.msg.sms.domain.teacher.model.Teacher
import team.msg.sms.domain.user.model.User

interface CommandHomeroomTeacherService {
fun saveHomeroomTeacher(homeroomTeacher: HomeroomTeacher, teacher: Teacher, user: User): HomeroomTeacher
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package team.msg.sms.domain.teacher.service

import team.msg.sms.domain.teacher.model.Teacher
import team.msg.sms.domain.user.model.User

interface CommandTeacherService {
fun saveTeacher(teacher: Teacher, user: User): Teacher
fun saveDirectorTeacher(teacher: Teacher, user: User): Teacher
fun saveDeputyPrincipalTeacher(teacher: Teacher, user: User): Teacher
fun savePrincipalTeacher(teacher: Teacher, user: User): Teacher
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package team.msg.sms.domain.teacher.service

import team.msg.sms.common.annotation.Service

@Service
class HomeroomTeacherService (
checkHomeroomTeacherService: CheckHomeroomTeacherService,
commandHomeroomTeacherService: CommandHomeroomTeacherService
) : CheckHomeroomTeacherService by checkHomeroomTeacherService,
CommandHomeroomTeacherService by commandHomeroomTeacherService
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package team.msg.sms.domain.teacher.service

import team.msg.sms.common.annotation.Service

@Service
class TeacherService (
checkTeacherService: CheckTeacherService,
commandTeacherService: CommandTeacherService
) : CheckTeacherService by checkTeacherService,
CommandTeacherService by commandTeacherService
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package team.msg.sms.domain.teacher.service.impl

import team.msg.sms.common.annotation.Service
import team.msg.sms.domain.teacher.exception.HomeroomTeacherAlreadyException
import team.msg.sms.domain.teacher.service.CheckHomeroomTeacherService
import team.msg.sms.domain.teacher.spi.HomeroomTeacherPort

@Service
class CheckHomeroomTeacherServiceImpl(
private val homeroomTeacherPort: HomeroomTeacherPort
) : CheckHomeroomTeacherService {
override fun checkHomeroomTeacherExistsByGradeAndClassNum(grade: Int, classNum: Int) {
if (homeroomTeacherPort.existsHomeroomTeacherByGradeAndClassNum(grade, classNum))
throw HomeroomTeacherAlreadyException
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package team.msg.sms.domain.teacher.service.impl

import team.msg.sms.common.annotation.Service
import team.msg.sms.domain.teacher.exception.TeacherAlreadyException
import team.msg.sms.domain.teacher.service.CheckTeacherService
import team.msg.sms.domain.teacher.spi.TeacherPort
import team.msg.sms.domain.user.model.User

@Service
class CheckTeacherServiceImpl(
private val teacherPort: TeacherPort
) : CheckTeacherService {
override fun checkTeacherExistsByUser(user: User) {
if (teacherPort.existsTeacherByUser(user))
throw TeacherAlreadyException
}

override fun checkNewTeacher(user: User) =
teacherPort.existsTeacherByUser(user)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package team.msg.sms.domain.teacher.service.impl

import team.msg.sms.common.annotation.Service
import team.msg.sms.domain.teacher.model.HomeroomTeacher
import team.msg.sms.domain.teacher.model.Teacher
import team.msg.sms.domain.teacher.service.CommandHomeroomTeacherService
import team.msg.sms.domain.teacher.spi.HomeroomTeacherPort
import team.msg.sms.domain.user.model.User

@Service
class CommandHomeroomTeacherServiceImpl(
private val homeroomTeacherPort: HomeroomTeacherPort
) : CommandHomeroomTeacherService {
override fun saveHomeroomTeacher(homeroomTeacher: HomeroomTeacher, teacher: Teacher, user: User) =
homeroomTeacherPort.saveHomeroomTeacher(homeroomTeacher, teacher, user)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package team.msg.sms.domain.teacher.service.impl

import team.msg.sms.common.annotation.Service
import team.msg.sms.domain.teacher.model.Teacher
import team.msg.sms.domain.teacher.service.CommandTeacherService
import team.msg.sms.domain.teacher.spi.TeacherPort
import team.msg.sms.domain.user.model.User

@Service
class CommandTeacherServiceImpl(
private val teacherPort: TeacherPort
) : CommandTeacherService {
override fun saveTeacher(teacher: Teacher, user: User) =
teacherPort.saveTeacher(teacher, user)

override fun saveDirectorTeacher(teacher: Teacher, user: User) =
saveTeacher(teacher, user)

override fun saveDeputyPrincipalTeacher(teacher: Teacher, user: User) =
saveTeacher(teacher, user)

override fun savePrincipalTeacher(teacher: Teacher, user: User) =
saveTeacher(teacher, user)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package team.msg.sms.domain.teacher.spi

import team.msg.sms.domain.teacher.model.HomeroomTeacher
import team.msg.sms.domain.teacher.model.Teacher
import team.msg.sms.domain.user.model.User

interface CommandHomeroomTeacherPort {
fun saveHomeroomTeacher(homeroomTeacher: HomeroomTeacher, teacher: Teacher, user: User): HomeroomTeacher
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package team.msg.sms.domain.teacher.spi

import team.msg.sms.domain.teacher.model.Teacher
import team.msg.sms.domain.user.model.User

interface CommandTeacherPort {
fun saveTeacher(teacher: Teacher, user: User): Teacher
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package team.msg.sms.domain.teacher.spi

interface HomeroomTeacherPort :
QueryHomeroomTeacherPort,
CommandHomeroomTeacherPort
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package team.msg.sms.domain.teacher.spi

interface QueryHomeroomTeacherPort {
fun existsHomeroomTeacherByGradeAndClassNum(grade: Int, classNum: Int): Boolean
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package team.msg.sms.domain.teacher.spi

import team.msg.sms.domain.user.model.User
import java.util.*

interface QueryTeacherPort {
fun existsTeacherById(uuid: UUID): Boolean
fun existsTeacherByUser(user: User): Boolean
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package team.msg.sms.domain.teacher.spi

interface TeacherPort :
QueryTeacherPort,
CommandTeacherPort
Loading
Loading