generated from GSM-MSG/MSG-Repository-Generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/GSM-MSG/Bitgouel-Server i…
…nto 34-feat/student-activity-information-add
- Loading branch information
Showing
19 changed files
with
242 additions
and
11 deletions.
There are no files selected for viewing
88 changes: 88 additions & 0 deletions
88
bitgouel-api/src/main/kotlin/team/msg/common/aop/HttpLoggingAspect.kt
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 |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package team.msg.common.aop | ||
|
||
import org.aspectj.lang.JoinPoint | ||
import org.aspectj.lang.ProceedingJoinPoint | ||
import org.aspectj.lang.annotation.Around | ||
import org.aspectj.lang.annotation.Aspect | ||
import org.aspectj.lang.annotation.Pointcut | ||
import org.aspectj.lang.reflect.CodeSignature | ||
import org.aspectj.lang.reflect.MethodSignature | ||
import org.springframework.http.ResponseEntity | ||
import org.springframework.stereotype.Component | ||
import org.springframework.web.context.request.RequestContextHolder | ||
import org.springframework.web.context.request.ServletRequestAttributes | ||
import team.msg.common.logger.LoggerDelegator | ||
import java.util.* | ||
import kotlin.collections.HashMap | ||
import kotlin.collections.HashSet | ||
|
||
@Aspect | ||
@Component | ||
class HttpLoggingAspect { | ||
|
||
private val log by LoggerDelegator() | ||
|
||
@Pointcut("within(@org.springframework.web.bind.annotation.RestController *)") | ||
fun onRequest() {} | ||
|
||
@Around("onRequest()") | ||
@Throws(Throwable::class) | ||
fun logging(proceedingJoinPoint: ProceedingJoinPoint): Any? { | ||
val request = (RequestContextHolder.currentRequestAttributes() as ServletRequestAttributes).request | ||
val ip = request.remoteAddr | ||
val method = request.method | ||
val uri = request.requestURI | ||
val sessionId = request.requestedSessionId | ||
val params = request.queryString | ||
val contentType = request.contentType | ||
val userAgent = request.getHeader("User-Agent") | ||
val signature: MethodSignature = proceedingJoinPoint.signature as MethodSignature | ||
val className = signature.declaringType.simpleName | ||
val methodName = signature.name | ||
val headerNames = request.headerNames | ||
val headerSet: MutableSet<String> = HashSet() | ||
|
||
while (headerNames.hasMoreElements()) { | ||
val headerName = headerNames.nextElement() | ||
headerSet.add(headerName) | ||
} | ||
val code = UUID.randomUUID() | ||
log.info( | ||
"At {}#{} [Request:{}] IP: {}, Session-ID: {}, URI: {}, Params: {}, Content-Type: {}, User-Agent: {}, Headers: {}, Parameters: {}, Code: {}", | ||
className, methodName, method, ip, sessionId, uri, params, contentType, userAgent, headerSet, params(proceedingJoinPoint), code | ||
) | ||
val result = proceedingJoinPoint.proceed() | ||
when (result) { | ||
is ResponseEntity<*> -> { | ||
log.info( | ||
"At {}#{} [Response:{}] IP: {}, Session-ID: {}, Headers: {}, Response: {}, Status-Code: {}, Code: {}", | ||
className, methodName, method, ip,sessionId, result.headers, result.body, result.statusCode, code | ||
) | ||
} | ||
|
||
null -> { | ||
log.info( | ||
"At {}#{} [Response: null] IP: {}, Session-ID: {}, Code: {}", | ||
className, methodName, ip, sessionId, code | ||
) | ||
} | ||
|
||
else -> { | ||
throw RuntimeException("유효하지 않은 Controller 반환 타입입니다.") | ||
} | ||
} | ||
return result | ||
} | ||
|
||
private fun params(joinPoint: JoinPoint): Map<*,*>? { | ||
val codeSignature = joinPoint.signature as CodeSignature | ||
val parameterNames = codeSignature.parameterNames | ||
val args = joinPoint.args | ||
val params: MutableMap<String,Any> = HashMap() | ||
|
||
for (i in parameterNames.indices) { | ||
params[parameterNames[i]] = args[i] | ||
} | ||
return params | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...kotlin/team/msg/common/DataInitializer.kt → ...n/team/msg/common/init/DataInitializer.kt
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
9 changes: 9 additions & 0 deletions
9
bitgouel-api/src/main/kotlin/team/msg/domain/auth/exception/InvalidRefreshTokenException.kt
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package team.msg.domain.auth.exception | ||
|
||
import team.msg.domain.auth.exception.constant.AuthErrorCode | ||
import team.msg.global.error.exception.BitgouelException | ||
|
||
class InvalidRefreshTokenException( | ||
message: String | ||
) : BitgouelException(message, AuthErrorCode.INVALID_TOKEN.status){ | ||
} |
8 changes: 8 additions & 0 deletions
8
bitgouel-api/src/main/kotlin/team/msg/domain/auth/exception/MisMatchPasswordException.kt
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package team.msg.domain.auth.exception | ||
|
||
import team.msg.domain.auth.exception.constant.AuthErrorCode | ||
import team.msg.global.error.exception.BitgouelException | ||
|
||
class MisMatchPasswordException( | ||
message: String | ||
) : BitgouelException(message, AuthErrorCode.MISMATCH_PASSWORD.status) |
8 changes: 8 additions & 0 deletions
8
bitgouel-api/src/main/kotlin/team/msg/domain/auth/exception/RefreshTokenNotFoundException.kt
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package team.msg.domain.auth.exception | ||
|
||
import team.msg.domain.auth.exception.constant.AuthErrorCode | ||
import team.msg.global.error.exception.BitgouelException | ||
|
||
class RefreshTokenNotFoundException( | ||
message: String | ||
) : BitgouelException(message, AuthErrorCode.REFRESH_TOKEN_NOT_FOUND.status) |
8 changes: 8 additions & 0 deletions
8
bitgouel-api/src/main/kotlin/team/msg/domain/auth/exception/UnApprovedUserException.kt
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package team.msg.domain.auth.exception | ||
|
||
import team.msg.domain.auth.exception.constant.AuthErrorCode | ||
import team.msg.global.error.exception.BitgouelException | ||
|
||
class UnApprovedUserException( | ||
message: String | ||
) : BitgouelException(message, AuthErrorCode.UNAPPROVED_USER.status) |
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
6 changes: 6 additions & 0 deletions
6
bitgouel-api/src/main/kotlin/team/msg/domain/auth/presentation/data/request/LoginRequest.kt
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package team.msg.domain.auth.presentation.data.request | ||
|
||
data class LoginRequest( | ||
val email: String, | ||
val password: String | ||
) |
14 changes: 14 additions & 0 deletions
14
bitgouel-api/src/main/kotlin/team/msg/domain/auth/presentation/data/web/LoginWebRequest.kt
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package team.msg.domain.auth.presentation.data.web | ||
|
||
import javax.validation.constraints.Email | ||
import javax.validation.constraints.NotNull | ||
import javax.validation.constraints.Pattern | ||
|
||
data class LoginWebRequest( | ||
@field:Email | ||
@field:NotNull | ||
val email: String, | ||
|
||
@field:Pattern(regexp = "^(?=.*[A-Za-z0-9])[A-Za-z0-9!@#\\\\\$%^&*]{8,24}\$") | ||
val password: String | ||
) |
3 changes: 3 additions & 0 deletions
3
bitgouel-api/src/main/kotlin/team/msg/domain/auth/service/AuthService.kt
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,11 +1,14 @@ | ||
package team.msg.domain.auth.service | ||
|
||
import team.msg.domain.auth.presentation.data.request.* | ||
import team.msg.domain.auth.presentation.data.response.TokenResponse | ||
|
||
interface AuthService { | ||
fun studentSignUp(studentSignUpRequest: StudentSignUpRequest) | ||
fun teacherSignUp(teacherSignUpRequest: TeacherSignUpRequest) | ||
fun professorSignUp(professorSignUpRequest: ProfessorSignUpRequest) | ||
fun governmentSignUp(governmentSignUpRequest: GovernmentSignUpRequest) | ||
fun companyInstructorSignUp(companyInstructorSignUpRequest: CompanyInstructorSignUpRequest) | ||
fun login(request: LoginRequest): TokenResponse | ||
fun reissueToken(refreshToken: String): TokenResponse | ||
} |
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
Oops, something went wrong.