Skip to content

Commit

Permalink
Merge pull request #80 from Gongjakso/feat/apply
Browse files Browse the repository at this point in the history
fix : 공고 상세 정보 member 정보, 현재 인원 코드 수정, accessToken 제거
  • Loading branch information
sycuuui authored Feb 19, 2024
2 parents 8235f79 + 6aa6968 commit 37cac31
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public ApplicationResponse<PostRes> create(@AuthenticationPrincipal PrincipalDet

@Operation(summary = "공모전/프로젝트 공고 상세 조회 API", description = "공모전/프로젝트 공고 상세 조회")
@GetMapping("/{id}")
public ApplicationResponse<PostDetailRes> read(@AuthenticationPrincipal PrincipalDetails principalDetails, @PathVariable("id") Long id) {
return ApplicationResponse.ok(postService.read(principalDetails.getMember(), id));
public ApplicationResponse<PostDetailRes> read(@PathVariable("id") Long id) {
return ApplicationResponse.ok(postService.read(id));
}

@Operation(summary = "공모전/프로젝트 공고 수정 API", description = "팀빌딩 페이지에서 정보 입력 후 공고 수정")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public record PostDetailRes(
LocalDateTime endDate,
Long daysRemaining,
Long maxPerson,
Long currentPerson,
int currentPerson,
List<StackName> stackNames,
List<Category> categories,
MeetingMethod meetingMethod,
Expand All @@ -39,11 +39,11 @@ public record PostDetailRes(
Long scrapCount
) {

public static PostDetailRes of(Post post, Member member, Long currentPerson) {
public static PostDetailRes of(Post post, int currentPerson) {
return PostDetailRes.builder()
.postId(post.getPostId())
.memberId(member.getMemberId())
.memberName(member.getName())
.memberId(post.getMember().getMemberId())
.memberName(post.getMember().getName())
.title(post.getTitle())
.contents(post.getContents())
.urlLink("https://www.naver.com")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.gongjakso.server.domain.post.service;

import com.gongjakso.server.domain.apply.repository.ApplyRepository;
import com.gongjakso.server.domain.member.entity.Member;
import com.gongjakso.server.domain.post.common.Pagination;
import com.gongjakso.server.domain.post.dto.*;
Expand Down Expand Up @@ -34,6 +35,7 @@
public class PostService {
private final PostRepository postRepository;
private final PostScrapRepository postScrapRepository;
private final ApplyRepository applyRepository;

@Transactional
public PostRes create(Member member, PostReq req) {
Expand Down Expand Up @@ -69,11 +71,12 @@ public PostRes create(Member member, PostReq req) {
}

@Transactional
public PostDetailRes read(Member member, Long id) {
public PostDetailRes read(Long id) {
try {
Post post = postRepository.findById(id)
.orElseThrow(() -> new ApplicationException(NOT_FOUND_POST_EXCEPTION));
return PostDetailRes.of(post, member, 3L);
int current_person = (int) applyRepository.countApplyByPost(post);
return PostDetailRes.of(post, current_person);
}catch (Exception e){
throw new ApplicationException(INVALID_VALUE_EXCEPTION);
}
Expand Down

0 comments on commit 37cac31

Please sign in to comment.