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
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,7 +1,7 @@
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.transaction.annotation.Transactional;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
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;
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.presentation.annotation.Login;
import coffeemeet.server.user.presentation.dto.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,11 +1,11 @@
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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
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;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
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;
Expand All @@ -12,7 +12,7 @@
@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.EmailDto;
import coffeemeet.server.certification.presentation.dto.VerificationCodeDto;
import coffeemeet.server.certification.service.CertificationService;
import coffeemeet.server.common.annotation.Login;
import coffeemeet.server.common.presentation.annotation.Login;
import coffeemeet.server.common.util.FileUtils;
import coffeemeet.server.user.controller.dto.AuthInfo;
import coffeemeet.server.user.presentation.dto.AuthInfo;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package coffeemeet.server.certification.controller.dto;
package coffeemeet.server.certification.presentation.dto;

import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotNull;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package coffeemeet.server.certification.controller.dto;
package coffeemeet.server.certification.presentation.dto;

import jakarta.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;
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.implement.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,8 +1,7 @@
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.execption.InvalidInputException;
import jakarta.persistence.Column;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package coffeemeet.server.chatting.room.domain;
package coffeemeet.server.chatting.message.domain;

import coffeemeet.server.common.entity.BaseEntity;
import jakarta.persistence.Entity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
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.execption.InvalidInputException;
import jakarta.persistence.Column;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
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.user.domain.User;
import jakarta.persistence.Entity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
import org.springframework.context.annotation.Configuration;

@Configuration
public class S3Config {
public class AWSConfig {

private final String accessKey;
private final String secretKey;
private final String region;

public S3Config(
public AWSConfig(
@Value("${cloud.aws.credentials.access-key}") String accessKey,
@Value("${cloud.aws.credentials.secret-key}") String secretKey,
@Value("${cloud.aws.region.static}") String region) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package coffeemeet.server.common.config;

import coffeemeet.server.auth.domain.JwtTokenProvider;
import coffeemeet.server.auth.service.cq.RefreshTokenQuery;
import coffeemeet.server.common.UserArgumentResolver;
import coffeemeet.server.auth.implement.RefreshTokenQuery;
import coffeemeet.server.common.presentation.resolver.UserArgumentResolver;
import coffeemeet.server.oauth.utils.converter.OAuthProviderConverter;
import java.util.List;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package coffeemeet.server.common.media;
package coffeemeet.server.common.implement;

import coffeemeet.server.certification.domain.CompanyEmail;
import org.springframework.beans.factory.annotation.Value;
Expand All @@ -7,12 +7,12 @@
import org.springframework.stereotype.Service;

@Service
public class EmailService {
public class EmailSender {

private final JavaMailSender javaMailSender;
private final String sender;

public EmailService(JavaMailSender javaMailSender,
public EmailSender(JavaMailSender javaMailSender,
@Value("${spring.mail.username}") String sender) {
this.javaMailSender = javaMailSender;
this.sender = sender;
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/coffeemeet/server/common/implement/KeyType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package coffeemeet.server.common.implement;

import lombok.Getter;

@Getter
public enum KeyType {

BUSINESS_CARD("BusinessCard"),
PROFILE_IMAGE("ProfileImage"),
;

private final String value;

KeyType(String value) {
this.value = value;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package coffeemeet.server.common.implement;

import java.io.File;

public interface MediaManager {

void upload(String key, File file);

void delete(String key);

String getUrl(String key);

String generateKey(KeyType keyType);

String extractKey(String s3Url, KeyType keyType);

}
Loading