-
Notifications
You must be signed in to change notification settings - Fork 0
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
[feat] 회원가입 API 생성 #14
Conversation
@@ -21,7 +21,7 @@ class BaseResponse<T> { | |||
constructor(result: T) { | |||
this.code = BaseResponseCode.SUCCESS.status.value() | |||
this.message = BaseResponseCode.SUCCESS.message | |||
this.data = data | |||
this.data = result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분 변경 됐어요 !
result 가 constructor에 반영이 안돼서 !
@@ -3,6 +3,6 @@ package com.psr.psr.global.exception | |||
import org.springframework.http.HttpStatus | |||
|
|||
data class BaseRes( | |||
val status: HttpStatus, | |||
val status: Int, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요 부분도 에러 발생하면 400 에러가 나야하는데 BAD_REQUEST 라고 return 되길래,
숫자로 변경해뒀습니당
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
var id: Long, | ||
var id: Long? = null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
찾아보니까 kotlin은 따로 builder가 없대요 !
객체 생성할 때 필수적이지 않은 경우에는 이렇게 null 일 수 있다고 적어놔야하더라구요
아니면 필수 값으로 착각하여 에러 발생함니당
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
팁줍줍
companion object { | ||
fun getCategoryByName(name: String): Category { | ||
return enumValues<Category>().find { it.value == name } | ||
?: throw BaseException(BaseResponseCode.INVALID_USER_CATEGORY) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
감사.❤️🔥
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
시큐리티도 어려운데 낯선 코틀린으로 뚝딱 해내는 장채니는 무싯다.
// 이메일의 형식이 맞는지 확인 | ||
if(!isValidRegularExpression(signUpReq.email, EMAIL_VALIDATION)) throw BaseException(BaseResponseCode.INVALID_EMAIL) | ||
// 비밀번호의 형식이 맞는지 확인 | ||
if(!isValidRegularExpression(signUpReq.password, PASSWORD_VALIDATION)) throw BaseException(BaseResponseCode.INVALID_PASSWORD) | ||
// 휴대폰 번호의 형식이 맞는지 확인 | ||
if(!isValidRegularExpression(signUpReq.phone, PHONE_VALIDATION)) throw BaseException(BaseResponseCode.INVALID_PHONE) | ||
// Category가 알맞은 이름을 갖고 있는지, 값이 중복되어있는지 확인 | ||
val categoryCheck = signUpReq.interestList.stream().map { i -> i.checkInterestCategory() }.collect(Collectors.toList()).groupingBy { it }.eachCount().any { it.value > 1 } | ||
if(categoryCheck) throw BaseException(BaseResponseCode.INVALID_USER_INTEREST_COUNT) | ||
// category 의 사이즈 확인 | ||
val listSize = signUpReq.interestList.size | ||
if(listSize < 1 || listSize > 3) throw BaseException(BaseResponseCode.INVALID_USER_INTEREST_COUNT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
request 관련 예외처리는 service?! controller?!(어느 경계까지 이 둘을 나눠야 하는지는 저도 잘 모르겠슴니다 ㅜㅅㅜ) /
아니면 @valid
어노테이션으로 처리하는 것도 하나의 방법이 될 것 같네유!
앞서 request에서 작성한 걸 이런식으로 에러핸들링시켜도 깔끔해서 괜찮더라구요!
+) 코틀린에서는 해당 방법으로 사용한다고 하네용 https://devlog-wjdrbs96.tistory.com/407
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
request 관련 예외처리는 service?! controller?!(어느 경계까지 이 둘을 나눠야 하는지는 저도 잘 모르겠슴니다 ㅜㅅㅜ) / 아니면
@valid
어노테이션으로 처리하는 것도 하나의 방법이 될 것 같네유!
저는 request 관련 처리는 controller에서 한다고 많이 들었어요..! 하지만 @valid
너무 조아요!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
제가 알기로두 controller에서 하는걸루 알고있슴니다! 저번 플젝에서 서비스 단에서 모두 처리해서, 일단 서비스 단에 넣어뒀서욤,,,!
valid 너무 좋아요! 적용해서 다시 올려둘게요🤍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그녀는 그냥 최고일 뿐이예요....😮
🌱 이슈 번호
close #12
💬 기타 사항
다 만들고 보니,, 관심 주제를 안만들어서,, 만들고 커밋 올릴게유,,,, ㅎㅎ,,,-> 생성완