-
Notifications
You must be signed in to change notification settings - Fork 1
[FEATURE] 유저 회원가입 추가 #303
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
[FEATURE] 유저 회원가입 추가 #303
Changes from 39 commits
44582bf
bee71b7
026c007
845a4f4
c6db672
f7a79b6
46679be
9d3165c
dde36b1
3c4ba14
9918101
94c3c1b
b8c6183
b76f26c
50a1c8b
6ff9da4
df5b987
93fd118
a12f35a
9eee78d
e9ac763
bfa4b8f
e0be3d4
157721c
b2f4fbf
7fb327c
a2a259d
b8dc96b
d67b326
ec45219
49f3b3f
a809255
302dfa9
d844619
d43f091
388a618
678c3a2
6c8230b
71b5df0
5f66a07
ca2bd24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package com.somemore.center.domain; | ||
|
|
||
| import com.somemore.global.common.entity.BaseEntity; | ||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.Table; | ||
| import lombok.AccessLevel; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| import java.util.UUID; | ||
|
|
||
| @Getter | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| @Entity | ||
| @Table(name = "new_center") // TODO prefix 삭제 | ||
| public class NEWCenter extends BaseEntity { | ||
|
|
||
| public static final String DEFAULT_NAME = "기관"; | ||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.UUID) | ||
| @Column(name = "id", nullable = false, columnDefinition = "BINARY(16)") | ||
| private UUID id; | ||
|
|
||
| @Column(name = "user_id", nullable = false, columnDefinition = "BINARY(16)") | ||
| private UUID userId; | ||
|
|
||
| @Column(name = "name", nullable = false) | ||
| private String name; | ||
|
||
|
|
||
| @Column(name = "homepage_url", nullable = false) | ||
| private String homepageUrl; | ||
|
|
||
| @Builder | ||
| private NEWCenter(UUID userId, String name, String homepageUrl) { | ||
| this.userId = userId; | ||
| this.name = name; | ||
| this.homepageUrl = homepageUrl; | ||
| } | ||
|
|
||
| public static NEWCenter createDefault(UUID userId) { | ||
| return NEWCenter.builder() | ||
| .userId(userId) | ||
| .name(DEFAULT_NAME + userId.toString().substring(0, 8)) | ||
| .homepageUrl("") | ||
| .build(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.somemore.center.repository; | ||
|
|
||
| import com.somemore.center.domain.NEWCenter; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| import java.util.UUID; | ||
|
|
||
| @Repository("newCenterJpaRepository") | ||
| public interface NEWCenterJpaRepository extends JpaRepository<NEWCenter, UUID> { | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.somemore.center.repository; | ||
|
|
||
| import com.somemore.center.domain.NEWCenter; | ||
|
|
||
| import java.util.Optional; | ||
| import java.util.UUID; | ||
|
|
||
| public interface NEWCenterRepository { | ||
|
|
||
| NEWCenter save(NEWCenter center); | ||
|
|
||
| Optional<NEWCenter> findById(UUID id); | ||
|
|
||
| Optional<NEWCenter> findByUserId(UUID userId); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| package com.somemore.center.repository; | ||
|
|
||
| import com.querydsl.jpa.impl.JPAQueryFactory; | ||
| import com.somemore.center.domain.NEWCenter; | ||
| import com.somemore.center.domain.QNEWCenter; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| import java.util.Optional; | ||
| import java.util.UUID; | ||
|
|
||
| @Repository("newCenterRepository") | ||
| @RequiredArgsConstructor | ||
| public class NEWCenterRepositoryImpl implements NEWCenterRepository { | ||
|
|
||
| private final NEWCenterJpaRepository NEWCenterJpaRepository; | ||
| private final JPAQueryFactory queryFactory; | ||
|
|
||
| private static final QNEWCenter center = QNEWCenter.nEWCenter; | ||
|
|
||
| @Override | ||
| public NEWCenter save(NEWCenter center) { | ||
| return NEWCenterJpaRepository.save(center); | ||
| } | ||
|
|
||
| @Override | ||
| public Optional<NEWCenter> findById(UUID id) { | ||
| return Optional.ofNullable( | ||
| queryFactory.selectFrom(center) | ||
| .where( | ||
| center.id.eq(id), | ||
| center.deleted.eq(false)) | ||
| .fetchOne() | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public Optional<NEWCenter> findByUserId(UUID userId) { | ||
| return Optional.ofNullable( | ||
| queryFactory.selectFrom(center) | ||
| .where( | ||
| center.userId.eq(userId), | ||
| center.deleted.eq(false)) | ||
| .fetchOne() | ||
|
|
||
| ); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package com.somemore.center.service; | ||
|
|
||
| import com.somemore.center.domain.NEWCenter; | ||
| import com.somemore.center.repository.NEWCenterRepository; | ||
| import com.somemore.center.usecase.NEWRegisterCenterUseCase; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import java.util.UUID; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| @Transactional | ||
| public class NEWRegisterCenterService implements NEWRegisterCenterUseCase { | ||
|
|
||
| private final NEWCenterRepository NEWCenterRepository; | ||
|
|
||
| @Override | ||
| public NEWCenter register(UUID userId) { | ||
| NEWCenter center = NEWCenter.createDefault(userId); | ||
| return NEWCenterRepository.save(center); | ||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NEWCenter 엔티티 클래스를 반환하는 이유가 혹시 있으신가요? 없다면 id 정도만 반환하는게 좋아보입니다.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 리뷰보고 고민하다가 좋은 인사이트를 얻었네요.. |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.somemore.center.usecase; | ||
|
|
||
| import com.somemore.center.domain.NEWCenter; | ||
|
|
||
| import java.util.UUID; | ||
|
|
||
| public interface NEWRegisterCenterUseCase { | ||
|
|
||
| NEWCenter register(UUID userId); | ||
| } |
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.
public으로 열여둔 이유가 있으신가요? 다른데에서 사용되지 않으면 private가 좋아보입니당
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.
그렇네요! 메서드 내부에서만 사용해야겠어요~