Skip to content

Commit

Permalink
Merge pull request #13 from Leets-Official/fix/#10/applications-도메인-변경
Browse files Browse the repository at this point in the history
[fix] #11 applications 도메인 변경
  • Loading branch information
ay-eonii authored Dec 2, 2023
2 parents e719b51 + 57eb8da commit 5865d99
Show file tree
Hide file tree
Showing 27 changed files with 347 additions and 84 deletions.
17 changes: 17 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## 1. 무슨 이유로 코드를 변경했나요?

<br>

## 2. 어떤 위험이나 장애를 발견했나요?

<br>

## 3. 관련 스크린샷을 첨부해주세요.

<br>

## 4. 완료 사항

<br>

## 5. 추가 사항
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import jakarta.persistence.*;
import land.leets.domain.application.type.ApplicationStatus;
import land.leets.domain.application.type.HasInterview;
import land.leets.domain.application.type.Position;
import land.leets.domain.application.type.SubmitStatus;
import land.leets.domain.shared.BaseTimeEntity;
Expand Down Expand Up @@ -53,7 +52,7 @@ public class Application extends BaseTimeEntity {
@Enumerated(EnumType.STRING)
private Position position;

@Column()
@Column
private String career;

@Column(nullable = false)
Expand All @@ -77,17 +76,6 @@ public class Application extends BaseTimeEntity {
@Column(nullable = false, columnDefinition = "text(500)")
private String completion;

@Builder.Default
@Column(columnDefinition = "char(10)")
@Enumerated(EnumType.STRING)
private HasInterview hasInterview = HasInterview.PENDING;

@Column
private LocalDateTime fixedInterviewDate;

@Column
private String place;

@Column
private LocalDateTime appliedAt;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package land.leets.domain.application.presentation.dto;

import land.leets.domain.application.type.ApplicationStatus;
import land.leets.domain.application.type.HasInterview;
import land.leets.domain.application.type.Position;
import land.leets.domain.application.type.SubmitStatus;
import land.leets.domain.interview.presentation.dto.res.InterviewDetailsResponse;
import lombok.AllArgsConstructor;
import lombok.Getter;

Expand Down Expand Up @@ -31,11 +31,9 @@ public class ApplicationDetailsResponse {
private String pros;
private String goal;
private String completion;
private HasInterview hasInterview;
private LocalDateTime fixedInterviewDate;
private String place;
private ApplicationStatus applicationStatus;
private SubmitStatus submitStatus;
private LocalDateTime appliedAt;
private LocalDateTime updatedAt;
private InterviewDetailsResponse interview;
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package land.leets.domain.application.presentation.dto;

import land.leets.domain.application.type.ApplicationStatus;
import land.leets.domain.application.type.HasInterview;
import land.leets.domain.application.type.Position;
import land.leets.domain.interview.presentation.dto.res.InterviewResponse;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.time.LocalDateTime;

@Getter
@AllArgsConstructor
public class ApplicationResponse {
Expand All @@ -18,8 +16,7 @@ public class ApplicationResponse {
private String grade;
private Position position;
private String career;
private LocalDateTime fixedInterviewDate;
private HasInterview hasInterview;
private ApplicationStatus applicationStatus;
private String phone;
private InterviewResponse interview;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.time.LocalDateTime;

@Getter
@AllArgsConstructor
public class StatusRequest {

private ApplicationStatus applicationStatus;
private LocalDateTime fixedInterviewDate;
private String place;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import land.leets.domain.application.presentation.dto.ApplicationRequest;
import land.leets.domain.application.presentation.dto.ApplicationResponse;
import land.leets.domain.application.presentation.dto.StatusRequest;
import land.leets.domain.interview.presentation.dto.res.InterviewDetailsResponse;
import land.leets.domain.interview.presentation.dto.res.InterviewResponse;
import org.mapstruct.*;

@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
Expand All @@ -16,8 +18,8 @@ public interface ApplicationMapper {
void updateApplicationFromDto(@MappingTarget Application application, StatusRequest request);

@BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
ApplicationResponse mappingApplicationToDto(Application application, String phone);
ApplicationResponse mappingToDto(Application application, InterviewResponse interview, String phone);

@BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
ApplicationDetailsResponse mappingApplicationDetailsToDto(Application application, String phone);
ApplicationDetailsResponse mappingDetailsToDto(Application application, InterviewDetailsResponse interview, String phone);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import land.leets.domain.application.presentation.mapper.ApplicationMapper;
import land.leets.domain.application.type.Position;
import land.leets.domain.application.type.SubmitStatus;
import land.leets.domain.interview.presentation.dto.res.InterviewResponse;
import land.leets.domain.interview.usecase.GetInterview;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

Expand All @@ -16,13 +18,15 @@
public class GetAllApplicationImpl implements GetAllApplication {
private final ApplicationRepository applicationRepository;
private final ApplicationMapper applicationMapper;
private final GetInterview getInterview;

@Override
public List<ApplicationResponse> execute() {
return applicationRepository.findAllByOrderByAppliedAtDesc().stream()
.map(application -> {
InterviewResponse interview = getInterview.execute(application);
String phone = application.getUser().getPhone();
return applicationMapper.mappingApplicationToDto(application, phone);
return applicationMapper.mappingToDto(application, interview, phone);
})
.collect(Collectors.toList());
}
Expand All @@ -34,17 +38,19 @@ public List<ApplicationResponse> execute(String position, String status) {
Position filter = Position.valueOf(position.toUpperCase());
return applicationRepository.findAllByPositionOrderByAppliedAtDesc(filter).stream()
.map(application -> {
InterviewResponse interview = getInterview.execute(application);
String phone = application.getUser().getPhone();
return applicationMapper.mappingApplicationToDto(application, phone);
return applicationMapper.mappingToDto(application, interview, phone);
})
.collect(Collectors.toList());
}

SubmitStatus filter = SubmitStatus.valueOf(status.toUpperCase());
return applicationRepository.findAllBySubmitStatusOrderByAppliedAtDesc(filter).stream()
.map(application -> {
InterviewResponse interview = getInterview.execute(application);
String phone = application.getUser().getPhone();
return applicationMapper.mappingApplicationToDto(application, phone);
return applicationMapper.mappingToDto(application, interview, phone);
})
.collect(Collectors.toList());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,27 @@
import land.leets.domain.application.exception.ApplicationNotFoundException;
import land.leets.domain.application.presentation.dto.ApplicationDetailsResponse;
import land.leets.domain.application.presentation.mapper.ApplicationMapper;
import land.leets.domain.interview.presentation.dto.res.InterviewDetailsResponse;
import land.leets.domain.interview.usecase.GetInterviewDetails;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service
@RequiredArgsConstructor
public class GetApplicationDetailsImpl implements GetApplicationDetails{
public class GetApplicationDetailsImpl implements GetApplicationDetails {

private final ApplicationRepository applicationRepository;
private final ApplicationMapper applicationMapper;
private final GetInterviewDetails getInterviewDetails;

@Override
public ApplicationDetailsResponse execute(Long id) {
Application application = applicationRepository.findById(id).orElseThrow(ApplicationNotFoundException::new);
InterviewDetailsResponse interview = getInterviewDetails.execute(application);
String phone = application.getUser().getPhone();
return applicationMapper.mappingApplicationDetailsToDto(application, phone);
return applicationMapper.mappingDetailsToDto(application, interview, phone);
}

@Override
Expand Down

This file was deleted.

This file was deleted.

36 changes: 36 additions & 0 deletions src/main/java/land/leets/domain/interview/domain/Interview.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package land.leets.domain.interview.domain;

import jakarta.persistence.*;
import land.leets.domain.application.domain.Application;
import land.leets.domain.interview.type.HasInterview;
import land.leets.domain.shared.BaseTimeEntity;
import lombok.*;

import java.time.LocalDateTime;

@Entity(name = "interviews")
@Builder
@Getter
@Setter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class Interview extends BaseTimeEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@OneToOne
private Application application;

@Builder.Default
@Column(columnDefinition = "char(10)")
@Enumerated(EnumType.STRING)
private HasInterview hasInterview = HasInterview.PENDING;

@Column(nullable = false)
private LocalDateTime fixedInterviewDate;

@Column(nullable = false)
private String place;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package land.leets.domain.interview.domain.repository;

import land.leets.domain.application.domain.Application;
import land.leets.domain.interview.domain.Interview;
import land.leets.domain.user.domain.User;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.Optional;

public interface InterviewRepository extends JpaRepository<Interview, Long> {
Optional<Interview> findByApplication_User(User user);
Optional<Interview> findByApplication(Application application);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package land.leets.domain.interview.presentation;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import land.leets.domain.interview.domain.Interview;
import land.leets.domain.interview.presentation.dto.req.FixedInterviewRequest;
import land.leets.domain.interview.presentation.dto.req.InterviewAttendanceRequest;
import land.leets.domain.interview.usecase.UpdateInterview;
import land.leets.global.error.ErrorResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
@RequestMapping("/interview")
@Tag(name = "INTERVIEW")
public class InterviewController {
private final UpdateInterview updateInterview;

@Operation(summary = "(유저) 면접 참여 여부 변경", description = "면접 참여 여부를 변경합니다.")
@ApiResponses({
@ApiResponse(responseCode = "200"),
@ApiResponse(responseCode = "400", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "403", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "404", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "500", content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
})
@PostMapping()
public Interview update(@RequestBody InterviewAttendanceRequest request) {
return updateInterview.byUser(request);
}

@Operation(summary = "(관리자) 면접 정보 변경", description = "면접 정보를 변경합니다.")
@ApiResponses({
@ApiResponse(responseCode = "200"),
@ApiResponse(responseCode = "400", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "403", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "404", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "500", content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
})
@PostMapping("/{id}")
public Interview update(@PathVariable Long id, @RequestBody FixedInterviewRequest request) {
return updateInterview.byAdmin(id, request);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package land.leets.domain.interview.presentation.dto.req;

import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.time.LocalDateTime;

@Getter
@AllArgsConstructor
public class FixedInterviewRequest {
@NotNull
private LocalDateTime fixedInterviewDate;

@NotNull
private String place;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package land.leets.domain.interview.presentation.dto.req;

import jakarta.validation.constraints.NotNull;
import land.leets.domain.interview.type.HasInterview;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public class InterviewAttendanceRequest {
@NotNull
private String email;

@NotNull
private HasInterview hasInterview;
}
Loading

0 comments on commit 5865d99

Please sign in to comment.