Skip to content

Commit

Permalink
feat : 프로젝트 참가 신청서 목록 조회
Browse files Browse the repository at this point in the history
  • Loading branch information
youKeon committed Oct 1, 2023
1 parent 50f4fff commit a867a40
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.graphy.backend.domain.recruitment.domain.Position;
import com.graphy.backend.domain.recruitment.dto.request.CreateRecruitmentRequest;
import com.graphy.backend.domain.recruitment.dto.request.UpdateRecruitmentRequest;
import com.graphy.backend.domain.recruitment.dto.response.GetApplicationResponse;
import com.graphy.backend.domain.recruitment.dto.response.GetRecruitmentDetailResponse;
import com.graphy.backend.domain.recruitment.dto.response.GetRecruitmentResponse;
import com.graphy.backend.domain.recruitment.service.RecruitmentService;
Expand Down Expand Up @@ -57,6 +58,15 @@ public ResponseEntity<ResultResponse> recruitmentList(@RequestParam(required = f
return ResponseEntity.ok(ResultResponse.of(ResultCode.RECRUITMENT_PAGING_GET_SUCCESS, result));
}

@Operation(summary = "findApplicationList", description = "프로젝트 참가 신청서 목록 조회")
@GetMapping("{recruitmentId}/applications")
public ResponseEntity<ResultResponse> applicationList(@PathVariable Long recruitmentId,
PageRequest pageRequest) {
Pageable pageable = pageRequest.of();
List<GetApplicationResponse> result = recruitmentService.findApplicationList(recruitmentId, pageable);
return ResponseEntity.ok(ResultResponse.of(ResultCode.APPLICATION_PAGING_GET_SUCCESS, result));
}

@Operation(summary = "updateRecruitment", description = "구인 게시글 수정")
@PutMapping("/{recruitmentId}")
public ResponseEntity<ResultResponse> RecruitmentModify(@PathVariable Long recruitmentId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.graphy.backend.domain.member.domain.Member;
import com.graphy.backend.domain.project.domain.Tag;
import com.graphy.backend.global.common.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -15,7 +16,7 @@
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Application {
public class Application extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.graphy.backend.domain.recruitment.dto.response;

import com.graphy.backend.domain.recruitment.domain.Application;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class GetApplicationResponse {
private Long id;
private String memberNickname;
private String introduction;

public static GetApplicationResponse from(Application application) {
return GetApplicationResponse.builder()
.id(application.getId())
.memberNickname(application.getMember().getNickname())
.introduction(application.getIntroduction())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.graphy.backend.domain.recruitment.repository;

import com.graphy.backend.domain.recruitment.domain.Application;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;

public interface ApplicationRepository extends JpaRepository<Application, Long>, ApplicationCustomRepository {
Page<Application> findAllByRecruitmentId(Long id, Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,35 @@
import com.graphy.backend.domain.member.domain.Member;
import com.graphy.backend.domain.project.domain.Tags;
import com.graphy.backend.domain.project.service.TagService;
import com.graphy.backend.domain.recruitment.domain.Application;
import com.graphy.backend.domain.recruitment.domain.Position;
import com.graphy.backend.domain.recruitment.domain.Recruitment;
import com.graphy.backend.domain.recruitment.dto.request.CreateRecruitmentRequest;
import com.graphy.backend.domain.recruitment.dto.request.UpdateRecruitmentRequest;
import com.graphy.backend.domain.recruitment.dto.response.GetApplicationResponse;
import com.graphy.backend.domain.recruitment.dto.response.GetRecruitmentDetailResponse;
import com.graphy.backend.domain.recruitment.dto.response.GetRecruitmentResponse;
import com.graphy.backend.domain.recruitment.repository.ApplicationRepository;
import com.graphy.backend.domain.recruitment.repository.RecruitmentRepository;
import com.graphy.backend.global.error.ErrorCode;
import com.graphy.backend.global.error.exception.EmptyResultException;
import com.graphy.backend.global.error.exception.InvalidMemberException;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.stream.Collectors;

@Service
@RequiredArgsConstructor
public class RecruitmentService {
private final RecruitmentRepository recruitmentRepository;
private final TagService tagService;
private final RecruitmentTagService recruitmentTagService;
private final ApplicationRepository applicationRepository;
private final TagService tagService;

@Transactional
public void addRecruitment(CreateRecruitmentRequest request, Member loginUser) {
Expand Down Expand Up @@ -85,4 +91,11 @@ public void removeRecruitment(Long recruitmentId, Member loginUser) {
public Recruitment getRecruitmentById(Long id) {
return recruitmentRepository.findById(id).orElseThrow(() -> new EmptyResultException(ErrorCode.RECRUITMENT_NOT_EXIST));
}

public List<GetApplicationResponse> findApplicationList(Long recruitmentId, Pageable pageable) {
Page<Application> applicationList = applicationRepository.findAllByRecruitmentId(recruitmentId, pageable);
return applicationList.stream()
.map(GetApplicationResponse::from)
.collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public enum ResultCode {

// Application
APPLICATION_CREATE_SUCCESS("AP001", "프로젝트 참가 신청 성공"),
APPLICATION_GET_SUCCESS("AP002", "프로젝트 신청서 단건 조회 성공"),
APPLICATION_GET_SUCCESS("AP002", "프로젝트 참가 신청서 단건 조회 성공"),
APPLICATION_PAGING_GET_SUCCESS("AP003", "프로젝트 참가 신청서 페이징 조회 성공"),

// Message
MESSAGE_CREATE_SUCCESS("MSG001", "쪽지 전송 성공");
Expand Down

0 comments on commit a867a40

Please sign in to comment.