Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
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
119 changes: 61 additions & 58 deletions techeerzip/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ repositories {
}

dependencies {
// test H2
testImplementation 'com.h2database:h2:2.2.224'

implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
Expand Down Expand Up @@ -70,13 +67,19 @@ dependencies {
implementation 'net.logstash.logback:logstash-logback-encoder:7.4'
implementation 'org.projectlombok:lombok:1.18.30'

testCompileOnly 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'

compileOnly 'org.projectlombok:lombok'
runtimeOnly 'org.postgresql:postgresql'
annotationProcessor 'org.projectlombok:lombok'

// test
testCompileOnly 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'
testImplementation 'com.h2database:h2:2.2.224'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'org.springframework.boot:spring-boot-testcontainers' // Spring Boot 3.1+ 부터 제공하는 편리한 기능
testImplementation 'org.testcontainers:junit-jupiter'
testImplementation 'org.testcontainers:postgresql'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

// SpringDoc OpenAPI (테스트 용도)
Expand All @@ -102,10 +105,10 @@ dependencies {

// Pyroscope
implementation 'io.pyroscope:agent:2.1.2'

// GraphQL 클라이언트 (WebFlux)
implementation 'org.springframework.boot:spring-boot-starter-webflux'

// macOS DNS resolver for Netty
runtimeOnly 'io.netty:netty-resolver-dns-native-macos:4.1.114.Final:osx-aarch_64'
}
Expand Down Expand Up @@ -172,58 +175,58 @@ spotless {
// Spotless가 compileJava 이후에 실행되도록 설정
spotlessJava.dependsOn compileJava

//jacoco {
// toolVersion = "0.8.11"
//}
//
//// 공통 exclusion 패턴 정의
//def jacocoExcluded = [
// '**/Q*.class', // QueryDSL generated
// '**/*Builder*', // Lombok builder
// '**/dto/**', // DTO
// '**/exception/**', // Exception
// '**/config/**', // Config
// '**/infra/**', // Infra (S3, MQ 등)
// '**/global/**' // Global 패키지
//]

// // jacocoReport
// tasks.named('jacocoTestReport') {
// dependsOn test
// reports {
// xml.required = true
// html.required = true
// }
// classDirectories.setFrom(files(
// classDirectories.files.collect { fileTree(dir: it, exclude: jacocoExcluded) }
// ))
// }

// // jacocoCoverage 확인
// tasks.named('jacocoTestCoverageVerification') {
// classDirectories.setFrom(files(
// classDirectories.files.collect { fileTree(dir: it, exclude: jacocoExcluded) }
// ))

// violationRules {
// rule {
// element = 'CLASS'
// limit {
// counter = 'LINE'
// value = 'COVEREDRATIO'
// minimum = 0.00
// }
// limit {
// counter = 'BRANCH'
// value = 'COVEREDRATIO'
// minimum = 0.00
// }
// }
// }
// }
jacoco {
toolVersion = "0.8.11"
}

// 공통 exclusion 패턴 정의
def jacocoExcluded = [
'**/Q*.class', // QueryDSL generated
'**/*Builder*', // Lombok builder
'**/dto/**', // DTO
'**/exception/**', // Exception
'**/config/**', // Config
'**/infra/**', // Infra (S3, MQ 등)
'**/global/**' // Global 패키지
]

// jacocoReport
tasks.named('jacocoTestReport', JacocoReport) {
dependsOn test
reports {
xml.required = true
html.required = true
}
classDirectories.setFrom(files(
classDirectories.files.collect { fileTree(dir: it, exclude: jacocoExcluded) }
))
}

// jacocoCoverage 확인
tasks.named('jacocoTestCoverageVerification', JacocoCoverageVerification) {
classDirectories.setFrom(files(
classDirectories.files.collect { fileTree(dir: it, exclude: jacocoExcluded) }
))

violationRules {
rule {
element = 'CLASS'
limit {
counter = 'LINE'
value = 'COVEREDRATIO'
minimum = 0.00
}
limit {
counter = 'BRANCH'
value = 'COVEREDRATIO'
minimum = 0.00
}
}
}
}

// 테스트 task 마무리 설정
tasks.test {
useJUnitPlatform()
finalizedBy tasks.jacocoTestReport
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,22 @@ public ResponseEntity<FeedbackCursorResponse> getReceivedFeedbackRequests(
if (status != null && !status.trim().isEmpty()) {
feedbacks =
feedbackService.getReceivedFeedbacksByStatus(
currentUser.getUserId(), status, startDateTime, endDateTime, cursor, limit, currentUser);
currentUser.getUserId(),
status,
startDateTime,
endDateTime,
cursor,
limit,
currentUser);
} else {
feedbacks =
feedbackService.getAllReceivedFeedbacks(
currentUser.getUserId(), startDateTime, endDateTime, cursor, limit, currentUser);
currentUser.getUserId(),
startDateTime,
endDateTime,
cursor,
limit,
currentUser);
}

FeedbackCursorResponse response = FeedbackCursorResponse.from(feedbacks, limit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ Optional<Feedback> findByRequesterIdAndRecipientIdAndIsDeletedFalse(
Optional<Feedback> findByIdWithUsers(Long feedbackId);

List<Feedback> findReceivedFeedbacks(
Long recipientId, String status, LocalDateTime startDateTime, LocalDateTime endDateTime, Long cursor, int limit);
Long recipientId,
String status,
LocalDateTime startDateTime,
LocalDateTime endDateTime,
Long cursor,
int limit);

List<Feedback> findReceivedFeedbacksByStatus(
Long recipientId, String status, Long cursor, int limit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,12 @@ public Optional<Feedback> findByIdWithUsers(Long feedbackId) {

@Override
public List<Feedback> findReceivedFeedbacks(
Long recipientId, String status, LocalDateTime startDateTime, LocalDateTime endDateTime, Long cursor, int limit) {
Long recipientId,
String status,
LocalDateTime startDateTime,
LocalDateTime endDateTime,
Long cursor,
int limit) {
var query =
queryFactory
.selectFrom(feedback)
Expand All @@ -179,7 +184,9 @@ public List<Feedback> findReceivedFeedbacks(
.leftJoin(feedback.recipient)
.fetchJoin()
.where(
feedback.recipient.id.eq(recipientId)
feedback.recipient
.id
.eq(recipientId)
.and(feedback.isDeleted.eq(false)));

if (status != null) {
Expand All @@ -200,4 +207,4 @@ public List<Feedback> findReceivedFeedbacks(

return query.orderBy(feedback.createdAt.desc()).limit(limit + 1).fetch();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,13 @@ public List<Feedback> getReceivedFeedbackRequests(Long userId) {

@Transactional(readOnly = true)
public List<Feedback> getReceivedFeedbacksByStatus(
Long mentorId, String status, LocalDateTime startDateTime, LocalDateTime endDateTime, Long cursor, int limit, CustomUserPrincipal currentUser) {
Long mentorId,
String status,
LocalDateTime startDateTime,
LocalDateTime endDateTime,
Long cursor,
int limit,
CustomUserPrincipal currentUser) {
logger.debug(
"멘토 상태별 피드백 조회 시작 - mentorId: {}, status: {}, startDateTime: {}, endDateTime: {} | context: {}",
mentorId,
Expand All @@ -171,10 +177,18 @@ public List<Feedback> getReceivedFeedbacksByStatus(
throw new FeedbackForbiddenException();
}

LocalDateTime effectiveStartDateTime = startDateTime != null ? startDateTime : LocalDateTime.now().minusMonths(1);
LocalDateTime effectiveStartDateTime =
startDateTime != null ? startDateTime : LocalDateTime.now().minusMonths(1);
LocalDateTime effectiveEndDateTime = endDateTime;

List<Feedback> feedbacks = feedbackRepository.findReceivedFeedbacks(mentorId, status, effectiveStartDateTime, effectiveEndDateTime, cursor, limit);
List<Feedback> feedbacks =
feedbackRepository.findReceivedFeedbacks(
mentorId,
status,
effectiveStartDateTime,
effectiveEndDateTime,
cursor,
limit);

logger.debug(
"멘토 상태별 피드백 조회 완료 - mentorId: {}, status: {}, count: {} | context: {}",
Expand All @@ -188,18 +202,36 @@ public List<Feedback> getReceivedFeedbacksByStatus(

@Transactional(readOnly = true)
public List<Feedback> getAllReceivedFeedbacks(
Long mentorId, LocalDateTime startDateTime, LocalDateTime endDateTime, Long cursor, int limit, CustomUserPrincipal currentUser) {
logger.debug("멘토 전체 피드백 조회 시작 - mentorId: {}, startDateTime: {}, endDateTime: {} | context: {}", mentorId, startDateTime, endDateTime, CONTEXT);
Long mentorId,
LocalDateTime startDateTime,
LocalDateTime endDateTime,
Long cursor,
int limit,
CustomUserPrincipal currentUser) {
logger.debug(
"멘토 전체 피드백 조회 시작 - mentorId: {}, startDateTime: {}, endDateTime: {} | context: {}",
mentorId,
startDateTime,
endDateTime,
CONTEXT);

validateMentorRole(currentUser);
if (!currentUser.getUserId().equals(mentorId) && !currentUser.isAdmin()) {
throw new FeedbackForbiddenException();
}

LocalDateTime effectiveStartDateTime = startDateTime != null ? startDateTime : LocalDateTime.now().minusMonths(1);
LocalDateTime effectiveStartDateTime =
startDateTime != null ? startDateTime : LocalDateTime.now().minusMonths(1);
LocalDateTime effectiveEndDateTime = endDateTime;

List<Feedback> feedbacks = feedbackRepository.findReceivedFeedbacks(mentorId, null, effectiveStartDateTime, effectiveEndDateTime, cursor, limit);
List<Feedback> feedbacks =
feedbackRepository.findReceivedFeedbacks(
mentorId,
null,
effectiveStartDateTime,
effectiveEndDateTime,
cursor,
limit);

logger.debug(
"멘토 전체 피드백 조회 완료 - mentorId: {}, count: {} | context: {}",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
package backend.techeerzip.domain.role.entity;

public enum RoleType {
ADMIN("ROLE_ADMIN"),
MENTOR("ROLE_MENTOR"),
TECHEER("ROLE_TECHEER"),
COMPANY("ROLE_COMPANY"),
BOOTCAMP("ROLE_BOOTCAMP");
ADMIN("ROLE_ADMIN", 1L),
MENTOR("ROLE_MENTOR", 2L),
TECHEER("ROLE_TECHEER", 3L),
COMPANY("ROLE_COMPANY", null),
BOOTCAMP("ROLE_BOOTCAMP", null);

private final String roleName;
private final Long roleId;

RoleType(String roleName) {
RoleType(String roleName, Long roleId) {
this.roleName = roleName;
this.roleId = roleId;
}

public String getRoleName() {
return roleName;
}

/**
* DB 마이그레이션에서 정의된 roleId를 반환합니다. ADMIN=1, MENTOR=2, TECHEER=3으로 고정되어 있습니다. 다른 RoleType의 경우
* null을 반환할 수 있습니다.
*/
public Long getRoleId() {
return roleId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
indexes = {
@Index(
name = "idx_WeeklyGitContributions_user_year_month_week",
columnList = "userId year month week"),
columnList = "userId,year,month,week"),
@Index(
name = "idx_WeeklyGitContributions_user_weekStart",
columnList = "userId weekStart")
columnList = "userId,weekStart")
})
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public void todayCsPublishScheduler() {
String.format(
"[ERROR] CS 문제 발행 중 오류 발생!\n> 원인: %s\n> 시간: %s",
e.getMessage(), java.time.LocalDateTime.now());
eventPublisher.publishEvent(
new SlackEvent.Channel(errorMessage, SlackChannelType.EA));
eventPublisher.publishEvent(new SlackEvent.Channel(errorMessage, SlackChannelType.EA));
}
}
}
Loading