Skip to content

Commit

Permalink
Merge pull request #5 from STUDIO-EYE/feat/EPIC-80-post
Browse files Browse the repository at this point in the history
[Feat] 게시글 파일리스트 조회 api 구현
  • Loading branch information
ibaesuyeon authored Apr 14, 2024
2 parents 2087a82 + 1718010 commit 33f9bf7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.mju.management.domain.post.model.dto.request.UpdatePostRequestDto;
import com.mju.management.global.model.Result.CommonResult;
import com.mju.management.domain.post.service.PostServiceImpl;
import com.mju.management.global.model.Result.ListResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
Expand Down Expand Up @@ -35,15 +36,18 @@ public CommonResult createPost(/* @AuthenticationPrincipal User user,*/
return postServiceImpl.createPost(/* user, */ createPostDto.toServiceRequest(), files);
}

@Operation(summary = "기획/제작/편집 게시글 상세 조회 API")
@Operation(summary = "기획/제작/편집 게시글 상세 - 내용 조회 API")
@GetMapping
public CommonResult retrieveDetailPost(/* @AuthenticationPrincipal User user */
@Valid RetrieveDetailPostRequestDto retrieveDetailPostRequestDto ){
System.out.println("sdfslakfjklafsjlkjflad" + retrieveDetailPostRequestDto);

return postServiceImpl.retrieveDetailPost(/* user, */ retrieveDetailPostRequestDto.toServiceRequest());
}

@Operation(summary = "기획/제작/편집 게시글 상세 조회 - 파일 리스트 조회 API")
@GetMapping("/files")
public CommonResult retrieveDetailPostFiles(@Valid RetrieveDetailPostRequestDto retrieveDetailPostRequestDto ){
return postServiceImpl.retrieveDetailPostFiles(retrieveDetailPostRequestDto.toServiceRequest());
}
// @ExceptionHandler(MaxUploadSizeExceededException.class)
@Operation(summary = "기획/제작/편집 게시글 수정 API")
@PutMapping
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mju.management.domain.post.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -25,5 +26,6 @@ public class PostFile {

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "post_id")
@JsonIgnore
private Post post;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.mju.management.global.model.Exception.ExceptionList;
import com.mju.management.global.model.Exception.UnauthorizedAccessException;
import com.mju.management.global.model.Result.CommonResult;
import com.mju.management.global.model.Result.ListResult;
import com.mju.management.global.service.ResponseService;
import com.mju.management.global.service.S3Service;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -96,6 +97,26 @@ public CommonResult retrieveDetailPost(RetrieveDetailPostRequestServiceDto dto)
return responseService.getSingleResult(PostDetailResponse.from(post, userService.getUsername(post.getWriterId())));
}

@Transactional(readOnly = true)
public CommonResult retrieveDetailPostFiles(RetrieveDetailPostRequestServiceDto dto) {
Optional<Project> optionalProject = projectRepository.findById(dto.projectId());
// if (optionalProject.isEmpty()){
// return responseService.getFailResult(INVALID_PROJECT_ID.getCode(), INVALID_PROJECT_ID.getMessage());
// }
Project project = optionalProject.get();

// 요청자가 해당 프로젝트의 팀원인지 확인
checkMemberAuthorization(project, JwtContextHolder.getUserId());

Optional<Post> optionalPost = postRepository.findById(dto.postId());
// if(optionalPost.isEmpty()){
// return responseService.getFailResult(INVALID_POST_ID.getCode(), INVALID_POST_ID.getMessage());
// }

Post post = optionalPost.get();
List<PostFile> files = post.getPostFiles();
return responseService.getListResult(files);
}
public CommonResult updatePost(UpdatePostRequestServiceDto dto, List<MultipartFile> newFiles ) throws IOException{
Optional<Project> optionalProject = projectRepository.findById(dto.projectId());
if (optionalProject.isEmpty()){
Expand Down

0 comments on commit 33f9bf7

Please sign in to comment.