-
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.
Browse files
Browse the repository at this point in the history
[feat] 회원가입 API 생성
- Loading branch information
Showing
20 changed files
with
235 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,20 @@ | ||
package com.psr.psr.global | ||
|
||
class Constant { | ||
companion object JWT{ | ||
const val AUTHORIZATION_HEADER = "Authorization" | ||
const val BEARER_PREFIX: String = "Bearer " | ||
class JWT{ | ||
companion object JWT{ | ||
const val AUTHORIZATION_HEADER = "Authorization" | ||
const val BEARER_PREFIX: String = "Bearer " | ||
} | ||
} | ||
|
||
class User{ | ||
companion object User{ | ||
// 비밀번호 (숫자, 문자, 특수문자 포함 8~15자리 이내) | ||
const val PASSWORD_VALIDATION = "^.*(?=^.{8,15}\$)(?=.*\\d)(?=.*[a-zA-Z])(?=.*[!@#\$%^&+=]).*\$" | ||
const val EMAIL_VALIDATION = "^[0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*.[a-zA-Z]{2,3}\$" | ||
const val PHONE_VALIDATION = "^01([0|1|6|7|8|9])-?([0-9]{3,4})-?([0-9]{4})\$" | ||
} | ||
} | ||
|
||
} |
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
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
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,3 +1,5 @@ | ||
package com.psr.psr.global.jwt.dto | ||
|
||
data class TokenRes(val accessToken: String, val refreshToken: String) | ||
import com.psr.psr.user.entity.Type | ||
|
||
data class TokenRes(val accessToken: String, val refreshToken: String, val type: String) |
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
15 changes: 13 additions & 2 deletions
15
src/main/kotlin/com/psr/psr/user/controller/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 |
---|---|---|
@@ -1,12 +1,23 @@ | ||
package com.psr.psr.user.controller | ||
|
||
import com.psr.psr.global.dto.BaseResponse | ||
import com.psr.psr.global.exception.BaseResponseCode | ||
import com.psr.psr.global.jwt.dto.TokenRes | ||
import com.psr.psr.user.dto.SignUpReq | ||
import com.psr.psr.user.service.UserService | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RestController | ||
import org.springframework.web.bind.annotation.* | ||
|
||
@RestController | ||
@RequestMapping("/users") | ||
class UserController( | ||
private val userService: UserService | ||
) { | ||
/** | ||
* 회원가입 | ||
*/ | ||
@PostMapping("/signup") | ||
@ResponseBody | ||
fun signUp (@RequestBody signUpReq: SignUpReq) : BaseResponse<TokenRes>{ | ||
return BaseResponse(userService.signUp(signUpReq)) | ||
} | ||
} |
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,40 @@ | ||
package com.psr.psr.user.dto | ||
|
||
import com.psr.psr.user.entity.* | ||
import java.util.stream.Collector | ||
import java.util.stream.Collectors | ||
|
||
|
||
|
||
|
||
data class SignUpReq ( | ||
val email: String, | ||
var password: String, | ||
val type: String, | ||
val phone: String, | ||
val imgKey: String, | ||
val nickname: String, | ||
val marketing: Boolean, | ||
val notification: Boolean, | ||
val interestList: List<UserInterestReq> | ||
) { | ||
fun toEntity(): User { | ||
return User(email = email, | ||
password = password, | ||
type = Type.getTypeByName(type), | ||
phone = phone, | ||
imgKey = imgKey, | ||
provider = Provider.LOCAL, | ||
marketing = marketing, | ||
notification = notification, | ||
nickname = nickname) | ||
} | ||
|
||
fun toInterestEntity(user: User): List<UserInterest> { | ||
return interestList.stream() | ||
.map { i -> | ||
UserInterest(category = Category.getCategoryByName(i.category), | ||
user = user) | ||
}.collect(Collectors.toList()) | ||
} | ||
} |
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.psr.psr.user.dto | ||
|
||
import com.psr.psr.user.entity.Category | ||
|
||
data class UserInterestReq ( | ||
val category: String | ||
){ | ||
fun checkInterestCategory() : Category{ | ||
return Category.getCategoryByName(category) | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,19 @@ | ||
package com.psr.psr.user.entity | ||
|
||
import com.psr.psr.global.exception.BaseException | ||
import com.psr.psr.global.exception.BaseResponseCode | ||
|
||
|
||
enum class Type(val value: String) { | ||
GENERAL("일반"), | ||
ENTREPRENEUR("사업자"), | ||
SHOW_HOST("쇼호스트"), | ||
MANAGER("관리자") | ||
MANAGER("관리자"); | ||
|
||
companion object { | ||
fun getTypeByName(name: String): Type { | ||
return enumValues<Type>().find { it.value == name } | ||
?: throw BaseException(BaseResponseCode.INVALID_USER_TYPE_NAME) | ||
} | ||
} | ||
} |
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
Oops, something went wrong.