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/#76 아키텍처 정의에 따른 패키지 및 클래스 이름 변경 #77

Merged
merged 11 commits into from
Nov 2, 2023
2 changes: 1 addition & 1 deletion src/main/java/coffeemeet/server/admin/domain/Admin.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package coffeemeet.server.admin.domain;

import coffeemeet.server.common.entity.BaseEntity;
import coffeemeet.server.common.domain.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package coffeemeet.server.auth.domain;

import coffeemeet.server.auth.service.cq.RefreshTokenCommand;
import coffeemeet.server.auth.implement.RefreshTokenCommand;
import java.util.Date;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package coffeemeet.server.auth.service.cq;
package coffeemeet.server.auth.implement;

import coffeemeet.server.auth.domain.RefreshToken;
import coffeemeet.server.auth.repository.RefreshTokenRepository;
import coffeemeet.server.auth.infrastructure.RefreshTokenRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Service
@Component
@Transactional
@RequiredArgsConstructor
public class RefreshTokenCommand {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package coffeemeet.server.auth.service.cq;
package coffeemeet.server.auth.implement;

import static coffeemeet.server.auth.exception.AuthErrorCode.AUTHENTICATION_FAILED;

import coffeemeet.server.auth.domain.RefreshToken;
import coffeemeet.server.auth.repository.RefreshTokenRepository;
import coffeemeet.server.auth.infrastructure.RefreshTokenRepository;
import coffeemeet.server.common.execption.InvalidInputException;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Service
@Component
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class RefreshTokenQuery {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package coffeemeet.server.auth.repository;
package coffeemeet.server.auth.infrastructure;

import coffeemeet.server.auth.domain.RefreshToken;
import org.springframework.data.repository.CrudRepository;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package coffeemeet.server.auth.controller;
package coffeemeet.server.auth.presentation;

import coffeemeet.server.auth.domain.AuthTokens;
import coffeemeet.server.auth.service.AuthService;
import coffeemeet.server.common.annotation.Login;
import coffeemeet.server.user.controller.dto.AuthInfo;
import coffeemeet.server.common.domain.AuthInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import coffeemeet.server.auth.domain.AuthTokens;
import coffeemeet.server.auth.domain.AuthTokensGenerator;
import coffeemeet.server.auth.domain.JwtTokenProvider;
import coffeemeet.server.auth.service.cq.RefreshTokenCommand;
import coffeemeet.server.auth.implement.RefreshTokenCommand;
import coffeemeet.server.common.execption.InvalidAuthException;
import coffeemeet.server.user.service.UserService;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package coffeemeet.server.certification.domain;

import coffeemeet.server.common.entity.AdvancedBaseEntity;
import coffeemeet.server.common.domain.AdvancedBaseEntity;
import coffeemeet.server.user.domain.User;
import jakarta.persistence.Column;
import jakarta.persistence.Embedded;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package coffeemeet.server.certification.service.cq;
package coffeemeet.server.certification.implement;

import static coffeemeet.server.certification.exception.CertificationErrorCode.EXISTED_COMPANY_EMAIL;

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.certification.infrastructure.CertificationRepository;
import coffeemeet.server.common.execption.InvalidInputException;
import coffeemeet.server.user.domain.User;
import java.util.function.Consumer;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Service
@Component
@Transactional
@RequiredArgsConstructor
public class CertificationCommand {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package coffeemeet.server.certification.service.cq;
package coffeemeet.server.certification.implement;

import static coffeemeet.server.certification.exception.CertificationErrorCode.CERTIFICATION_NOT_FOUND;

import coffeemeet.server.certification.domain.Certification;
import coffeemeet.server.certification.repository.CertificationRepository;
import coffeemeet.server.certification.infrastructure.CertificationRepository;
import coffeemeet.server.common.execption.InvalidInputException;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Service
@Component
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class CertificationQuery {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package coffeemeet.server.certification.service.cq;
package coffeemeet.server.certification.implement;

import coffeemeet.server.certification.domain.CompanyEmail;
import coffeemeet.server.certification.domain.EmailVerification;
import coffeemeet.server.certification.repository.EmailVerificationRepository;
import coffeemeet.server.certification.infrastructure.EmailVerificationRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Component;

@Service
@Component
@RequiredArgsConstructor
public class EmailVerificationCommand {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package coffeemeet.server.certification.service.cq;
package coffeemeet.server.certification.implement;

import static coffeemeet.server.certification.exception.CertificationErrorCode.VERIFICATION_CODE_NOT_FOUND;

import coffeemeet.server.certification.domain.EmailVerification;
import coffeemeet.server.certification.repository.EmailVerificationRepository;
import coffeemeet.server.certification.infrastructure.EmailVerificationRepository;
import coffeemeet.server.common.execption.InvalidInputException;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Component;

@Service
@Component
@RequiredArgsConstructor
public class EmailVerificationQuery {

private static final String VERIFICATION_CODE_NOT_FOUND_MESSAGE = "인증코드 기간이 만료되었거나 해당 유저(%s)가 인증 번호를 요청한 기록이 없습니다.";
private static final String VERIFICATION_CODE_NOT_FOUND_MESSAGE = "인증코드 기간이 만료되었거나 해당 유저(%s)가 인증코드를 요청한 기록이 없습니다.";

private final EmailVerificationRepository emailVerificationRepository;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package coffeemeet.server.certification.repository;
package coffeemeet.server.certification.infrastructure;

import coffeemeet.server.certification.domain.Certification;
import coffeemeet.server.certification.domain.CompanyEmail;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package coffeemeet.server.certification.repository;
package coffeemeet.server.certification.infrastructure;

import coffeemeet.server.certification.domain.EmailVerification;
import org.springframework.data.repository.CrudRepository;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package coffeemeet.server.certification.controller;
package coffeemeet.server.certification.presentation;

import coffeemeet.server.certification.controller.dto.EmailDto;
import coffeemeet.server.certification.controller.dto.VerificationCodeDto;
import coffeemeet.server.certification.presentation.dto.EmailHTTP;
import coffeemeet.server.certification.presentation.dto.VerificationCodeHTTP;
import coffeemeet.server.certification.service.CertificationService;
import coffeemeet.server.common.annotation.Login;
import coffeemeet.server.common.domain.AuthInfo;
import coffeemeet.server.common.util.FileUtils;
import coffeemeet.server.user.controller.dto.AuthInfo;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -39,7 +39,7 @@ public ResponseEntity<Void> registerCompanyInfo(
@PostMapping("/users/me/company-mail")
public ResponseEntity<Void> sendVerificationCodeByEmail(
@Login AuthInfo authInfo,
@Valid @RequestBody EmailDto.Request request
@Valid @RequestBody EmailHTTP.Request request
) {
certificationService.sendVerificationMail(authInfo.userId(), request.companyEmail());
return ResponseEntity.ok().build();
Expand All @@ -48,7 +48,7 @@ public ResponseEntity<Void> sendVerificationCodeByEmail(
@PostMapping("/users/me/company-mail/verification")
public ResponseEntity<Void> verifyEmail(
@Login AuthInfo authInfo,
@Valid @RequestBody VerificationCodeDto.Request request
@Valid @RequestBody VerificationCodeHTTP.Request request
) {
certificationService.compareCode(authInfo.userId(), request.verificationCode());
return ResponseEntity.ok().build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package coffeemeet.server.certification.controller.dto;
package coffeemeet.server.certification.presentation.dto;

import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotNull;

public sealed interface EmailDto permits EmailDto.Request {
public sealed interface EmailHTTP permits EmailHTTP.Request {

record Request(
@Email @NotNull
String companyEmail
) implements EmailDto {
) implements EmailHTTP {

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package coffeemeet.server.certification.controller.dto;
package coffeemeet.server.certification.presentation.dto;

import jakarta.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;

public sealed interface VerificationCodeDto permits VerificationCodeDto.Request {
public sealed interface VerificationCodeHTTP permits VerificationCodeHTTP.Request {

record Request(
@NotNull @Length(min = 6, max = 6)
String verificationCode
) implements VerificationCodeDto {
) implements VerificationCodeHTTP {

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package coffeemeet.server.certification.service;

import static coffeemeet.server.certification.exception.CertificationErrorCode.INVALID_VERIFICATION_CODE;
import static coffeemeet.server.common.media.S3MediaService.KeyType.BUSINESS_CARD;
import static coffeemeet.server.common.domain.KeyType.BUSINESS_CARD;

import coffeemeet.server.certification.domain.CompanyEmail;
import coffeemeet.server.certification.domain.Department;
import coffeemeet.server.certification.service.cq.CertificationCommand;
import coffeemeet.server.certification.service.cq.EmailVerificationCommand;
import coffeemeet.server.certification.service.cq.EmailVerificationQuery;
import coffeemeet.server.certification.implement.CertificationCommand;
import coffeemeet.server.certification.implement.EmailVerificationCommand;
import coffeemeet.server.certification.implement.EmailVerificationQuery;
import coffeemeet.server.common.execption.InvalidInputException;
import coffeemeet.server.common.media.EmailService;
import coffeemeet.server.common.media.S3MediaService;
import coffeemeet.server.common.implement.EmailSender;
import coffeemeet.server.common.implement.MediaManager;
import coffeemeet.server.common.util.FileUtils;
import coffeemeet.server.user.domain.User;
import coffeemeet.server.user.service.cq.UserQuery;
import coffeemeet.server.user.implement.UserQuery;
import java.io.File;
import java.util.random.RandomGenerator;
import lombok.RequiredArgsConstructor;
Expand All @@ -26,32 +26,32 @@ public class CertificationService {
private static final String WRONG_VERIFICATION_CODE_MESSAGE = "사용자(%s)가 잘못된 인증코드(%s)를 입력했습니다.";
private static final RandomGenerator RANDOM_GENERATOR = RandomGenerator.getDefault();

private final S3MediaService s3MediaService;
private final EmailService emailService;
private final MediaManager mediaManager;
private final EmailSender emailSender;
private final UserQuery userQuery;
private final CertificationCommand certificationCommand;
private final EmailVerificationCommand emailVerificationCommand;
private final EmailVerificationQuery emailVerificationQuery;

public void registerCertification(long userId, String email, String departmentName,
File businessCardImage) {
String key = s3MediaService.generateKey(BUSINESS_CARD);
String key = mediaManager.generateKey(BUSINESS_CARD);
uploadBusinessCard(userId, key, businessCardImage);

CompanyEmail companyEmail = new CompanyEmail(email);
String businessCardUrl = s3MediaService.getUrl(key);
String businessCardUrl = mediaManager.getUrl(key);
Department department = Department.valueOf(departmentName);
User user = userQuery.getUserById(userId);
certificationCommand.createCertification(companyEmail, businessCardUrl, department, user);
}

private void uploadBusinessCard(long userId, String key, File businessCardUrl) {
certificationCommand.applyIfCertifiedUser(userId, certification -> {
String oldKey = s3MediaService.extractKey(certification.getBusinessCardUrl(), BUSINESS_CARD);
s3MediaService.delete(oldKey);
String oldKey = mediaManager.extractKey(certification.getBusinessCardUrl(), BUSINESS_CARD);
mediaManager.delete(oldKey);
});

s3MediaService.upload(key, businessCardUrl);
mediaManager.upload(key, businessCardUrl);
FileUtils.delete(businessCardUrl);
}

Expand All @@ -60,7 +60,7 @@ public void sendVerificationMail(Long userId, String email) {
certificationCommand.hasDuplicatedCompanyEmail(companyEmail);

String verificationCode = generateVerificationCode();
emailService.sendVerificationCode(companyEmail, verificationCode);
emailSender.sendVerificationCode(companyEmail, verificationCode);
emailVerificationCommand.createEmailVerification(userId, companyEmail, verificationCode);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package coffeemeet.server.chatting.message.exception;
package coffeemeet.server.chatting.exception;

import coffeemeet.server.common.execption.ErrorCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum MessageErrorCode implements ErrorCode {
public enum ChattingErrorCode implements ErrorCode {
INVALID_MESSAGE("CM000", "유효하지 않은 메세지 형식입니다."),
;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package coffeemeet.server.chatting.message.domain;

import static coffeemeet.server.chatting.message.exception.MessageErrorCode.INVALID_MESSAGE;
import static coffeemeet.server.chatting.exception.ChattingErrorCode.INVALID_MESSAGE;

import coffeemeet.server.chatting.room.domain.ChattingRoom;
import coffeemeet.server.common.entity.BaseEntity;
import coffeemeet.server.common.domain.BaseEntity;
import coffeemeet.server.common.execption.InvalidInputException;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package coffeemeet.server.chatting.room.domain;
package coffeemeet.server.chatting.message.domain;

import coffeemeet.server.common.entity.BaseEntity;
import coffeemeet.server.common.domain.BaseEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package coffeemeet.server.chatting.message.domain;
package coffeemeet.server.chatting.room.domain;

import static coffeemeet.server.chatting.message.exception.MessageErrorCode.INVALID_MESSAGE;
import static coffeemeet.server.chatting.exception.ChattingErrorCode.INVALID_MESSAGE;

import coffeemeet.server.chatting.room.domain.ChattingRoomHistory;
import coffeemeet.server.common.entity.BaseEntity;
import coffeemeet.server.common.domain.BaseEntity;
import coffeemeet.server.common.execption.InvalidInputException;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package coffeemeet.server.chatting.room.domain;

import coffeemeet.server.common.entity.BaseEntity;
import coffeemeet.server.common.domain.BaseEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package coffeemeet.server.user_chatting_history.domain;
package coffeemeet.server.chatting.room.domain;

import coffeemeet.server.chatting.room.domain.ChattingRoomHistory;
import coffeemeet.server.common.entity.BaseEntity;
import coffeemeet.server.common.domain.BaseEntity;
import coffeemeet.server.user.domain.User;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
Expand Down
Loading