Skip to content

Commit

Permalink
Merge branch 'develop' into feat/#2-implement-login-using-oauth
Browse files Browse the repository at this point in the history
  • Loading branch information
yunhacandy authored Aug 14, 2024
2 parents a22148d + b0ad6e0 commit 4f3788c
Show file tree
Hide file tree
Showing 13 changed files with 185 additions and 74 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cotato.growingpain.log.domain.controller;

import cotato.growingpain.common.Response;
import cotato.growingpain.log.domain.dto.JobPostListRetrieveDTO;
import cotato.growingpain.log.domain.dto.JobPostRequestDTO;
import cotato.growingpain.log.domain.dto.JobPostRetrieveDTO;
import cotato.growingpain.log.domain.entity.JobPost;
Expand Down Expand Up @@ -43,14 +44,24 @@ public Response<JobPost> createJobPost(@RequestBody @Valid JobPostRequestDTO req
return Response.createSuccess("지원 현황 등록 완료", null);
}

@Operation(summary = "지원 현황 조회", description = "지원 현황을 조회하기 위한 메소드")
@Operation(summary = "지원 현황 리스트 조회", description = "지원 현황 리스트를 조회하기 위한 메소드")
@ApiResponse(content = @Content(schema = @Schema(implementation = Response.class)))
@GetMapping("")
@ResponseStatus(HttpStatus.OK)
public Response<List<JobPostRetrieveDTO>> getJobPosts(
public Response<List<JobPostListRetrieveDTO>> getJobPosts(
@AuthenticationPrincipal Long memberId) {
List<JobPostRetrieveDTO> retrievedJobPost = jobService.jobPostRetrieveList(memberId);
return Response.createSuccess("지원 현황 조회 완료", retrievedJobPost);
List<JobPostListRetrieveDTO> retrievedJobPostList = jobService.jobPostRetrieveList(memberId);
return Response.createSuccess("지원 현황 리스트 조회 완료", retrievedJobPostList);
}

@Operation(summary = "지원 현황 상세 삭제", description = "지원 현황 상세 정보를 조회하기 위한 메소드")
@ApiResponse(content = @Content(schema = @Schema(implementation = Response.class)))
@ResponseStatus(HttpStatus.OK)
@GetMapping("/{jobPostId}")
public Response<JobPostRetrieveDTO> getJobPostById(@PathVariable Long jobPostId) {

JobPostRetrieveDTO retrievedJobPost = jobService.getJobPostById(jobPostId);
return Response.createSuccess("지원 현황 상세 조회 완료", retrievedJobPost);
}

@Operation(summary = "지원 현황 내용 수정", description = "지원 현황을 수정하기 위한 메소드")
Expand All @@ -77,4 +88,6 @@ public Response<JobPost> updateJobPost(

return Response.createSuccess("지원 현황 삭제 완료", null);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package cotato.growingpain.log.domain.dto;

import cotato.growingpain.log.domain.entity.ApplicationDetail;
import lombok.Builder;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Builder
public record ApplicationDetailDTO(
Long id,
String title,
String content
) {
public static ApplicationDetailDTO fromEntity(ApplicationDetail applicationDetail) {
return ApplicationDetailDTO.builder()
.id(applicationDetail.getId())
.title(applicationDetail.getTitle())
.content(applicationDetail.getContent())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package cotato.growingpain.log.domain.dto;

import cotato.growingpain.log.domain.entity.JobApplication;
import lombok.Builder;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Builder
public record JobApplicationListRetrieveDTO(
String applicationType,
String status,
String endDate
) {
public static JobApplicationListRetrieveDTO fromEntity(JobApplication jobApplication) {
String status = jobApplication.getResult().toString();

if ("DOCUMENT".equals(jobApplication.getApplicationType().toString())) {
status = jobApplication.getResult() != null ? jobApplication.getResult().toString() : null;
} else if ("INTERVIEW".equals(jobApplication.getApplicationType().toString())) {
status = jobApplication.getResult() != null ? jobApplication.getResult().toString() : null;
}

return JobApplicationListRetrieveDTO.builder()
.applicationType(String.valueOf(jobApplication.getApplicationType()))
.status(status)
.endDate(jobApplication.getApplicationCloseDate())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,40 @@
package cotato.growingpain.log.domain.dto;

import cotato.growingpain.log.domain.entity.JobApplication;
import java.util.List;
import lombok.Builder;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Builder
public record JobApplicationRetrieveDTO(
Long id,
String applicationType,
String status,
String endDate
String place,
String result,
String submissionStatus,
String resultStatus,
String applicationStartDate,
String applicationCloseDate,
Long memberId,
Long jobPostId,
List<ApplicationDetailDTO> applicationDetails
) {
public static JobApplicationRetrieveDTO fromEntity(JobApplication jobApplication) {
String status = jobApplication.getResult().toString();

if ("DOCUMENT".equals(jobApplication.getApplicationType().toString())) {
status = jobApplication.getResult() != null ? jobApplication.getResult().toString() : null;
} else if ("INTERVIEW".equals(jobApplication.getApplicationType().toString())) {
status = jobApplication.getResult() != null ? jobApplication.getResult().toString() : null;
}
List<ApplicationDetailDTO> applicationDetailList = jobApplication.getApplicationDetails().stream()
.map(ApplicationDetailDTO::fromEntity)
.toList();

return JobApplicationRetrieveDTO.builder()
.applicationType(String.valueOf(jobApplication.getApplicationType()))
.status(status)
.endDate(jobApplication.getApplicationCloseDate())
.id(jobApplication.getId())
.applicationType(jobApplication.getApplicationType().getDescription())
.place(jobApplication.getPlace())
.result(jobApplication.getResult().getDescription())
.submissionStatus(String.valueOf(jobApplication.isSubmissionStatus()))
.resultStatus(String.valueOf(jobApplication.isResultStatus()))
.applicationStartDate(jobApplication.getApplicationStartDate())
.applicationCloseDate(jobApplication.getApplicationCloseDate())
.applicationDetails(applicationDetailList)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package cotato.growingpain.log.domain.dto;

import cotato.growingpain.log.domain.entity.JobPost;
import java.util.List;
import lombok.Builder;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Builder
public record JobPostListRetrieveDTO(
String companyName,
String jobPart,
List<JobApplicationListRetrieveDTO> jobApplications
) {
public static JobPostListRetrieveDTO fromEntity(JobPost jobPost) {
List<JobApplicationListRetrieveDTO> jobApplicationList = jobPost.getJobApplications().stream()
.map(JobApplicationListRetrieveDTO::fromEntity)
.toList();

return JobPostListRetrieveDTO.builder()
.companyName(jobPost.getCompanyName())
.jobPart(jobPost.getJobPart())
.jobApplications(jobApplicationList)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,22 @@
@Slf4j
@Builder
public record JobPostRetrieveDTO(
Long jobPostId,
String companyName,
String jobPart,
List<JobApplicationRetrieveDTO> jobApplications
) {
public static JobPostRetrieveDTO fromEntity(JobPost jobPost) {
List<JobApplicationRetrieveDTO> jobApplicationList = jobPost.getJobApplications().stream()
List<JobApplicationRetrieveDTO> jobApplication = jobPost.getJobApplications().stream()
.map(JobApplicationRetrieveDTO::fromEntity)
.toList();

return JobPostRetrieveDTO.builder()
.jobPostId(jobPost.getId())
.companyName(jobPost.getCompanyName())
.jobPart(jobPost.getJobPart())
.jobApplications(jobApplicationList)
.jobApplications(jobApplication)
.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,5 @@ public void update(JobPostRequestDTO jobPostRequestDTO, JobApplicationRepository
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

import cotato.growingpain.log.domain.entity.JobPost;
import java.util.List;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;

public interface JobPostRepository extends JpaRepository<JobPost, Long> {
List<JobPost> findByMemberId(Long memberId);

Optional<JobPost> findById(Long jobPostId);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cotato.growingpain.log.domain.service;

import cotato.growingpain.log.domain.dto.JobPostListRetrieveDTO;
import cotato.growingpain.log.domain.dto.JobPostRequestDTO;
import cotato.growingpain.log.domain.dto.JobPostRetrieveDTO;
import cotato.growingpain.log.domain.entity.JobApplication;
Expand Down Expand Up @@ -28,7 +29,7 @@ public class JobService {

private final ApplicationDetailRepository applicationDetailRepository;

public JobPost createJobPost(final JobPostRequestDTO jobPostRequest, Long memberId) {
public void createJobPost(final JobPostRequestDTO jobPostRequest, Long memberId) {

Member member = memberRepository.findById(memberId)
.orElseThrow(() -> new RuntimeException("Member not found with ID: " + memberId));
Expand All @@ -53,18 +54,25 @@ public JobPost createJobPost(final JobPostRequestDTO jobPostRequest, Long member
});
});

return savedJobPost;
}

public List<JobPostRetrieveDTO> jobPostRetrieveList(final Long memberId) {
public List<JobPostListRetrieveDTO> jobPostRetrieveList(final Long memberId) {
List<JobPost> jobPosts = jobPostRepository.findByMemberId(memberId);

return jobPosts.stream()
.map(JobPostRetrieveDTO::fromEntity)
.map(JobPostListRetrieveDTO::fromEntity)
.collect(Collectors.toList());
}

public JobPost updateJobApplication(Long jobPostId, JobPostRequestDTO request, Long memberId) {
public JobPostRetrieveDTO getJobPostById(final Long jobPostId) {
JobPost jobPost = jobPostRepository.findById(jobPostId)
.orElseThrow(() -> new RuntimeException("JobPost not found with ID: " + jobPostId));

return JobPostRetrieveDTO.fromEntity(jobPost);
}


public void updateJobApplication(Long jobPostId, JobPostRequestDTO request, Long memberId) {
JobPost jobPost = jobPostRepository.findById(jobPostId)
.orElseThrow(() -> new RuntimeException("JobPost not found with ID: " + jobPostId));

Expand All @@ -73,11 +81,10 @@ public JobPost updateJobApplication(Long jobPostId, JobPostRequestDTO request, L
}

jobPost.update(request, jobApplicationRepository, applicationDetailRepository);
JobPost updatedJobPost = jobPostRepository.save(jobPost);
jobPostRepository.save(jobPost);

log.info("Updated JobPost with ID: {}", jobPostId);

return updatedJobPost;
}

public void deleteJobPost(Long jobPostId, Long memberId) {
Expand Down
10 changes: 5 additions & 5 deletions src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
spring:
application:
name: application-dev
name: application-local

datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
Expand Down Expand Up @@ -30,7 +30,7 @@ jwt:
refresh:
expiration: 86400000 #7일

#logging:
# discord:
# webhook-url: ${DISCORD_WEBHOOK_URL}
# config: classpath:logback-test.xml
logging:
discord:
webhook-uri: ${DISCORD_WEBHOOK_URI}
config: classpath:logback-test.xml
2 changes: 1 addition & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
spring:
profiles:
active: local # dev: 개발 서버, local: 로컬 개발
active: dev # dev: 개발 서버, local: 로컬 개발

output:
ansi:
Expand Down
38 changes: 38 additions & 0 deletions src/main/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<!--Discord Log-->
<springProperty name="DISCORD_WEBHOOK_URI" source="logging.discord.webhook-uri"/>
<appender name="DISCORD" class="com.github.napstr.logback.DiscordAppender">
<webhookUri>
${DISCORD_WEBHOOK_URI}
</webhookUri>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %msg %n</pattern>
</layout>
<username>에러났댜ㅑㅑㅑㅑㅑㅑ</username>
<avatarUrl>
https://img.freepik.com/premium-photo/server-logs-analysis-closeup-developing-programming-and-coding-technologies-developer-working-on-web-sites-codes-in-office_372999-779.jpg
</avatarUrl>
<tts>false</tts>
</appender>

<!--Consol appender 설정-->
<appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<Pattern>%d %-5level %logger{35} - %msg%n</Pattern>
</encoder>
</appender>

<appender name="ASYNC_DISCORD" class="ch.qos.logback.classic.AsyncAppender">
<appender-ref ref="DISCORD"/>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
</appender>

<!--로그 레벨 지정-->
<root level="INFO">
<appender-ref ref="Console"/>
<appender-ref ref="ASYNC_DISCORD"/>
</root>
</configuration>
Loading

0 comments on commit 4f3788c

Please sign in to comment.