-
Notifications
You must be signed in to change notification settings - Fork 1
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
4df52c3
commit 56c2225
Showing
13 changed files
with
285 additions
and
2 deletions.
There are no files selected for viewing
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
32 changes: 32 additions & 0 deletions
32
src/main/kotlin/com/restaurant/be/user/presentation/controller/GetUserController.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,32 @@ | ||
package com.restaurant.be.user.presentation.controller | ||
|
||
import com.restaurant.be.common.response.CommonResponse | ||
import com.restaurant.be.user.presentation.dto.GetUserResponse | ||
import io.swagger.annotations.Api | ||
import io.swagger.annotations.ApiOperation | ||
import io.swagger.v3.oas.annotations.media.Content | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse | ||
import org.springframework.security.access.prepost.PreAuthorize | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.PathVariable | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RestController | ||
|
||
@Api(tags = ["01. User Info"], description = "유저 서비스") | ||
@RestController | ||
@RequestMapping("/api/v1/users") | ||
class GetUserController { | ||
|
||
@GetMapping("/{userId}") | ||
@PreAuthorize("hasRole('USER')") | ||
@ApiOperation(value = "유저 정보 조회 API") | ||
@ApiResponse( | ||
responseCode = "200", | ||
description = "성공", | ||
content = [Content(schema = Schema(implementation = GetUserResponse::class))] | ||
) | ||
fun getUser(@PathVariable userId: String): CommonResponse<GetUserResponse> { | ||
return CommonResponse.success() | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/kotlin/com/restaurant/be/user/presentation/controller/UpdatePasswordController.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,31 @@ | ||
package com.restaurant.be.user.presentation.controller | ||
|
||
import com.restaurant.be.common.response.CommonResponse | ||
import com.restaurant.be.user.presentation.dto.UpdatePasswordRequest | ||
import io.swagger.annotations.Api | ||
import io.swagger.annotations.ApiOperation | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse | ||
import org.springframework.web.bind.annotation.PatchMapping | ||
import org.springframework.web.bind.annotation.RequestBody | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RestController | ||
import javax.validation.Valid | ||
|
||
@Api(tags = ["01. User Info"], description = "유저 서비스") | ||
@RestController | ||
@RequestMapping("/api/v1/users/password") | ||
class UpdatePasswordController { | ||
|
||
@PatchMapping | ||
@ApiOperation(value = "비밀번호 변경 API") | ||
@ApiResponse( | ||
responseCode = "200", | ||
description = "성공" | ||
) | ||
fun passwordUpdate( | ||
@Valid @RequestBody | ||
request: UpdatePasswordRequest | ||
): CommonResponse<Unit> { | ||
return CommonResponse.success() | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/kotlin/com/restaurant/be/user/presentation/controller/UpdateUserController.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,39 @@ | ||
package com.restaurant.be.user.presentation.controller | ||
|
||
import com.restaurant.be.common.response.CommonResponse | ||
import com.restaurant.be.user.presentation.dto.UpdateUserRequest | ||
import com.restaurant.be.user.presentation.dto.UpdateUserResponse | ||
import io.swagger.annotations.Api | ||
import io.swagger.annotations.ApiOperation | ||
import io.swagger.v3.oas.annotations.media.Content | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse | ||
import org.springframework.security.access.prepost.PreAuthorize | ||
import org.springframework.web.bind.annotation.PatchMapping | ||
import org.springframework.web.bind.annotation.RequestBody | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RestController | ||
import java.security.Principal | ||
import javax.validation.Valid | ||
|
||
@Api(tags = ["01. User Info"], description = "유저 서비스") | ||
@RestController | ||
@RequestMapping("/api/v1/users") | ||
class UpdateUserController { | ||
|
||
@PatchMapping | ||
@PreAuthorize("hasRole('USER')") | ||
@ApiOperation(value = "유저 수정 API") | ||
@ApiResponse( | ||
responseCode = "200", | ||
description = "성공", | ||
content = [Content(schema = Schema(implementation = UpdateUserResponse::class))] | ||
) | ||
fun updateUser( | ||
principal: Principal, | ||
@Valid @RequestBody | ||
request: UpdateUserRequest | ||
): CommonResponse<UpdateUserResponse> { | ||
return CommonResponse.success() | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/kotlin/com/restaurant/be/user/presentation/controller/ValidateEmailController.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,48 @@ | ||
package com.restaurant.be.user.presentation.controller | ||
|
||
import com.restaurant.be.common.response.CommonResponse | ||
import com.restaurant.be.user.presentation.dto.SendEmailRequest | ||
import com.restaurant.be.user.presentation.dto.ValidateEmailRequest | ||
import com.restaurant.be.user.presentation.dto.ValidateEmailResponse | ||
import io.swagger.annotations.Api | ||
import io.swagger.annotations.ApiOperation | ||
import io.swagger.v3.oas.annotations.media.Content | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse | ||
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 | ||
import javax.validation.Valid | ||
|
||
@Api(tags = ["01. User Info"], description = "유저 서비스") | ||
@RestController | ||
@RequestMapping("/v1/users/email") | ||
class ValidateEmailController { | ||
@PostMapping("/send") | ||
@ApiOperation(value = "이메일 전송 API") | ||
@ApiResponse( | ||
responseCode = "200", | ||
description = "성공" | ||
) | ||
fun sendEmail( | ||
@Valid @RequestBody | ||
request: SendEmailRequest | ||
): CommonResponse<Unit> { | ||
return CommonResponse.success() | ||
} | ||
|
||
@PostMapping("/validate") | ||
@ApiOperation(value = "이메일 인증 API") | ||
@ApiResponse( | ||
responseCode = "200", | ||
description = "성공", | ||
content = [Content(schema = Schema(implementation = ValidateEmailResponse::class))] | ||
) | ||
fun validateEmail( | ||
@Valid @RequestBody | ||
request: ValidateEmailRequest | ||
): CommonResponse<ValidateEmailResponse> { | ||
return CommonResponse.success(ValidateEmailResponse("test")) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/kotlin/com/restaurant/be/user/presentation/dto/GetUserDto.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,11 @@ | ||
@file:Suppress("ktlint", "MatchingDeclarationName") | ||
|
||
package com.restaurant.be.user.presentation.dto | ||
|
||
import com.restaurant.be.user.presentation.dto.common.UserDto | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
data class GetUserResponse( | ||
@Schema(description = "유저 정보") | ||
val userDto: UserDto | ||
) |
23 changes: 23 additions & 0 deletions
23
src/main/kotlin/com/restaurant/be/user/presentation/dto/SendEmailDto.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,23 @@ | ||
@file:Suppress("ktlint", "MatchingDeclarationName") | ||
|
||
package com.restaurant.be.user.presentation.dto | ||
|
||
import com.restaurant.be.user.presentation.dto.common.EmailSendType | ||
import io.swagger.annotations.ApiModelProperty | ||
import javax.validation.constraints.Email | ||
import javax.validation.constraints.NotEmpty | ||
|
||
data class SendEmailRequest( | ||
@field:NotEmpty(message = "이메일은 필수 값 입니다.") | ||
@field:Email(message = "유효하지 않는 이메일 입니다.") | ||
@ApiModelProperty(value = "이메일", example = "[email protected]", required = true) | ||
val email: String, | ||
|
||
@ApiModelProperty( | ||
value = "이메일 전송 타입", | ||
example = "EMAIL_VALIDATION", | ||
required = true, | ||
allowableValues = "EMAIL_VALIDATION, UPDATE_PASSWORD" | ||
) | ||
val sendType: EmailSendType | ||
) |
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
23 changes: 23 additions & 0 deletions
23
src/main/kotlin/com/restaurant/be/user/presentation/dto/UpdatePasswordDto.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,23 @@ | ||
@file:Suppress("ktlint", "MatchingDeclarationName") | ||
|
||
package com.restaurant.be.user.presentation.dto | ||
|
||
import io.swagger.annotations.ApiModelProperty | ||
import javax.validation.constraints.NotEmpty | ||
import javax.validation.constraints.Pattern | ||
|
||
data class UpdatePasswordRequest( | ||
@field:NotEmpty(message = "비밀번호는 필수 값 입니다.") | ||
@field:Pattern( | ||
regexp = "^(?=.*[A-Z])(?=.*[a-z])(?=.*\\d)(?=.*[\\W_])[A-Za-z\\d\\W_]{8,16}\$", | ||
message = "영소문자, 영대문자, 숫자, 특수문자가 포함된 8~16자 비밀번호" | ||
) | ||
@ApiModelProperty(value = "비밀번호", example = "Test1234!", required = true) | ||
val password: String, | ||
@field:NotEmpty(message = "변경 토큰은 필수 값 입니다.") | ||
@ApiModelProperty( | ||
value = "변경 토큰", | ||
example = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVIjoxNjIzNTEyNzAwfQ.7J1" | ||
) | ||
val token: String | ||
) |
24 changes: 24 additions & 0 deletions
24
src/main/kotlin/com/restaurant/be/user/presentation/dto/UpdateUserDto.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,24 @@ | ||
package com.restaurant.be.user.presentation.dto | ||
|
||
import com.restaurant.be.user.presentation.dto.common.UserDto | ||
import io.swagger.annotations.ApiModelProperty | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
import javax.validation.constraints.NotBlank | ||
|
||
data class UpdateUserRequest( | ||
@field:NotBlank(message = "닉네임을 입력해 주세요.") | ||
@ApiModelProperty(value = "닉네임", example = "닉네임", required = true) | ||
val nickname: String = "", | ||
|
||
@ApiModelProperty( | ||
value = "프로필 이미지 URL", | ||
example = "https://test.com/test.jpg", | ||
required = true | ||
) | ||
val profileImageUrl: String = "" | ||
) | ||
|
||
data class UpdateUserResponse( | ||
@Schema(description = "유저 정보") | ||
val userDto: UserDto | ||
) |
26 changes: 26 additions & 0 deletions
26
src/main/kotlin/com/restaurant/be/user/presentation/dto/ValidateEmailDto.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,26 @@ | ||
package com.restaurant.be.user.presentation.dto | ||
|
||
import com.restaurant.be.user.presentation.dto.common.EmailSendType | ||
import io.swagger.annotations.ApiModelProperty | ||
import javax.validation.constraints.Email | ||
import javax.validation.constraints.NotEmpty | ||
|
||
data class ValidateEmailRequest( | ||
@field:NotEmpty(message = "이메일은 필수 값 입니다.") | ||
@field:Email(message = "유효하지 않는 이메일 입니다.") | ||
@ApiModelProperty(value = "이메일", example = "[email protected]", required = true) | ||
val email: String, | ||
@ApiModelProperty(value = "인증번호", required = true) | ||
val code: String, | ||
@ApiModelProperty( | ||
value = "이메일 전송 타입", | ||
example = "EMAIL_VALIDATION", | ||
required = true, | ||
allowableValues = "EMAIL_VALIDATION, UPDATE_PASSWORD" | ||
) | ||
val sendType: EmailSendType | ||
) | ||
|
||
data class ValidateEmailResponse( | ||
val token: String | ||
) |
6 changes: 6 additions & 0 deletions
6
src/main/kotlin/com/restaurant/be/user/presentation/dto/common/EmailSendType.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 com.restaurant.be.user.presentation.dto.common | ||
|
||
enum class EmailSendType { | ||
EMAIL_VALIDATION, | ||
UPDATE_PASSWORD | ||
} |
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 |
---|---|---|
|
@@ -3,12 +3,22 @@ package com.restaurant.be.user.presentation.dto.common | |
import io.swagger.annotations.ApiModelProperty | ||
|
||
data class UserDto( | ||
@ApiModelProperty(value = "유저 아이디", example = "1", required = true) | ||
val id: Long = 0, | ||
|
||
@ApiModelProperty(value = "이메일 아이디", example = "[email protected]", required = true) | ||
val email: String = "", | ||
|
||
@ApiModelProperty(value = "비밀번호", example = "test12!@", required = true) | ||
val password: String = "", | ||
|
||
@ApiModelProperty(value = "닉네임", example = "닉네임", required = true) | ||
val nickname: String = "" | ||
val nickname: String = "", | ||
|
||
@ApiModelProperty( | ||
value = "프로필 이미지 URL", | ||
example = "https://test.com/test.jpg", | ||
required = true | ||
) | ||
val profileImageUrl: String = "" | ||
) |