Skip to content
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

Merged
merged 7 commits into from
Jul 26, 2023
Merged

[feat] 회원가입 API 생성 #14

merged 7 commits into from
Jul 26, 2023

Conversation

chaerlo127
Copy link
Collaborator

@chaerlo127 chaerlo127 commented Jul 26, 2023

🌱 이슈 번호

close #12


💬 기타 사항

  • API 생성하면서 기존 코드 변경된 부분이 있습니당 아래 리뷰에 적어둘게요!
  • 다 만들고 보니,, 관심 주제를 안만들어서,, 만들고 커밋 올릴게유,,,, ㅎㅎ,,, -> 생성완

@chaerlo127 chaerlo127 added 🔮 feat 기능을 생성해요 ! 🐣 chae-eun 채은이가 만든 기능이에요 ! 🕸️ fix 버그 코드를 수정해요 ! labels Jul 26, 2023
@chaerlo127 chaerlo127 self-assigned this Jul 26, 2023
@@ -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
Copy link
Collaborator Author

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,
Copy link
Collaborator Author

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,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

찾아보니까 kotlin은 따로 builder가 없대요 !
객체 생성할 때 필수적이지 않은 경우에는 이렇게 null 일 수 있다고 적어놔야하더라구요
아니면 필수 값으로 착각하여 에러 발생함니당

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

팁줍줍

Comment on lines +17 to +22
companion object {
fun getCategoryByName(name: String): Category {
return enumValues<Category>().find { it.value == name }
?: throw BaseException(BaseResponseCode.INVALID_USER_CATEGORY)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

감사.❤️‍🔥

Copy link
Member

@sojungpp sojungpp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

시큐리티도 어려운데 낯선 코틀린으로 뚝딱 해내는 장채니는 무싯다.

Comment on lines +38 to +49
// 이메일의 형식이 맞는지 확인
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)
Copy link
Member

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, 스프링)
스크린샷 2023-07-26 오후 11 14 21

앞서 request에서 작성한 걸 이런식으로 에러핸들링시켜도 깔끔해서 괜찮더라구요!

스크린샷 2023-07-26 오후 11 21 15

+) 코틀린에서는 해당 방법으로 사용한다고 하네용 https://devlog-wjdrbs96.tistory.com/407

Copy link
Member

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 너무 조아요!!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제가 알기로두 controller에서 하는걸루 알고있슴니다! 저번 플젝에서 서비스 단에서 모두 처리해서, 일단 서비스 단에 넣어뒀서욤,,,!
valid 너무 좋아요! 적용해서 다시 올려둘게요🤍

Copy link
Member

@psyeon1120 psyeon1120 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그녀는 그냥 최고일 뿐이예요....😮

@chaerlo127 chaerlo127 merged commit 7f55ffb into develop Jul 26, 2023
1 check passed
@chaerlo127 chaerlo127 deleted the feat/#12-signup branch July 31, 2023 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐣 chae-eun 채은이가 만든 기능이에요 ! 🔮 feat 기능을 생성해요 ! 🕸️ fix 버그 코드를 수정해요 !
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feat] 회원가입 API
3 participants