Skip to content

Commit

Permalink
Merge pull request #7 from STUDIO-EYE/feat/EPIC-80-post
Browse files Browse the repository at this point in the history
Feat/epic 80 post
  • Loading branch information
ibaesuyeon authored Apr 14, 2024
2 parents 7b6e77e + d5a8dd0 commit 54d19f1
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ public interface PostRepository extends JpaRepository<Post, Long> {
List<Post> findByCategoryAndProject(Category getCategory, Project project);

List<Post> findByCategoryAndProject(Category getCategory, Project project, Pageable pageable);
List<Post> findByProject(Project project);

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mju.management.domain.project.contoller;

import com.mju.management.domain.post.model.dto.request.RetrieveDetailPostRequestDto;
import com.mju.management.domain.project.dto.response.GetProjectListResponseDto;
import com.mju.management.domain.project.dto.response.GetProjectResponseDto;
import com.mju.management.domain.project.service.ProjectService;
Expand Down Expand Up @@ -53,6 +54,13 @@ public CommonResult getProject(@PathVariable Long projectId) {
return responseService.getSingleResult(project);
}

// 프로젝트 별 파일리스트 조회
@Operation(summary = "프로젝트 별 파일 리스트 조회")
@GetMapping("/{projectId}/files")
public CommonResult getProjectFiles(@PathVariable Long projectId) {
return responseService.getListResult(projectService.getProjectFiles(projectId));
}

//프로젝트 수정
@Operation(summary = "프로젝트 수정")
@PutMapping("/{projectId}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mju.management.domain.project.service;

import com.mju.management.domain.post.domain.PostFile;
import com.mju.management.domain.project.dto.reqeust.CreateProjectRequestDto;
import com.mju.management.domain.project.dto.response.GetProjectListResponseDto;
import com.mju.management.domain.project.dto.response.GetProjectResponseDto;
Expand All @@ -16,4 +17,5 @@ public interface ProjectService {
void updateProject(Long projectIndex, CreateProjectRequestDto createProjectRequestDto);
void finishProject(Long projectIndex);

List<PostFile> getProjectFiles(Long projectId);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.mju.management.domain.project.service;

import com.mju.management.domain.post.domain.Post;
import com.mju.management.domain.post.domain.PostFile;
import com.mju.management.domain.post.infrastructure.PostFileRepository;
import com.mju.management.domain.post.infrastructure.PostRepository;
import com.mju.management.domain.project.dto.response.GetProjectListResponseDto;
import com.mju.management.domain.project.dto.response.GetProjectResponseDto;
import com.mju.management.domain.project.dto.response.GetProjectUserResponseDto;
Expand All @@ -19,6 +23,7 @@
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

Expand All @@ -27,6 +32,8 @@
public class ProjectServiceImpl implements ProjectService{
private final ProjectRepository projectRepository;
private final UserServiceImpl userService;
private final PostRepository postRepository;
private final PostFileRepository postFileRepository;

@Override
@Transactional
Expand Down Expand Up @@ -126,6 +133,22 @@ public void finishProject(Long projectId) {

}

@Override
public List<PostFile> getProjectFiles(Long projectId) {
Project project = projectRepository.findByIdWithProjectUserList(projectId)
.orElseThrow(()->new NonExistentException(ExceptionList.NON_EXISTENT_PROJECT));
if(!project.isLeaderOrMember(JwtContextHolder.getUserId()))
throw new UnauthorizedAccessException(ExceptionList.UNAUTHORIZED_ACCESS);
// List<GetProjectUserResponseDto> getProjectUserResponseDtoList =
// getProjectUserResponseDtoList(project.getProjectUserList());
List<Post> posts = postRepository.findByProject(project);
List<PostFile> project_files = new ArrayList<>();
for(Post post : posts){
project_files.addAll(postFileRepository.findByPostId(post.getId()));
}
return project_files;
}

public void validateProjectPeriod(CreateProjectRequestDto createProjectRequestDto){
LocalDate startDate = createProjectRequestDto.startDateAsLocalDateType();
LocalDate endDate = createProjectRequestDto.finishDateAsLocalDateType();
Expand Down

0 comments on commit 54d19f1

Please sign in to comment.