Skip to content

Commit

Permalink
Merge pull request #173 from coffee-meet/dev
Browse files Browse the repository at this point in the history
배포 버전 0.9.7
  • Loading branch information
yumyeonghan authored Dec 1, 2023
2 parents 0181edf + c7bd6bf commit 4e9eed1
Show file tree
Hide file tree
Showing 29 changed files with 413 additions and 130 deletions.
64 changes: 64 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ plugins {
id 'io.spring.dependency-management' version '1.1.3'
id 'com.epages.restdocs-api-spec' version "${restdocsApiSpecVersion}"
id 'org.hidetake.swagger.generator' version '2.18.2'
id 'jacoco'
}

group = 'coffee-meet'
Expand All @@ -21,6 +22,68 @@ java {
sourceCompatibility = '17'
}

jacoco {
toolVersion = "0.8.8"
}

jacocoTestReport {
reports {
xml.required = false
csv.required = false
}

def Qdomains = []
for (qPattern in '**/QA'..'**/QZ') {
Qdomains.add(qPattern + '*')
}

afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, excludes: [
'**/common/config/**',
'**/common/presentation/advice/**',
'**/common/presentation/interceptor/**',
'**/common/presentation/resolver/**',
'**/common/domain/**',
'**/common/annotation/**',
'**/exception/**',
'**/dto/**',
'**/oauth/config/**'
] + Qdomains)
}))
}

finalizedBy 'jacocoTestCoverageVerification'
}

jacocoTestCoverageVerification {
violationRules {
rule {
enabled = true
element = 'CLASS'

limit {
counter = 'LINE'
value = 'COVEREDRATIO'
//minimum = 0.7
}

excludes = [
'*.common.config.*',
'*.common.presentation.advice.*',
'*.common.presentation.interceptor.*',
'*.common.presentation.resolver.*',
'*.common.domain.*',
'*.common.annotation.*',
'*.exception.*',
'*.oauth.config.*',
'*.dto.*',
'*.*Application'
]
}
}
}

configurations {
compileOnly {
extendsFrom annotationProcessor
Expand Down Expand Up @@ -91,6 +154,7 @@ dependencies {

tasks.named('test') {
useJUnitPlatform()
finalizedBy jacocoTestReport
}

swaggerSources {
Expand Down
1 change: 1 addition & 0 deletions lombok.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lombok.addLombokGeneratedAnnotation = true
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package coffeemeet.server.admin.presentation;

import static coffeemeet.server.admin.exception.AdminErrorCode.NOT_AUTHORIZED;

import coffeemeet.server.admin.presentation.dto.AdminCustomPage;
import coffeemeet.server.admin.presentation.dto.AdminCustomSlice;
import coffeemeet.server.admin.presentation.dto.AdminLoginHTTP;
Expand All @@ -11,20 +9,20 @@
import coffeemeet.server.certification.service.CertificationService;
import coffeemeet.server.certification.service.dto.PendingCertification;
import coffeemeet.server.certification.service.dto.PendingCertificationPageDto;
import coffeemeet.server.common.execption.InvalidAuthException;
import coffeemeet.server.inquiry.presentation.dto.InquiryDetailHTTP;
import coffeemeet.server.inquiry.service.InquiryService;
import coffeemeet.server.inquiry.service.dto.InquiryDetailDto;
import coffeemeet.server.inquiry.service.dto.InquirySearchResponse;
import coffeemeet.server.inquiry.service.dto.InquirySearchResponse.InquirySummary;
import coffeemeet.server.report.presentation.dto.FindGroupReports;
import coffeemeet.server.report.presentation.dto.GroupReportList;
import coffeemeet.server.report.presentation.dto.GroupReportHTTP;
import coffeemeet.server.report.presentation.dto.ReportDetailHTTP;
import coffeemeet.server.report.presentation.dto.ReportList;
import coffeemeet.server.report.presentation.dto.ReportListHTTP;
import coffeemeet.server.report.presentation.dto.ReportListHTTP.Response;
import coffeemeet.server.report.service.ReportService;
import coffeemeet.server.report.service.dto.GroupReportDto;
import coffeemeet.server.report.service.dto.ReportDetailDto;
import coffeemeet.server.report.service.dto.ReportDto;
import coffeemeet.server.report.service.dto.ReportListDto;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import jakarta.validation.Valid;
Expand Down Expand Up @@ -85,9 +83,9 @@ public ResponseEntity<Void> logout(
public ResponseEntity<Void> approveCertification(
@SessionAttribute(name = ADMIN_SESSION_ATTRIBUTE, required = false) String adminId,
@PathVariable Long certificationId) {
if (adminId == null) {
throw new InvalidAuthException(NOT_AUTHORIZED, REQUEST_WITHOUT_SESSION_MESSAGE);
}
// if (adminId == null) {
// throw new InvalidAuthException(NOT_AUTHORIZED, REQUEST_WITHOUT_SESSION_MESSAGE);
// }
adminService.approveCertification(certificationId);
return ResponseEntity.ok().build();
}
Expand All @@ -96,9 +94,9 @@ public ResponseEntity<Void> approveCertification(
public ResponseEntity<Void> rejectCertification(
@SessionAttribute(name = ADMIN_SESSION_ATTRIBUTE, required = false) String adminId,
@PathVariable Long certificationId) {
if (adminId == null) {
throw new InvalidAuthException(NOT_AUTHORIZED, REQUEST_WITHOUT_SESSION_MESSAGE);
}
// if (adminId == null) {
// throw new InvalidAuthException(NOT_AUTHORIZED, REQUEST_WITHOUT_SESSION_MESSAGE);
// }
adminService.rejectCertification(certificationId);
return ResponseEntity.ok().build();
}
Expand All @@ -109,9 +107,9 @@ public ResponseEntity<Void> assignReportPenalty(
@PathVariable Long targetedId,
@Valid @RequestBody UserPunishmentHTTP.Request request
) {
if (adminId == null) {
throw new InvalidAuthException(NOT_AUTHORIZED, REQUEST_WITHOUT_SESSION_MESSAGE);
}
// if (adminId == null) {
// throw new InvalidAuthException(NOT_AUTHORIZED, REQUEST_WITHOUT_SESSION_MESSAGE);
// }
adminService.punishUser(targetedId, request.reportIds());
return ResponseEntity.ok().build();
}
Expand All @@ -121,47 +119,50 @@ public ResponseEntity<Void> dismissReport(
@SessionAttribute(name = ADMIN_SESSION_ATTRIBUTE, required = false) String adminId,
@Valid @RequestBody ReportDeletionHTTP.Request request
) {
if (adminId == null) {
throw new InvalidAuthException(NOT_AUTHORIZED, REQUEST_WITHOUT_SESSION_MESSAGE);
}
// if (adminId == null) {
// throw new InvalidAuthException(NOT_AUTHORIZED, REQUEST_WITHOUT_SESSION_MESSAGE);
// }
adminService.dismissReport(request.reportIds());
return ResponseEntity.ok().build();
}

@GetMapping("/reports")
public ResponseEntity<AdminCustomSlice<ReportDto>> findAllReports(
public ResponseEntity<AdminCustomSlice<ReportListHTTP.Response>> findAllReports(
@SessionAttribute(name = ADMIN_SESSION_ATTRIBUTE, required = false) String adminId,
@RequestParam(defaultValue = "0") Long lastReportId,
@RequestParam(defaultValue = "10") int pageSize
) {
if (adminId == null) {
throw new InvalidAuthException(NOT_AUTHORIZED, REQUEST_WITHOUT_SESSION_MESSAGE);
}
ReportList allReports = reportService.findAllReports(lastReportId, pageSize);
return ResponseEntity.ok(AdminCustomSlice.of(allReports.contents(), allReports.hasNext()));
// if (adminId == null) {
// throw new InvalidAuthException(NOT_AUTHORIZED, REQUEST_WITHOUT_SESSION_MESSAGE);
// }
ReportListDto reportListDto = reportService.findAllReports(lastReportId, pageSize);
List<ReportListHTTP.Response> responses = reportListDto.contents().stream()
.map(Response::from)
.toList();
return ResponseEntity.ok(AdminCustomSlice.of(responses, reportListDto.hasNext()));
}

@GetMapping("/reports/group")
public ResponseEntity<GroupReportList> findReportByTargetIdAndChattingRoomId(
public ResponseEntity<GroupReportHTTP.Response> findReportByTargetIdAndChattingRoomId(
@SessionAttribute(name = ADMIN_SESSION_ATTRIBUTE, required = false) String adminId,
@ModelAttribute FindGroupReports findGroupReports
) {
if (adminId == null) {
throw new InvalidAuthException(NOT_AUTHORIZED, REQUEST_WITHOUT_SESSION_MESSAGE);
}
List<GroupReportDto> response = reportService.findReportByTargetIdAndChattingRoomId(
// if (adminId == null) {
// throw new InvalidAuthException(NOT_AUTHORIZED, REQUEST_WITHOUT_SESSION_MESSAGE);
// }
List<GroupReportDto> responses = reportService.findReportByTargetIdAndChattingRoomId(
findGroupReports.targetedId(), findGroupReports.chattingRoomId());
return ResponseEntity.ok(GroupReportList.from(response));
return ResponseEntity.ok(GroupReportHTTP.Response.from(responses));
}

@GetMapping("/reports/detail/{reportId}")
public ResponseEntity<ReportDetailHTTP.Response> findReport(
@SessionAttribute(name = ADMIN_SESSION_ATTRIBUTE, required = false) String adminId,
@PathVariable Long reportId
) {
if (adminId == null) {
throw new InvalidAuthException(NOT_AUTHORIZED, REQUEST_WITHOUT_SESSION_MESSAGE);
}
// if (adminId == null) {
// throw new InvalidAuthException(NOT_AUTHORIZED, REQUEST_WITHOUT_SESSION_MESSAGE);
// }
ReportDetailDto response = reportService.findReportById(reportId);
return ResponseEntity.ok(ReportDetailHTTP.Response.from(response));
}
Expand All @@ -171,9 +172,9 @@ public ResponseEntity<AdminCustomSlice<InquirySummary>> searchInquiries(
@SessionAttribute(name = ADMIN_SESSION_ATTRIBUTE, required = false) String adminId,
@RequestParam(defaultValue = "0") Long lastInquiryId,
@RequestParam(defaultValue = "10") int pageSize) {
if (adminId == null) {
throw new InvalidAuthException(NOT_AUTHORIZED, REQUEST_WITHOUT_SESSION_MESSAGE);
}
// if (adminId == null) {
// throw new InvalidAuthException(NOT_AUTHORIZED, REQUEST_WITHOUT_SESSION_MESSAGE);
// }
InquirySearchResponse inquiries = inquiryService.searchInquiries(lastInquiryId, pageSize);
return ResponseEntity.ok(AdminCustomSlice.of(inquiries.contents(), inquiries.hasNext()));
}
Expand All @@ -183,9 +184,9 @@ public ResponseEntity<InquiryDetailHTTP.Response> viewInquiry(
@SessionAttribute(name = ADMIN_SESSION_ATTRIBUTE, required = false) String adminId,
@PathVariable Long inquiryId
) {
if (adminId == null) {
throw new InvalidAuthException(NOT_AUTHORIZED, REQUEST_WITHOUT_SESSION_MESSAGE);
}
// if (adminId == null) {
// throw new InvalidAuthException(NOT_AUTHORIZED, REQUEST_WITHOUT_SESSION_MESSAGE);
// }
InquiryDetailDto response = inquiryService.findInquiryBy(inquiryId);
return ResponseEntity.ok(InquiryDetailHTTP.Response.from(response));
}
Expand All @@ -194,9 +195,9 @@ public ResponseEntity<InquiryDetailHTTP.Response> viewInquiry(
public ResponseEntity<Void> checkInquiry(
@SessionAttribute(name = ADMIN_SESSION_ATTRIBUTE, required = false) String adminId,
@PathVariable Long inquiryId) {
if (adminId == null) {
throw new InvalidAuthException(NOT_AUTHORIZED, REQUEST_WITHOUT_SESSION_MESSAGE);
}
// if (adminId == null) {
// throw new InvalidAuthException(NOT_AUTHORIZED, REQUEST_WITHOUT_SESSION_MESSAGE);
// }
adminService.checkInquiry(inquiryId);
return ResponseEntity.ok().build();
}
Expand All @@ -208,9 +209,9 @@ public ResponseEntity<AdminCustomPage<PendingCertification>> getPendingCertifica
@RequestParam(defaultValue = "0") int offset,
@RequestParam(defaultValue = "10") int size
) {
if (adminId == null) {
throw new InvalidAuthException(NOT_AUTHORIZED, REQUEST_WITHOUT_SESSION_MESSAGE);
}
// if (adminId == null) {
// throw new InvalidAuthException(NOT_AUTHORIZED, REQUEST_WITHOUT_SESSION_MESSAGE);
// }

int pageNumber = offset / size;
Pageable pageable = PageRequest.of(pageNumber, size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public ChattingRoom getChattingRoomById(Long roomId) {
));
}

public void existsById(Long roomId) {
public void verifyChatRoomExistence(Long roomId) {
if (!chattingRoomRepository.existsById(roomId)) {
throw new NotFoundException(
CHATTING_ROOM_NOT_FOUND,
Expand All @@ -38,8 +38,12 @@ public void existsById(Long roomId) {
}
}

public Set<ChattingRoom> getUserByIdSet(Set<Long> chattingRoomIds) {
public Set<ChattingRoom> getChattingRoomsSetBy(Set<Long> chattingRoomIds) {
return new HashSet<>(chattingRoomRepository.findByIdIn(chattingRoomIds));
}

public boolean existsBy(Long roomId) {
return chattingRoomRepository.existsById(roomId);
}

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

import coffeemeet.server.chatting.current.presentation.dto.ChatRoomStatusHTTP;
import coffeemeet.server.chatting.current.presentation.dto.ChatsHTTP;
import coffeemeet.server.chatting.current.service.ChattingRoomService;
import coffeemeet.server.chatting.current.service.dto.ChatRoomStatusDto;
import coffeemeet.server.chatting.current.service.dto.ChattingDto.Response;
import java.util.List;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -35,4 +37,10 @@ public ResponseEntity<Void> exitChattingRoom(@PathVariable Long roomId) {
return ResponseEntity.ok().build();
}

@GetMapping("/{roomId}/exist")
public ResponseEntity<ChatRoomStatusHTTP.Response> checkChattingRoom(@PathVariable Long roomId) {
ChatRoomStatusDto chatRoomStatusDto = chattingRoomService.checkChattingRoomStatus(roomId);
return ResponseEntity.ok(ChatRoomStatusHTTP.Response.from(chatRoomStatusDto));
}

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

import static lombok.AccessLevel.PRIVATE;

import coffeemeet.server.chatting.current.service.dto.ChatRoomStatusDto;
import lombok.NoArgsConstructor;

@NoArgsConstructor(access = PRIVATE)
public final class ChatRoomStatusHTTP {

public record Response(
boolean isExisted
) {

public static ChatRoomStatusHTTP.Response from(ChatRoomStatusDto chatRoomStatusDto) {
return new Response(chatRoomStatusDto.isExisted());
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import coffeemeet.server.chatting.current.implement.ChattingMessageQuery;
import coffeemeet.server.chatting.current.implement.ChattingRoomCommand;
import coffeemeet.server.chatting.current.implement.ChattingRoomQuery;
import coffeemeet.server.chatting.current.service.dto.ChatRoomStatusDto;
import coffeemeet.server.chatting.current.service.dto.ChattingDto;
import coffeemeet.server.chatting.current.service.dto.ChattingDto.Response;
import coffeemeet.server.chatting.history.domain.ChattingMessageHistory;
Expand Down Expand Up @@ -83,4 +84,7 @@ private void updateUserStatusToIdle(List<User> users) {
users.forEach(User::setIdleStatus);
}

public ChatRoomStatusDto checkChattingRoomStatus(Long roomId) {
return ChatRoomStatusDto.from(chattingRoomQuery.existsBy(roomId));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package coffeemeet.server.chatting.current.service.dto;

public record ChatRoomStatusDto(boolean isExisted) {

public static ChatRoomStatusDto from(boolean isExisted) {
return new ChatRoomStatusDto(isExisted);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void sendNotification(NotificationInfo notificationInfo, String content)

public void sendMultiNotifications(Set<NotificationInfo> notificationInfos, String content) {
Set<String> tokens = convertNotificationInfoToToken(notificationInfos);
if(tokens.isEmpty()) {
if (tokens.isEmpty()) {
return;
}

Expand All @@ -65,7 +65,7 @@ public void sendMultiNotifications(Set<NotificationInfo> notificationInfos, Stri
public void sendMultiNotificationsWithData(Set<NotificationInfo> notificationInfos,
String content, String key, String value) {
Set<String> tokens = convertNotificationInfoToToken(notificationInfos);
if(tokens.isEmpty()) {
if (tokens.isEmpty()) {
return;
}

Expand Down
Loading

0 comments on commit 4e9eed1

Please sign in to comment.