-
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.
- Loading branch information
1 parent
e54e558
commit 4cb6e77
Showing
249 changed files
with
5,100 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Empty file.
Empty file.
Empty file.
60 changes: 60 additions & 0 deletions
60
Monologue/src/main/kotlin/com/SWHackathon/Monologue/domain/auth/client/api/AuthController.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,60 @@ | ||
package com.project.qvickv3.domain.auth.client.api | ||
|
||
import com.project.qvickv3.domain.auth.client.request.AdminSignUpRequest | ||
import com.project.qvickv3.domain.auth.client.request.RefreshTokenRequest | ||
import com.project.qvickv3.domain.auth.client.request.SignInRequest | ||
import com.project.qvickv3.domain.auth.client.request.SignUpRequest | ||
import com.project.qvickv3.domain.auth.service.AuthService | ||
import com.project.qvickv3.domain.auth.service.response.JsonWebTokenResponse | ||
import com.project.qvickv3.domain.auth.service.response.RefreshTokenResponse | ||
import com.project.qvickv3.global.common.dto.response.BaseResponse | ||
import com.project.qvickv3.global.common.dto.response.BaseResponseData | ||
import jakarta.validation.Valid | ||
import org.springframework.http.HttpStatus | ||
import org.springframework.web.bind.annotation.PostMapping | ||
import org.springframework.web.bind.annotation.RequestBody | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.ResponseStatus | ||
import org.springframework.web.bind.annotation.RestController | ||
|
||
@RestController | ||
@RequestMapping("/auth") | ||
class AuthController (private val authService: AuthService) { | ||
|
||
@PostMapping("/sign-up") | ||
@ResponseStatus(HttpStatus.CREATED) | ||
fun signUp(@RequestBody @Valid request: SignUpRequest): BaseResponse { | ||
authService.signUp(request) | ||
return BaseResponse.created("회원가입 성공") | ||
} | ||
|
||
@PostMapping("/sign-up/admin") | ||
@ResponseStatus(HttpStatus.CREATED) | ||
fun adminSignUp(@RequestBody @Valid request: AdminSignUpRequest): BaseResponse { | ||
authService.adminSignUp(request) | ||
return BaseResponse.created("회원가입 성공") | ||
} | ||
|
||
@PostMapping("/sign-up/teacher") | ||
@ResponseStatus(HttpStatus.CREATED) | ||
fun teacherSignUp(@RequestBody @Valid request: SignUpRequest): BaseResponse { | ||
authService.teacherSignUp(request) | ||
return BaseResponse.created("회원가입 성공") | ||
} | ||
|
||
@PostMapping("/sign-in") | ||
fun signIn(@RequestBody @Valid request: SignInRequest): BaseResponseData<JsonWebTokenResponse> { | ||
return BaseResponseData.ok( | ||
message = "로그인 성공", | ||
data = authService.signIn(request)) | ||
} | ||
|
||
@PostMapping("/refresh") | ||
fun refreshToken(@RequestBody @Valid request: RefreshTokenRequest): BaseResponseData<RefreshTokenResponse> { | ||
return BaseResponseData.ok( | ||
message = "토큰 재발급 성공", | ||
data = authService.refresh(request) | ||
) | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
...c/main/kotlin/com/SWHackathon/Monologue/domain/auth/client/request/RefreshTokenRequest.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 com.project.qvickv3.domain.auth.client.request | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty | ||
import jakarta.validation.constraints.NotBlank | ||
|
||
data class RefreshTokenRequest( | ||
@JsonProperty("refreshToken") | ||
val refreshToken: @NotBlank String | ||
) |
12 changes: 12 additions & 0 deletions
12
...gue/src/main/kotlin/com/SWHackathon/Monologue/domain/auth/client/request/SignInRequest.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,12 @@ | ||
package com.project.qvickv3.domain.auth.client.request | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty | ||
import jakarta.validation.constraints.Email | ||
|
||
data class SignInRequest( | ||
@JsonProperty("email") | ||
@field:Email | ||
val email: String, | ||
@JsonProperty("password") | ||
val password: String | ||
) |
25 changes: 25 additions & 0 deletions
25
...gue/src/main/kotlin/com/SWHackathon/Monologue/domain/auth/client/request/SignUpRequest.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,25 @@ | ||
package com.project.qvickv3.domain.auth.client.request | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty | ||
import com.project.qvickv3.domain.user.domain.enum.Gender | ||
import jakarta.validation.constraints.Email | ||
import jakarta.validation.constraints.Pattern | ||
|
||
data class SignUpRequest( | ||
@JsonProperty("email") | ||
@field:Email | ||
val email: String, | ||
@JsonProperty("name") | ||
val name: String, | ||
@JsonProperty("password") | ||
val password: String, | ||
@JsonProperty("stdId") | ||
val stdId: String, | ||
@JsonProperty("room") | ||
val room: String, | ||
@JsonProperty("phoneNum") | ||
@field:Pattern(regexp = "^\\d{2,3}-\\d{3,4}-\\d{4}$", message = "정해진 핸드폰 양식을 따라주세요 (010-0000-0000)") | ||
val phoneNum:String, | ||
@JsonProperty("gender") | ||
val gender: Gender, | ||
) |
104 changes: 104 additions & 0 deletions
104
Monologue/src/main/kotlin/com/SWHackathon/Monologue/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 |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package com.project.qvickv3.domain.auth.service | ||
|
||
import com.project.qvickv3.domain.auth.client.request.AdminSignUpRequest | ||
import com.project.qvickv3.domain.auth.client.request.RefreshTokenRequest | ||
import com.project.qvickv3.domain.auth.client.request.SignInRequest | ||
import com.project.qvickv3.domain.auth.client.request.SignUpRequest | ||
import com.project.qvickv3.domain.auth.service.response.JsonWebTokenResponse | ||
import com.project.qvickv3.domain.auth.service.response.RefreshTokenResponse | ||
import com.project.qvickv3.domain.user.client.dto.User | ||
import com.project.qvickv3.domain.user.domain.enum.Gender | ||
import com.project.qvickv3.domain.user.domain.enum.UserRole | ||
import com.project.qvickv3.domain.user.domain.repository.jpa.UserJpaRepository | ||
import com.project.qvickv3.domain.user.exception.PasswordWrongException | ||
import com.project.qvickv3.domain.user.exception.UserExistException | ||
import com.project.qvickv3.domain.user.exception.UserNotFoundException | ||
import com.project.qvickv3.global.security.jwt.JwtExtract | ||
import com.project.qvickv3.global.security.jwt.JwtProvider | ||
import com.project.qvickv3.global.security.jwt.exception.TokenExpiredException | ||
import com.project.qvickv3.global.security.jwt.exception.error.JwtErrorType | ||
import org.springframework.security.crypto.password.PasswordEncoder | ||
import org.springframework.stereotype.Service | ||
import java.time.LocalDateTime | ||
|
||
@Service | ||
class AuthService ( | ||
private val userJpaRepository: UserJpaRepository, | ||
private val encoder: PasswordEncoder, | ||
private val jwtProvider: JwtProvider, | ||
private val jwtExtract: JwtExtract, | ||
) { | ||
|
||
fun signUp(request: SignUpRequest) { | ||
if(userJpaRepository.existsByEmailOrStdIdOrPhoneNum(request.email, request.stdId, request.phoneNum)) { | ||
throw UserExistException.EXCEPTION | ||
} | ||
save(request) | ||
} | ||
|
||
fun teacherSignUp(request: SignUpRequest) { | ||
if(userJpaRepository.existsByEmail(request.email)) { | ||
throw UserExistException.EXCEPTION | ||
} | ||
save(request) | ||
} | ||
|
||
fun adminSignUp(request: AdminSignUpRequest) { | ||
if(userJpaRepository.existsByEmail(request.email)) { | ||
throw UserExistException.EXCEPTION | ||
} | ||
userJpaRepository.save(User.toEntity(User( | ||
email = request.email, | ||
name = request.name, | ||
password = encoder.encode(request.password), | ||
stdId = "", | ||
room = "", | ||
phoneNum = "", | ||
gender = Gender.MALE, | ||
userRole = UserRole.ADMIN, | ||
isChecked = false, | ||
checkedDate = LocalDateTime.now(), | ||
))) | ||
} | ||
|
||
fun signIn(request: SignInRequest): JsonWebTokenResponse { | ||
val user: User = userJpaRepository | ||
.findByEmail(request.email) | ||
.map { userEntity -> User.toUser(userEntity) } | ||
.orElseThrow { UserNotFoundException.EXCEPTION } | ||
val password: String = user.password | ||
if (!encoder.matches(request.password, password)) | ||
throw PasswordWrongException.EXCEPTION | ||
return JsonWebTokenResponse( | ||
accessToken = jwtProvider.generateAccessToken(request.email, user.userRole), | ||
refreshToken = jwtProvider.generateRefreshToken(request.email, user.userRole), | ||
userRole = user.userRole) | ||
} | ||
|
||
fun refresh(request: RefreshTokenRequest): RefreshTokenResponse { | ||
val got = jwtExtract.getToken(request.refreshToken) | ||
val user = jwtExtract.findUserByEmail(got) | ||
if (jwtExtract.checkTokenInfo(got) == JwtErrorType.ExpiredJwtException) { | ||
throw TokenExpiredException.EXCEPTION | ||
} | ||
return RefreshTokenResponse( | ||
jwtProvider.generateAccessToken(user.email, user.userRole), | ||
) | ||
} | ||
|
||
fun save(request: SignUpRequest){ | ||
userJpaRepository.save(User.toEntity(User( | ||
email = request.email, | ||
name = request.name, | ||
password = encoder.encode(request.password), | ||
stdId = request.stdId, | ||
room = request.room, | ||
phoneNum = request.phoneNum, | ||
gender = request.gender, | ||
userRole = UserRole.USER, | ||
isChecked = false, | ||
checkedDate = LocalDateTime.now(), | ||
))) | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
...ain/kotlin/com/SWHackathon/Monologue/domain/auth/service/response/JsonWebTokenResponse.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,13 @@ | ||
package com.project.qvickv3.domain.auth.service.response | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude | ||
import com.project.qvickv3.domain.user.domain.enum.UserRole | ||
import lombok.Builder | ||
|
||
@Builder | ||
@JsonInclude(JsonInclude.Include.NON_EMPTY) | ||
class JsonWebTokenResponse( | ||
val accessToken: String, | ||
val refreshToken: String, | ||
val userRole: UserRole | ||
) |
10 changes: 10 additions & 0 deletions
10
...ain/kotlin/com/SWHackathon/Monologue/domain/auth/service/response/RefreshTokenResponse.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,10 @@ | ||
package com.project.qvickv3.domain.auth.service.response | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude | ||
import lombok.Builder | ||
|
||
@Builder | ||
@JsonInclude(JsonInclude.Include.NON_EMPTY) | ||
data class RefreshTokenResponse( | ||
val accessToken: String | ||
) |
4 changes: 4 additions & 0 deletions
4
...ogue/src/main/kotlin/com/SWHackathon/Monologue/domain/azure/controller/AzureController.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,4 @@ | ||
package com.SWHackathon.Monologue.domain.azure.controller | ||
|
||
class AzureController { | ||
} |
4 changes: 4 additions & 0 deletions
4
Monologue/src/main/kotlin/com/SWHackathon/Monologue/domain/azure/service/AzureService.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,4 @@ | ||
package com.SWHackathon.Monologue.domain.azure.service | ||
|
||
class AzureService { | ||
} |
14 changes: 14 additions & 0 deletions
14
Monologue/src/main/kotlin/com/SWHackathon/Monologue/domain/health/HealthController.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 com.SWHackathon.Monologue.domain.health | ||
|
||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RestController | ||
|
||
@RestController | ||
@RequestMapping("health") | ||
class HealthController { | ||
@GetMapping | ||
fun health() : String{ | ||
return "health check" | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
Monologue/src/main/kotlin/com/SWHackathon/Monologue/domain/image/Image.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,21 @@ | ||
package com.SWHackathon.Monologue.domain.image | ||
|
||
data class Image( | ||
val userId: String, | ||
|
||
val profileImage: String, | ||
|
||
val frameImage: String, | ||
|
||
val beforeImage: String, | ||
|
||
val resultImage:String, | ||
){ | ||
constructor(userId: String?, profileImage: String?, frameImage: String?, beforeImage: String?, resultImage: String?): this ( | ||
userId = userId ?: "", | ||
profileImage = profileImage ?: "", | ||
frameImage = frameImage ?: "", | ||
beforeImage = beforeImage ?: "", | ||
resultImage = resultImage ?: "" | ||
) | ||
} |
4 changes: 4 additions & 0 deletions
4
Monologue/src/main/kotlin/com/SWHackathon/Monologue/domain/image/after/AfterImageEntity.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,4 @@ | ||
package com.SWHackathon.Monologue.domain.image | ||
|
||
class AfterImageEntity { | ||
} |
4 changes: 4 additions & 0 deletions
4
...ogue/src/main/kotlin/com/SWHackathon/Monologue/domain/image/after/AfterImageRepository.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,4 @@ | ||
package com.SWHackathon.Monologue.domain.image.after | ||
|
||
interface AfterImageRepository { | ||
} |
4 changes: 4 additions & 0 deletions
4
Monologue/src/main/kotlin/com/SWHackathon/Monologue/domain/image/before/BeforeImageEntity.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,4 @@ | ||
package com.SWHackathon.Monologue.domain.image | ||
|
||
class BeforeImageEntity { | ||
} |
4 changes: 4 additions & 0 deletions
4
...ue/src/main/kotlin/com/SWHackathon/Monologue/domain/image/before/BeforeImageRepository.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,4 @@ | ||
package com.SWHackathon.Monologue.domain.image.before | ||
|
||
interface BeforeImageRepository { | ||
} |
4 changes: 4 additions & 0 deletions
4
Monologue/src/main/kotlin/com/SWHackathon/Monologue/domain/image/frame/FrameImageEntity.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,4 @@ | ||
package com.SWHackathon.Monologue.domain.image | ||
|
||
class FrameImageEntity { | ||
} |
4 changes: 4 additions & 0 deletions
4
...ogue/src/main/kotlin/com/SWHackathon/Monologue/domain/image/frame/FrameImageRepository.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,4 @@ | ||
package com.SWHackathon.Monologue.domain.image.frame | ||
|
||
interface FrameImageRepository { | ||
} |
44 changes: 44 additions & 0 deletions
44
Monologue/src/main/kotlin/com/SWHackathon/Monologue/domain/user/client/api/UserController.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,44 @@ | ||
package com.project.qvickv3.domain.user.client.api | ||
|
||
import com.project.qvickv3.domain.user.client.dto.User | ||
import com.project.qvickv3.domain.user.client.dto.request.UserEditRequest | ||
import com.project.qvickv3.domain.user.service.UserService | ||
import com.project.qvickv3.domain.user.usecase.UserUseCase | ||
import com.project.qvickv3.global.common.dto.response.BaseResponse | ||
import com.project.qvickv3.global.common.dto.response.BaseResponseData | ||
import kotlinx.coroutines.flow.merge | ||
import org.springframework.web.bind.annotation.DeleteMapping | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.PostMapping | ||
import org.springframework.web.bind.annotation.RequestBody | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RestController | ||
|
||
@RestController | ||
@RequestMapping("/user") | ||
class UserController( | ||
private val userUseCase: UserUseCase | ||
) { | ||
|
||
@PostMapping | ||
fun editUser(@RequestBody request: UserEditRequest): BaseResponse { | ||
userUseCase.editUser(request) | ||
return BaseResponse.ok("유저 정보 수정 완료") | ||
} | ||
|
||
@GetMapping | ||
fun getUser(): BaseResponseData<User>{ | ||
return BaseResponseData.ok( | ||
message = "유저 프로필 조회 성공", | ||
data = userUseCase.getUser() | ||
) | ||
} | ||
|
||
@DeleteMapping | ||
fun deleteUser(): BaseResponse { | ||
userUseCase.deleteUser() | ||
return BaseResponse.ok(message = "회원탈퇴 완료") | ||
} | ||
|
||
} | ||
|
3 changes: 3 additions & 0 deletions
3
Monologue/src/main/kotlin/com/SWHackathon/Monologue/domain/user/client/dto/Profile.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,3 @@ | ||
package com.SWHackathon.Monologue.domain.user.client.dto | ||
|
||
data class Profile() |
Oops, something went wrong.