-
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/#46 Certification 테이블 생성, 회사 인증 등록 API 구현 #53
Merged
Changes from 21 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
8162eb4
refactor: User 내부 컬럼으로 관리했던 인증 정보 추출해서 Certification Table 생성
smartandhandsome 7d72ae3
feat: CertificationRepository 구현
smartandhandsome 123c43b
test: CertificationRepository 테스트
smartandhandsome c59ae59
test: Certification 픽스처 생성
smartandhandsome 3c1e630
refactor: final 추가
smartandhandsome 505a0e1
refactor: import 제거
smartandhandsome d07e2b6
refactor: 변경된 필드명으로 메서드 이름 변경
smartandhandsome efdcc23
refactor: table 분리로 인해 연관 없어진 메서드 제거
smartandhandsome 58c74b1
refactor: table 분리로 인한 response 변경
smartandhandsome 1a85025
refactor: 순환참조가 발생해서 Service와 Repository 사이 Repository 가공 Layer 생성
smartandhandsome c135bf8
refactor: PK와 FK(user_id) 동일하게 설정
smartandhandsome 6409889
refactor: 닉네임 조회 -> 아이디 조회로 변경
smartandhandsome ff0caaf
refactor: 다른 도메인의 서비스 의존이 아닌 Repository 가공 클래스 의존으로 변경
smartandhandsome f80907c
feat: 회사 정보 등록 api 구현
smartandhandsome 359b2fc
refactor: DTO 컨벤션에 맞게 변경
smartandhandsome 0c88f42
feat: repository 가공 클래스 생성
smartandhandsome d95a464
refactor: class 명 수정
smartandhandsome 1abc25d
refactor: 레포지토리 가공 테이블 필드 설정
smartandhandsome 69c41df
refactor: Transactional(readOnly = true) 추가
smartandhandsome b059c93
refactor: 상수 삭제
smartandhandsome 0d54dee
refactor: 불필요한 Transactional 삭제
smartandhandsome 63860cb
Merge branch 'dev' into feat/#46
257ef54
fix: merge conflict 오류 수정
a4982e7
refactor: applyIfCertifiedUser 위치 command로 변경
smartandhandsome 948910f
refactor: 사용하지 않는 메서드 삭제
smartandhandsome fd1ce0b
Merge branch 'feat/#46' of https://github.com/coffee-meet/backend int…
smartandhandsome File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
58 changes: 58 additions & 0 deletions
58
src/main/java/coffeemeet/server/certification/domain/Certification.java
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,58 @@ | ||
package coffeemeet.server.certification.domain; | ||
|
||
import coffeemeet.server.common.entity.AdvancedBaseEntity; | ||
import coffeemeet.server.user.domain.User; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Embedded; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.MapsId; | ||
import jakarta.persistence.OneToOne; | ||
import jakarta.persistence.Table; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.NonNull; | ||
|
||
@Entity | ||
@Getter | ||
@Table(name = "certifications") | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class Certification extends AdvancedBaseEntity { | ||
|
||
@Id | ||
private Long id; | ||
|
||
@MapsId | ||
@OneToOne(fetch = FetchType.LAZY) | ||
private User user; | ||
|
||
@Embedded | ||
@Column(nullable = false) | ||
private CompanyEmail companyEmail; | ||
|
||
@Column(nullable = false) | ||
private String businessCardUrl; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private Department department; | ||
|
||
@Column(nullable = false) | ||
private boolean isCertificated; | ||
|
||
@Builder | ||
private Certification( | ||
@NonNull CompanyEmail companyEmail, @NonNull String businessCardUrl, | ||
@NonNull Department department, @NonNull User user) { | ||
this.companyEmail = companyEmail; | ||
this.businessCardUrl = businessCardUrl; | ||
this.department = department; | ||
this.isCertificated = false; | ||
this.user = user; | ||
} | ||
|
||
} |
15 changes: 9 additions & 6 deletions
15
...meet/server/user/domain/CompanyEmail.java → ...er/certification/domain/CompanyEmail.java
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
5 changes: 5 additions & 0 deletions
5
src/main/java/coffeemeet/server/certification/domain/Department.java
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,5 @@ | ||
package coffeemeet.server.certification.domain; | ||
|
||
public enum Department { | ||
IT, MANAGEMENT, SALES, DISTRIBUTION, DESIGN, MANUFACTURING, RESEARCH_AND_DEVELOPMENT, MARKETING, PLANNING | ||
} |
1 change: 0 additions & 1 deletion
1
src/main/java/coffeemeet/server/certification/domain/EmailVerification.java
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
16 changes: 16 additions & 0 deletions
16
src/main/java/coffeemeet/server/certification/repository/CertificationRepository.java
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,16 @@ | ||
package coffeemeet.server.certification.repository; | ||
|
||
import coffeemeet.server.certification.domain.Certification; | ||
import coffeemeet.server.certification.domain.CompanyEmail; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface CertificationRepository extends JpaRepository<Certification, Long> { | ||
|
||
Optional<Certification> findByUserId(Long userId); | ||
|
||
boolean existsByCompanyEmail(CompanyEmail companyEmail); | ||
|
||
boolean existsByUserId(Long userId); | ||
|
||
} |
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
37 changes: 37 additions & 0 deletions
37
src/main/java/coffeemeet/server/certification/service/cq/CertificationCommand.java
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,37 @@ | ||
package coffeemeet.server.certification.service.cq; | ||
|
||
import coffeemeet.server.certification.domain.Certification; | ||
import coffeemeet.server.certification.domain.CompanyEmail; | ||
import coffeemeet.server.certification.domain.Department; | ||
import coffeemeet.server.certification.repository.CertificationRepository; | ||
import coffeemeet.server.user.domain.User; | ||
import java.util.function.Consumer; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Transactional | ||
@RequiredArgsConstructor | ||
@Service | ||
public class CertificationCommand { | ||
|
||
private final CertificationRepository certificationRepository; | ||
|
||
public void newCertification(CompanyEmail companyEmail, String businessCardUrl, | ||
Department department, User user) { | ||
certificationRepository.save( | ||
Certification.builder() | ||
.companyEmail(companyEmail) | ||
.businessCardUrl(businessCardUrl) | ||
.department(department) | ||
.user(user) | ||
.build() | ||
); | ||
} | ||
|
||
@Transactional(readOnly = true) | ||
public void applyIfCertifiedUser(Long userId, Consumer<? super Certification> consumer) { | ||
certificationRepository.findByUserId(userId).ifPresent(consumer); | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/coffeemeet/server/certification/service/cq/CertificationQuery.java
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 coffeemeet.server.certification.service.cq; | ||
|
||
import coffeemeet.server.certification.domain.Certification; | ||
import coffeemeet.server.certification.domain.CompanyEmail; | ||
import coffeemeet.server.certification.repository.CertificationRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Transactional(readOnly = true) | ||
@RequiredArgsConstructor | ||
@Service | ||
public class CertificationQuery { | ||
|
||
public static final String CERTIFICATION_NOT_FOUND = "해당 사용자의 인증정보를 찾을 수 없습니다."; | ||
private static final String EXISTED_COMPANY_EMAIL = "이미 사용 중인 회사 이메일입니다."; | ||
|
||
private final CertificationRepository certificationRepository; | ||
|
||
public Certification getCertificationByUserId(Long userId) { | ||
return certificationRepository.findByUserId(userId) | ||
.orElseThrow(() -> new IllegalArgumentException(CERTIFICATION_NOT_FOUND)); | ||
} | ||
|
||
public void checkDuplicatedCompanyEmail(CompanyEmail companyEmail) { | ||
if (certificationRepository.existsByCompanyEmail(companyEmail)) { | ||
throw new IllegalArgumentException(EXISTED_COMPANY_EMAIL); | ||
} | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Command로 보아야 될지 Query로 보아야 할 지 잘 모르겠습니다.
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.
저는 Query로 보는게 맞다고 생각됩니다