Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.solidconnection.admin.controller;

import com.example.solidconnection.admin.dto.MentorApplicationAssignUniversityRequest;
import com.example.solidconnection.admin.dto.MentorApplicationCountResponse;
import com.example.solidconnection.admin.dto.MentorApplicationRejectRequest;
import com.example.solidconnection.admin.dto.MentorApplicationSearchCondition;
Expand Down Expand Up @@ -62,4 +63,14 @@ public ResponseEntity<MentorApplicationCountResponse> getMentorApplicationCount(
MentorApplicationCountResponse response = adminMentorApplicationService.getMentorApplicationCount();
return ResponseEntity.ok(response);
}

@PostMapping("/{mentorApplicationId}/assign-university")
public ResponseEntity<Void> assignUniversity(
@PathVariable("mentorApplicationId") Long mentorApplicationId,
@Valid @RequestBody MentorApplicationAssignUniversityRequest request
) {
Long universityId = request.universityId();
adminMentorApplicationService.assignUniversity(mentorApplicationId, universityId);
return ResponseEntity.ok().build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.example.solidconnection.admin.dto;

import jakarta.validation.constraints.NotNull;

public record MentorApplicationAssignUniversityRequest(
@NotNull(message = "대학 ID 는 필수입니다.")
Long universityId
) {

}
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package com.example.solidconnection.admin.dto;

import com.example.solidconnection.mentor.domain.MentorApplicationStatus;
import com.example.solidconnection.mentor.domain.UniversitySelectType;
import java.time.ZonedDateTime;

public record MentorApplicationResponse(
long id,
String region,
String country,
String university,
UniversitySelectType universitySelectType,
String mentorProofUrl,
MentorApplicationStatus mentorApplicationStatus,
String rejectedReason,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.example.solidconnection.admin.dto;

import com.example.solidconnection.mentor.domain.MentorApplicationStatus;
import com.example.solidconnection.mentor.domain.UniversitySelectType;
import java.time.LocalDate;

public record MentorApplicationSearchCondition(
MentorApplicationStatus mentorApplicationStatus,
String keyword,
LocalDate createdAt
LocalDate createdAt,
UniversitySelectType universitySelectType
) {

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.example.solidconnection.admin.service;

import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_APPLICATION_NOT_FOUND;
import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_APPLICATION_NOT_OTHER_STATUS;
import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_APPLICATION_UNIVERSITY_NOT_SELECTED;

import com.example.solidconnection.admin.dto.MentorApplicationCountResponse;
Expand All @@ -10,7 +11,10 @@
import com.example.solidconnection.common.exception.CustomException;
import com.example.solidconnection.mentor.domain.MentorApplication;
import com.example.solidconnection.mentor.domain.MentorApplicationStatus;
import com.example.solidconnection.mentor.domain.UniversitySelectType;
import com.example.solidconnection.mentor.repository.MentorApplicationRepository;
import com.example.solidconnection.university.domain.University;
import com.example.solidconnection.university.repository.UniversityRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
Expand All @@ -22,6 +26,7 @@
public class AdminMentorApplicationService {

private final MentorApplicationRepository mentorApplicationRepository;
private final UniversityRepository universityRepository;

@Transactional(readOnly = true)
public Page<MentorApplicationSearchResponse> searchMentorApplications(
Expand All @@ -44,7 +49,10 @@ public void approveMentorApplication(Long mentorApplicationId) {
}

@Transactional
public void rejectMentorApplication(long mentorApplicationId, MentorApplicationRejectRequest request) {
public void rejectMentorApplication(
long mentorApplicationId,
MentorApplicationRejectRequest request
) {
MentorApplication mentorApplication = mentorApplicationRepository.findById(mentorApplicationId)
.orElseThrow(() -> new CustomException(MENTOR_APPLICATION_NOT_FOUND));

Expand All @@ -63,4 +71,21 @@ public MentorApplicationCountResponse getMentorApplicationCount() {
rejectedCount
);
}

@Transactional
public void assignUniversity(
Long mentorApplicationId,
Long universityId
) {
MentorApplication mentorApplication = mentorApplicationRepository.findById(mentorApplicationId)
.orElseThrow(() -> new CustomException(MENTOR_APPLICATION_NOT_FOUND));

if(mentorApplication.getUniversitySelectType() != UniversitySelectType.OTHER){
throw new CustomException(MENTOR_APPLICATION_NOT_OTHER_STATUS);
}

University university = universityRepository.getUniversityById(universityId);

mentorApplication.assignUniversity(university.getId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public enum ErrorCode {
MENTOR_ALREADY_EXISTS(HttpStatus.BAD_REQUEST.value(), "이미 존재하는 멘토입니다."),
MENTOR_APPLICATION_ALREADY_CONFIRMED(HttpStatus.BAD_REQUEST.value(), "이미 승인 또는 거절된 멘토 승격 요청 입니다."),
MENTOR_APPLICATION_UNIVERSITY_NOT_SELECTED(HttpStatus.BAD_REQUEST.value(), "승인하려는 멘토 신청에 대학교가 선택되지 않았습니다."),
MENTOR_APPLICATION_NOT_OTHER_STATUS(HttpStatus.BAD_REQUEST.value(), "대학 선택 타입이 OTHER이 아닌 멘토 지원서 입니다."),

// socket
UNAUTHORIZED_SUBSCRIBE(HttpStatus.FORBIDDEN.value(), "구독 권한이 없습니다."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,9 @@ public void reject(String rejectedReason){
this.mentorApplicationStatus = MentorApplicationStatus.REJECTED;
this.rejectedReason = rejectedReason;
}

public void assignUniversity(long universityId) {
this.universityId = universityId;
this.universitySelectType = UniversitySelectType.CATALOG;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.example.solidconnection.admin.dto.MentorApplicationSearchResponse;
import com.example.solidconnection.admin.dto.SiteUserResponse;
import com.example.solidconnection.mentor.domain.MentorApplicationStatus;
import com.example.solidconnection.mentor.domain.UniversitySelectType;
import com.querydsl.core.types.ConstructorExpression;
import com.querydsl.core.types.Projections;
import com.querydsl.core.types.dsl.BooleanExpression;
Expand Down Expand Up @@ -48,6 +49,7 @@ public class MentorApplicationFilterRepositoryImpl implements MentorApplicationF
region.koreanName,
country.koreanName,
university.koreanName,
mentorApplication.universitySelectType,
mentorApplication.mentorProofUrl,
mentorApplication.mentorApplicationStatus,
mentorApplication.rejectedReason,
Expand Down Expand Up @@ -81,7 +83,8 @@ public Page<MentorApplicationSearchResponse> searchMentorApplications(MentorAppl
.where(
verifyMentorStatusEq(condition.mentorApplicationStatus()),
keywordContains(condition.keyword()),
createdAtEq(condition.createdAt())
createdAtEq(condition.createdAt()),
universitySelectTypeEq(condition.universitySelectType())
)
.orderBy(mentorApplication.createdAt.desc())
.offset(pageable.getOffset())
Expand Down Expand Up @@ -110,7 +113,8 @@ private JPAQuery<Long> createCountQuery(MentorApplicationSearchCondition conditi
return query.where(
verifyMentorStatusEq(condition.mentorApplicationStatus()),
keywordContains(condition.keyword()),
createdAtEq(condition.createdAt())
createdAtEq(condition.createdAt()),
universitySelectTypeEq(condition.universitySelectType())
);
}

Expand Down Expand Up @@ -142,4 +146,8 @@ private BooleanExpression createdAtEq(LocalDate createdAt) {
endOfDay.atZone(SYSTEM_ZONE_ID)
);
}

private BooleanExpression universitySelectTypeEq(UniversitySelectType universitySelectType) {
return universitySelectType != null ? mentorApplication.universitySelectType.eq(universitySelectType) : null;
}
}
Loading
Loading