Skip to content

Commit

Permalink
🧩 :: (#482) μžμž˜ν•œ μˆ˜μ •
Browse files Browse the repository at this point in the history
  • Loading branch information
alsdl0629 committed Dec 5, 2023
1 parent 5c654b5 commit 37e2bf5
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

@Getter
@AllArgsConstructor
public class StudentQueryApplicationsResponse {
public class QueryMyApplicationsResponse {

private final List<StudentQueryApplicationResponse> applications;
private final List<QueryMyApplicationResponse> applications;

@Getter
@Builder
public static class StudentQueryApplicationResponse {
public static class QueryMyApplicationResponse {
private final Long applicationId;
private final Long recruitmentId;
private final String company;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
import team.retum.jobis.common.annotation.ReadOnlyUseCase;
import team.retum.jobis.common.spi.SecurityPort;
import team.retum.jobis.domain.application.dto.response.AttachmentResponse;
import team.retum.jobis.domain.application.dto.response.StudentQueryApplicationsResponse;
import team.retum.jobis.domain.application.dto.response.StudentQueryApplicationsResponse.StudentQueryApplicationResponse;
import team.retum.jobis.domain.application.dto.response.QueryMyApplicationsResponse;
import team.retum.jobis.domain.application.dto.response.QueryMyApplicationsResponse.QueryMyApplicationResponse;
import team.retum.jobis.domain.application.spi.QueryApplicationPort;
import team.retum.jobis.domain.student.model.Student;

@RequiredArgsConstructor
@ReadOnlyUseCase
public class QueryStudentApplicationsUseCase {
public class QueryMyApplicationsUseCase {

private final QueryApplicationPort queryApplicationPort;
private final SecurityPort securityPort;

public StudentQueryApplicationsResponse execute() {
public QueryMyApplicationsResponse execute() {
Student student = securityPort.getCurrentStudent();

return new StudentQueryApplicationsResponse(
return new QueryMyApplicationsResponse(
queryApplicationPort.queryApplicationByConditions(
null, student.getId(), null, null).stream()
.map(application -> StudentQueryApplicationResponse.builder()
.map(application -> QueryMyApplicationResponse.builder()
.applicationId(application.getId())
.recruitmentId(application.getRecruitmentId())
.company(application.getCompanyName())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import lombok.Getter;
import team.retum.jobis.domain.student.exception.ClassRoomNotFoundException;

import java.util.List;

@Getter
@Builder
public class SchoolNumber {
Expand All @@ -16,10 +14,6 @@ public class SchoolNumber {

private final Integer number;

private static final int FIRST_GRADE = 1;
private static final int SECOND_GRADE = 2;
private static final int THIRD_GRADE = 3;

public static String processSchoolNumber(SchoolNumber schoolNumber) {
return String.valueOf(schoolNumber.grade) +
schoolNumber.classRoom +
Expand Down Expand Up @@ -54,4 +48,8 @@ public static SchoolNumber parseSchoolNumber(String schoolNumber) {
.number(number)
.build();
}

private static final int FIRST_GRADE = 1;
private static final int SECOND_GRADE = 2;
private static final int THIRD_GRADE = 3;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ public interface QueryStudentPort {

int queryStudentCountByGradeAndEntranceYear(int grade, int entranceYear);

boolean existsByGradeAndClassRoomAndNumberAndName(SchoolNumber schoolNumber, String name);
boolean existsBySchoolNumberAndName(SchoolNumber schoolNumber, String name);
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package team.retum.jobis.domain.student.usecase;

import lombok.RequiredArgsConstructor;
import team.retum.jobis.common.annotation.UseCase;
import team.retum.jobis.common.annotation.ReadOnlyUseCase;
import team.retum.jobis.domain.student.exception.StudentAlreadyExistsException;
import team.retum.jobis.domain.student.exception.StudentNotFoundException;
import team.retum.jobis.domain.student.model.SchoolNumber;
import team.retum.jobis.domain.student.spi.QueryStudentPort;
import team.retum.jobis.domain.student.spi.QueryVerifiedStudentPort;

@RequiredArgsConstructor
@UseCase
@ReadOnlyUseCase
public class VerifyStudentUseCase {

private final QueryVerifiedStudentPort queryVerifiedStudentPort;
Expand All @@ -18,7 +18,7 @@ public class VerifyStudentUseCase {
public void execute(String gcn, String name) {
SchoolNumber parseSchoolNumber = SchoolNumber.parseSchoolNumber(gcn);

if (queryStudentPort.existsByGradeAndClassRoomAndNumberAndName(parseSchoolNumber, name)) {
if (queryStudentPort.existsBySchoolNumberAndName(parseSchoolNumber, name)) {
throw StudentAlreadyExistsException.EXCEPTION;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import team.retum.jobis.domain.application.dto.response.QueryEmploymentCountResponse;
import team.retum.jobis.domain.application.dto.response.QueryPassedApplicationStudentsResponse;
import team.retum.jobis.domain.application.dto.response.QueryRejectionReasonResponse;
import team.retum.jobis.domain.application.dto.response.StudentQueryApplicationsResponse;
import team.retum.jobis.domain.application.dto.response.QueryMyApplicationsResponse;
import team.retum.jobis.domain.application.dto.response.TeacherQueryApplicationsResponse;
import team.retum.jobis.domain.application.model.ApplicationStatus;
import team.retum.jobis.domain.application.presentation.dto.request.ChangeApplicationsStatusWebRequest;
Expand All @@ -34,7 +34,7 @@
import team.retum.jobis.domain.application.usecase.QueryEmploymentCountUseCase;
import team.retum.jobis.domain.application.usecase.QueryPassedApplicationStudentsUseCase;
import team.retum.jobis.domain.application.usecase.QueryRejectionReasonUseCase;
import team.retum.jobis.domain.application.usecase.QueryStudentApplicationsUseCase;
import team.retum.jobis.domain.application.usecase.QueryMyApplicationsUseCase;
import team.retum.jobis.domain.application.usecase.ReapplyUseCase;
import team.retum.jobis.domain.application.usecase.RejectApplicationUseCase;
import team.retum.jobis.domain.application.usecase.TeacherQueryApplicationsUseCase;
Expand All @@ -48,7 +48,7 @@ public class ApplicationWebAdapter {
private final DeleteApplicationUseCase deleteApplicationUseCase;
private final TeacherQueryApplicationsUseCase queryApplicationListService;
private final CompanyQueryApplicationsUseCase companyQueryApplicationsUseCase;
private final QueryStudentApplicationsUseCase queryStudentApplicationsUseCase;
private final QueryMyApplicationsUseCase queryMyApplicationsUseCase;
private final ChangeApplicationsStatusUseCase changeApplicationsStatusUseCase;
private final ChangeFieldTrainDateUseCase changeFieldTrainDateUseCase;
private final RejectApplicationUseCase rejectApplicationUseCase;
Expand Down Expand Up @@ -94,9 +94,9 @@ public CompanyQueryApplicationsResponse queryCompanyApplicationList() {
return companyQueryApplicationsUseCase.execute();
}

@GetMapping("/students")
public StudentQueryApplicationsResponse queryApplication() {
return queryStudentApplicationsUseCase.execute();
@GetMapping("/my")
public QueryMyApplicationsResponse queryMyApplications() {
return queryMyApplicationsUseCase.execute();
}

@ResponseStatus(HttpStatus.NO_CONTENT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public int queryStudentCountByGradeAndEntranceYear(int grade, int entranceYear)
}

@Override
public boolean existsByGradeAndClassRoomAndNumberAndName(SchoolNumber schoolNumber, String name) {
public boolean existsBySchoolNumberAndName(SchoolNumber schoolNumber, String name) {
return studentJpaRepository.existsByGradeAndClassRoomAndNumberAndName(
schoolNumber.getGrade(), schoolNumber.getClassRoom(), schoolNumber.getNumber(), name
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.requestMatchers(HttpMethod.GET, "/applications/employment/count").permitAll()
.requestMatchers(HttpMethod.GET, "/applications/pass/{company-id}").hasAnyAuthority(TEACHER.name())
.requestMatchers(HttpMethod.GET, "/applications/company").hasAuthority(COMPANY.name())
.requestMatchers(HttpMethod.GET, "/applications/students").hasAnyAuthority(STUDENT.name(), DEVELOPER.name())
.requestMatchers(HttpMethod.GET, "/applications/my").hasAnyAuthority(STUDENT.name(), DEVELOPER.name())
.requestMatchers(HttpMethod.POST, "/applications/{company-id}").hasAnyAuthority(STUDENT.name(), DEVELOPER.name())
.requestMatchers(HttpMethod.DELETE, "/applications/{application-id}").hasAuthority(STUDENT.name())
.requestMatchers(HttpMethod.PATCH, "/applications/status").hasAnyAuthority(TEACHER.name())
Expand Down

0 comments on commit 37e2bf5

Please sign in to comment.