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

배포 0. #230

Merged
merged 24 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
825e850
feat: 비동기 처리를 위한 Thread Pool 설정
smartandhandsome Jan 12, 2024
72a2c51
refactor: setWaitForTasksToCompleteOnShutdown 추가
smartandhandsome Jan 12, 2024
620bf4a
Merge pull request #224 from coffee-meet/feat/#221
smartandhandsome Jan 13, 2024
236acff
refactor: 토큰 만료 에러코드 세분화
smartandhandsome Jan 16, 2024
92044e5
Merge pull request #226 from coffee-meet/feat/#225
smartandhandsome Jan 16, 2024
e3afbca
feat: 타입 안정성을 위한 객체 생성
smartandhandsome Jan 16, 2024
8d8ec46
feat: 이메일 전송 비동기 처리
smartandhandsome Jan 16, 2024
f35a849
test: 메인코드 변경에 따른 테스트코드 수정
smartandhandsome Jan 16, 2024
26904ca
refactor: 가독성을 향상을 위한 리팩토링
smartandhandsome Feb 1, 2024
1e29eff
refactor: Transaction을 Service 레이어에서 관리하도록 변경
smartandhandsome Feb 1, 2024
9f2e896
refactor: InquiryCommand Transactional 제거 및 버그 수정
smartandhandsome Feb 1, 2024
2b8cb1e
refactor: deleteUserByUserId 중복제거
smartandhandsome Feb 1, 2024
7db0d68
refactor: TransactionalEventListener로 리팩터링
smartandhandsome Feb 1, 2024
1260661
refactor: AdminRepository domain으로 package 변경
smartandhandsome Feb 1, 2024
80f99b5
refactor: MatchingService 구조 리팩터링 및 알림 전송 Event 형식으로 리펙터링
smartandhandsome Feb 1, 2024
74667b3
refactor: MatchingService 구조 리팩터링 및 알림 전송 Event 형식으로 리펙터링
smartandhandsome Feb 1, 2024
948e038
refactor: ChattingService 구조 및 가독성을 위한 리팩터링 및 알림 전송 Event 형식으로 변경
smartandhandsome Feb 2, 2024
3317c58
test: 테스트 수정
smartandhandsome Feb 2, 2024
5e56fb3
fix: 사용자 프로필 변경 오류 수정 및 리팩터링
smartandhandsome Feb 2, 2024
1dbdc61
Merge pull request #228 from coffee-meet/feat/#223
smartandhandsome Feb 4, 2024
08eafe8
Merge pull request #229 from coffee-meet/hotfix
smartandhandsome Feb 4, 2024
863c476
chore: 테스트 위한 주석 삭제
smartandhandsome Feb 4, 2024
0dc9e20
fix: 다른 메서드 사용 수정
smartandhandsome Feb 5, 2024
9a61053
feat: update create
Feb 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package coffeemeet.server.admin.infrastructure;
package coffeemeet.server.admin.domain;

import coffeemeet.server.admin.domain.Admin;
import org.springframework.data.jpa.repository.JpaRepository;

public interface AdminRepository extends JpaRepository<Admin, String> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package coffeemeet.server.admin.implement;

import static coffeemeet.server.common.execption.GlobalErrorCode.VALIDATION_ERROR;

import coffeemeet.server.admin.domain.Admin;
import coffeemeet.server.common.execption.NotFoundException;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class AdminAccountValidator {

private static final String PASSWORD_VALIDATION_ERROR_MESSAGE = "유효하지 않은 관리자 비밀번호(%s)입니다.";

private final AdminQuery adminQuery;

public void validate(String id, String password) {
Admin admin = adminQuery.getById(id);
if (!admin.isCorrectPassword(password)) {
throw new NotFoundException(VALIDATION_ERROR,
String.format(PASSWORD_VALIDATION_ERROR_MESSAGE, password));
}
}

}
17 changes: 5 additions & 12 deletions src/main/java/coffeemeet/server/admin/implement/AdminQuery.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package coffeemeet.server.admin.implement;


import static coffeemeet.server.common.execption.GlobalErrorCode.VALIDATION_ERROR;
import static coffeemeet.server.admin.exception.AdminErrorCode.INVALID_LOGIN_REQUEST;

import coffeemeet.server.admin.domain.Admin;
import coffeemeet.server.admin.infrastructure.AdminRepository;
import coffeemeet.server.admin.domain.AdminRepository;
import coffeemeet.server.common.execption.NotFoundException;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
Expand All @@ -14,20 +14,13 @@
public class AdminQuery {

private static final String ID_VALIDATION_ERROR_MESSAGE = "유효하지 않은 관리자 아이디(%s)입니다.";
private static final String PASSWORD_VALIDATION_ERROR_MESSAGE = "유효하지 않은 관리자 비밀번호(%s)입니다.";

private final AdminRepository adminRepository;

public void checkIdAndPassword(String id, String password) {
Admin admin = adminRepository.findById(id)
.orElseThrow(() -> new NotFoundException(VALIDATION_ERROR,
public Admin getById(String id) {
return adminRepository.findById(id)
.orElseThrow(() -> new NotFoundException(INVALID_LOGIN_REQUEST,
String.format(ID_VALIDATION_ERROR_MESSAGE, id)));

if (admin.isCorrectPassword(password)) {
return;
}
throw new NotFoundException(VALIDATION_ERROR,
String.format(PASSWORD_VALIDATION_ERROR_MESSAGE, password));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import coffeemeet.server.certification.service.CertificationService;
import coffeemeet.server.certification.service.dto.PendingCertification;
import coffeemeet.server.certification.service.dto.PendingCertificationPageDto;
import coffeemeet.server.common.annotation.PerformanceMeasurement;
import coffeemeet.server.inquiry.presentation.dto.InquiryDetailHTTP;
import coffeemeet.server.inquiry.service.InquiryService;
import coffeemeet.server.inquiry.service.dto.InquiryDetailDto;
Expand Down Expand Up @@ -110,7 +109,7 @@ public ResponseEntity<Void> assignReportPenalty(
// if (adminId == null) {
// throw new InvalidAuthException(NOT_AUTHORIZED, REQUEST_WITHOUT_SESSION_MESSAGE);
// }
adminService.punishUser(targetedId, request.reportIds());
adminService.approveReport(targetedId, request.reportIds());
return ResponseEntity.ok().build();
}

Expand Down Expand Up @@ -200,8 +199,6 @@ public ResponseEntity<Void> checkInquiry(
return ResponseEntity.ok().build();
}

// TODO: 11/27/23 임시로 페이징(옵셋 기반) 처리, 개선 필요
@PerformanceMeasurement
@GetMapping("/certifications/pending")
public ResponseEntity<AdminCustomPage<PendingCertification>> getPendingCertifications(
@SessionAttribute(name = ADMIN_SESSION_ATTRIBUTE, required = false) String adminId,
Expand Down
69 changes: 24 additions & 45 deletions src/main/java/coffeemeet/server/admin/service/AdminService.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
package coffeemeet.server.admin.service;

import static coffeemeet.server.user.domain.UserStatus.MATCHING;

import coffeemeet.server.admin.implement.AdminQuery;
import coffeemeet.server.admin.implement.AdminAccountValidator;
import coffeemeet.server.certification.implement.CertificationCommand;
import coffeemeet.server.certification.implement.CertificationQuery;
import coffeemeet.server.common.infrastructure.FCMNotificationSender;
import coffeemeet.server.inquiry.domain.Inquiry;
import coffeemeet.server.inquiry.implement.InquiryCommand;
import coffeemeet.server.inquiry.implement.InquiryQuery;
import coffeemeet.server.matching.implement.MatchingQueueCommand;
import coffeemeet.server.report.implement.ReportCommand;
import coffeemeet.server.user.domain.NotificationInfo;
import coffeemeet.server.user.domain.User;
import coffeemeet.server.user.implement.UserQuery;
import coffeemeet.server.common.domain.UserNotificationEvent;
import coffeemeet.server.user.implement.UserCommand;
import java.util.Set;
import lombok.RequiredArgsConstructor;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -24,62 +17,48 @@
public class AdminService {

private final CertificationCommand certificationCommand;
private final UserQuery userQuery;
private final FCMNotificationSender fcmNotificationSender;
private final ApplicationEventPublisher applicationEventPublisher;
private final ReportCommand reportCommand;
private final MatchingQueueCommand matchingQueueCommand;
private final CertificationQuery certificationQuery;
private final AdminQuery adminQuery;
private final InquiryQuery inquiryQuery;
private final UserCommand userCommand;
private final AdminAccountValidator adminAccountValidator;
private final InquiryCommand inquiryCommand;

@Transactional(readOnly = true)
public void login(String id, String password) {
adminQuery.checkIdAndPassword(id, password);
adminAccountValidator.validate(id, password);
}

@Transactional
public void approveCertification(Long certificationId) {
certificationCommand.completeCertification(certificationId);

Long userId = certificationQuery.getUserIdByCertificationId(certificationId);
NotificationInfo notificationInfo = userQuery.getNotificationInfoByUserId(userId);

fcmNotificationSender.sendNotification(notificationInfo,
"축하드립니다! 회사 인증이 완료됐습니다. 이제부터 모든 서비스를 자유롭게 이용하실 수 있습니다.");
applicationEventPublisher.publishEvent(new UserNotificationEvent(certificationId,
"축하드립니다! 회사 인증이 완료됐습니다. 이제부터 모든 서비스를 자유롭게 이용하실 수 있습니다."));
}

@Transactional
public void rejectCertification(Long certificationId) {
certificationCommand.deleteCertificationByUserId(certificationId);

Long userId = certificationQuery.getUserIdByCertificationId(certificationId);
NotificationInfo notificationInfo = userQuery.getNotificationInfoByUserId(userId);

fcmNotificationSender.sendNotification(notificationInfo, "규정 및 기준에 부합하지 않아 회사 인증이 반려되었습니다.");
applicationEventPublisher.publishEvent(
new UserNotificationEvent(certificationId, "규정 및 기준에 부합하지 않아 회사 인증이 반려되었습니다."));
}

@Transactional // TODO: 2023/11/17 추후 구조 변경을 통해서 개선 예정
public void punishUser(Long userId, Set<Long> reportIds) {
User user = userQuery.getUserById(userId);
if (user.getUserStatus() == MATCHING) {
String companyName = certificationQuery.getCompanyNameByUserId(userId);
matchingQueueCommand.deleteUserByUserId(companyName, userId);
}
user.punished();

@Transactional
public void approveReport(Long userId, Set<Long> reportIds) {
userCommand.updatePunishedUser(userId);
reportCommand.processReports(reportIds);
fcmNotificationSender.sendNotification(user.getNotificationInfo(),
"귀하의 계정은 최근 신고 접수로 인해 일시적으로 서비스 이용이 제한되었습니다.");
applicationEventPublisher.publishEvent(
new UserNotificationEvent(userId, "귀하의 계정은 최근 신고 접수로 인해 일시적으로 서비스 이용이 제한되었습니다."));
}

@Transactional
public void dismissReport(Set<Long> reportIds) {
reportCommand.deleteReports(reportIds);
}

@Transactional
public void checkInquiry(Long inquiryId) {
Inquiry inquiry = inquiryQuery.getInquiryBy(inquiryId);
inquiryCommand.check(inquiry);
NotificationInfo notificationInfo = userQuery.getNotificationInfoByUserId(
inquiry.getInquirerId());
fcmNotificationSender.sendNotification(notificationInfo, "작성하신 문의가 확인되었습니다. 계정 메일을 확인해주세요");
inquiryCommand.updateCheckedInquiry(inquiryId);
// TODO: 2024/02/02 문의 응답 작성 및 (이메일 전송 or 알림 보내고 추후 확인)
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package coffeemeet.server.auth.domain;

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

import coffeemeet.server.common.execption.InvalidAuthException;
import io.jsonwebtoken.Claims;
Expand Down Expand Up @@ -66,7 +67,7 @@ private Claims parseClaims(String accessToken) {
.getBody();
} catch (ExpiredJwtException e) {
throw new InvalidAuthException(
AUTHENTICATION_FAILED,
EXPIRED_TOKEN,
String.format(EXPIRED_TOKEN_MESSAGE, accessToken));
} catch (UnsupportedJwtException e) {
throw new InvalidAuthException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
public enum AuthErrorCode implements ErrorCode {
INVALID_LOGIN_TYPE("A000", "지원하지 않는 로그인 타입입니다."),
AUTHENTICATION_FAILED("A001", "인증이 실패했습니다."),
EXPIRED_TOKEN("A002", "인증이 실패했습니다."),
AUTHORIZATION_FAILED("A003", "인가에 실패했습니다."),
HEADER_NOT_FOUND("A004", "헤더에 인증 코드가 없습니다."),
ALREADY_REGISTERED("A009", "이미 가입된 사용자입니다."),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package coffeemeet.server.auth.service;

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

import coffeemeet.server.auth.domain.AuthTokens;
import coffeemeet.server.auth.domain.AuthTokensGenerator;
Expand All @@ -26,7 +26,7 @@ public class AuthService {
public AuthTokens renew(Long userId, String refreshToken) {
if (jwtTokenProvider.isExpiredRefreshToken(refreshToken)) {
throw new InvalidAuthException(
AUTHENTICATION_FAILED,
EXPIRED_TOKEN,
String.format(EXPIRED_REFRESH_TOKEN_MESSAGE, refreshToken));
} else {
return authTokensGenerator.reissueAccessToken(userId, refreshToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
import coffeemeet.server.user.implement.UserQuery;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Component
@Transactional
@RequiredArgsConstructor
public class CertificationCommand {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ public boolean isExistedCompanyEmail(CompanyEmail companyEmail) {
return certificationRepository.existsByCompanyEmail(companyEmail);
}

public Long getUserIdByCertificationId(Long certificationId) {
return certificationId;
}

public Page<Certification> getPendingCertification(Pageable pageable) {
return certificationRepository.findPendingCertifications(pageable);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package coffeemeet.server.certification.implement;

import coffeemeet.server.certification.domain.CompanyEmail;
import coffeemeet.server.common.domain.CoffeeMeetMail;
import coffeemeet.server.common.infrastructure.EmailSender;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
Expand All @@ -9,14 +10,18 @@
@RequiredArgsConstructor
public class VerificationMailSender {

private static final String VERIFICATION_MAIL_SUBJECT = "[coffee-meet] 커피밋 사용을 위해 이메일 인증을 완료해주세요";
private static final String VERIFICATION_MAIL_BODY = "인증코드: %s";
private static final String VERIFICATION_MAIL_TITLE = "[coffee-meet] 커피밋 사용을 위해 이메일 인증을 완료해주세요";
private static final String VERIFICATION_MAIL_CONTENTS_FORM = "인증코드: %s";

private final EmailSender emailSender;

public void sendVerificationMail(CompanyEmail companyEmail, String verificationCode) {
emailSender.sendEmail(companyEmail.getValue(), VERIFICATION_MAIL_SUBJECT,
String.format(VERIFICATION_MAIL_BODY, verificationCode));
emailSender.sendMail(createVerificationMail(companyEmail.getValue(), verificationCode));
}

private CoffeeMeetMail createVerificationMail(String receiver, String code) {
String contents = String.format(VERIFICATION_MAIL_CONTENTS_FORM, code);
return new CoffeeMeetMail(receiver, VERIFICATION_MAIL_TITLE, contents);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@RequiredArgsConstructor
Expand All @@ -35,18 +36,20 @@ public class CertificationService {
private final VerificationInfoCommand verificationInfoCommand;
private final VerificationMailSender verificationMailSender;

@Transactional
public void registerCertification(Long userId, String companyName, String email,
String departmentName, File businessCardImage) {
CompanyEmail companyEmail = new CompanyEmail(email);
Department department = Department.valueOf(departmentName);

String businessCardImageUrl = businessCardImageUploader.uploadBusinessCardImage(
businessCardImage);
businessCardImage); // TODO: 2024/02/02 이 외부콜을 어떻게 하면 좋을까?

certificationCommand.createCertification(userId, companyName, companyEmail, department,
businessCardImageUrl);
}

@Transactional
public void updateCertification(Long userId, String companyName, String email,
String departmentName, File businessCardImage) {
CompanyEmail companyEmail = new CompanyEmail(email);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package coffeemeet.server.chatting.current.domain;

public record ChattingMessageNotificationEvenet(
Long roomId,
String senderNickName,
String message
) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package coffeemeet.server.chatting.current.domain;

public record ChattingRoomNotificationEvent(
Long chattingRoomId,
String message
)
{

}
Loading
Loading