diff --git a/src/main/java/com/gongjakso/server/domain/apply/controller/ApplyController.java b/src/main/java/com/gongjakso/server/domain/apply/controller/ApplyController.java index ef0f19b5..fed86c1e 100644 --- a/src/main/java/com/gongjakso/server/domain/apply/controller/ApplyController.java +++ b/src/main/java/com/gongjakso/server/domain/apply/controller/ApplyController.java @@ -1,7 +1,8 @@ package com.gongjakso.server.domain.apply.controller; -import com.gongjakso.server.domain.apply.dto.AddApplyReq; +import com.gongjakso.server.domain.apply.dto.ApplyReq; import com.gongjakso.server.domain.apply.dto.ApplicationRes; +import com.gongjakso.server.domain.apply.dto.ApplyRes; import com.gongjakso.server.domain.apply.repository.ApplyRepository; import com.gongjakso.server.domain.apply.service.ApplyService; import com.gongjakso.server.global.common.ApplicationResponse; @@ -20,13 +21,14 @@ public class ApplyController { private final ApplyRepository applyRepository; //지원 요청 api @PostMapping("/{post_id}") - public ApplicationResponse addApply(@AuthenticationPrincipal PrincipalDetails principalDetails, @PathVariable("post_id") Long postId, @RequestBody AddApplyReq req){ + public ApplicationResponse addApply(@AuthenticationPrincipal PrincipalDetails principalDetails, @PathVariable("post_id") Long postId, @RequestBody ApplyReq req){ applyService.save(principalDetails.getMember(),postId,req); return ApplicationResponse.created(); } + //프로젝트 지원서 요청 api @GetMapping("/{post_id}") - public ApplicationResponse getApply(@PathVariable("post_id") Long postId, @RequestBody AddApplyReq req){ - return ApplicationResponse.ok(); + public ApplicationResponse getApply(@PathVariable("post_id") Long postId){ + return applyService.findApply(postId); } @PatchMapping("/{apply_id}/open") public ApplicationResponse updateIsOpenStatus(@AuthenticationPrincipal PrincipalDetails principalDetails,@PathVariable("apply_id") Long applyId){ diff --git a/src/main/java/com/gongjakso/server/domain/apply/dto/ApplyList.java b/src/main/java/com/gongjakso/server/domain/apply/dto/ApplyList.java new file mode 100644 index 00000000..a13454b0 --- /dev/null +++ b/src/main/java/com/gongjakso/server/domain/apply/dto/ApplyList.java @@ -0,0 +1,11 @@ +package com.gongjakso.server.domain.apply.dto; + +import com.gongjakso.server.domain.apply.entity.Apply; + +public record ApplyList( + Long apply_id, + String name, + String state +) { + +} diff --git a/src/main/java/com/gongjakso/server/domain/apply/dto/AddApplyReq.java b/src/main/java/com/gongjakso/server/domain/apply/dto/ApplyReq.java similarity index 96% rename from src/main/java/com/gongjakso/server/domain/apply/dto/AddApplyReq.java rename to src/main/java/com/gongjakso/server/domain/apply/dto/ApplyReq.java index c2b8e100..8adbfe15 100644 --- a/src/main/java/com/gongjakso/server/domain/apply/dto/AddApplyReq.java +++ b/src/main/java/com/gongjakso/server/domain/apply/dto/ApplyReq.java @@ -5,7 +5,7 @@ import com.gongjakso.server.domain.member.entity.Member; import com.gongjakso.server.domain.post.entity.Post; -public record AddApplyReq( +public record ApplyReq( String application, String recruit_part, String type, diff --git a/src/main/java/com/gongjakso/server/domain/apply/dto/ApplyRes.java b/src/main/java/com/gongjakso/server/domain/apply/dto/ApplyRes.java new file mode 100644 index 00000000..09b46b77 --- /dev/null +++ b/src/main/java/com/gongjakso/server/domain/apply/dto/ApplyRes.java @@ -0,0 +1,20 @@ +package com.gongjakso.server.domain.apply.dto; + +import com.gongjakso.server.domain.apply.entity.Apply; +import com.gongjakso.server.domain.post.entity.Post; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.List; + +public record ApplyRes( + LocalDateTime startDate, + LocalDateTime endDate, + Long max_person, + int current_person, + List apply_list +) { + public static ApplyRes of(Post post, Apply apply,int current_person,List apply_list){ + return new ApplyRes(post.getStartDate(),post.getEndDate(),post.getMaxPerson(),current_person,apply_list); + } +} diff --git a/src/main/java/com/gongjakso/server/domain/apply/dto/OpenReq.java b/src/main/java/com/gongjakso/server/domain/apply/dto/OpenReq.java deleted file mode 100644 index 1edc907d..00000000 --- a/src/main/java/com/gongjakso/server/domain/apply/dto/OpenReq.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.gongjakso.server.domain.apply.dto; - -public record OpenReq(Boolean is_open) { -} diff --git a/src/main/java/com/gongjakso/server/domain/apply/dto/PassReq.java b/src/main/java/com/gongjakso/server/domain/apply/dto/PassReq.java deleted file mode 100644 index 1083698b..00000000 --- a/src/main/java/com/gongjakso/server/domain/apply/dto/PassReq.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.gongjakso.server.domain.apply.dto; - -public record PassReq(Boolean is_pass) { -} diff --git a/src/main/java/com/gongjakso/server/domain/apply/dto/StateReq.java b/src/main/java/com/gongjakso/server/domain/apply/dto/StateReq.java deleted file mode 100644 index 6a90a7ad..00000000 --- a/src/main/java/com/gongjakso/server/domain/apply/dto/StateReq.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.gongjakso.server.domain.apply.dto; - -public record StateReq() { -} diff --git a/src/main/java/com/gongjakso/server/domain/apply/service/ApplyService.java b/src/main/java/com/gongjakso/server/domain/apply/service/ApplyService.java index 17261297..3aca012b 100644 --- a/src/main/java/com/gongjakso/server/domain/apply/service/ApplyService.java +++ b/src/main/java/com/gongjakso/server/domain/apply/service/ApplyService.java @@ -1,13 +1,13 @@ package com.gongjakso.server.domain.apply.service; -import com.gongjakso.server.domain.apply.dto.AddApplyReq; +import com.gongjakso.server.domain.apply.dto.ApplyReq; import com.gongjakso.server.domain.apply.dto.ApplicationRes; +import com.gongjakso.server.domain.apply.dto.ApplyRes; import com.gongjakso.server.domain.apply.entity.Apply; import com.gongjakso.server.domain.apply.repository.ApplyRepository; import com.gongjakso.server.domain.member.entity.Member; import com.gongjakso.server.domain.post.entity.Post; import com.gongjakso.server.domain.post.repository.PostRepository; -import com.gongjakso.server.domain.post.service.PostService; import com.gongjakso.server.global.common.ApplicationResponse; import lombok.RequiredArgsConstructor; import org.springframework.transaction.annotation.Transactional; @@ -20,7 +20,7 @@ public class ApplyService { private final ApplyRepository applyRepository; private final PostRepository postRepository; - public Apply save(Member member, Long post_id,AddApplyReq req){ + public Apply save(Member member, Long post_id, ApplyReq req){ Post post = postRepository.findByPostId(post_id); if (post == null) { // Handle the case where the Post entity with the given post_id is not found @@ -30,6 +30,11 @@ public Apply save(Member member, Long post_id,AddApplyReq req){ return applyRepository.save(apply); } + public ApplicationResponse findApply(Long post_id){ + Post post = postRepository.findById(post_id).orElseThrow(()->new NotFoundException("Post not found with id: " + post_id)); + + } + public ApplicationResponse updateOpen(Long apply_id){ Apply apply = applyRepository.findById(apply_id).orElseThrow(()->new NotFoundException("Apply not found with id: " + apply_id)); apply.setIs_open(true);