Skip to content

Commit

Permalink
♻️ : 이미지 에러 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
imenuuu committed Mar 16, 2024
1 parent 5a12700 commit e2ee5f3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ public CommonResponse<String> patchProject(@PathVariable Long projectId,
Project project = projectService.findByProjectId(projectId);
projectService.patchProject(project, modifyProject);
projectImgService.updateImageLists(project, modifyProject.getDeleteImageList(), presentFile, multipartFiles);

return CommonResponse.onSuccess("수정 성공");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public Project postProject(ProjectReq.Project projects) {
.build();
}

public ProjectImage postProjectImage(Long id, String imgUrl, ImageRepresentStatus imageRepresentStatus, int sequence) {
public ProjectImage toProductImage(Long id, String imgUrl, ImageRepresentStatus imageRepresentStatus, int sequence) {
return ProjectImage.builder()
.projectId(id)
.url(imgUrl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public void saveImgList(Long projectId, String url, List<String> imgUrlList) {

for (int i=1 ; i <= imgUrlList.size(); i++) {
if(i==imgUrlList.size()){
projectImages.add(projectConverter.postProjectImage(projectId,imgUrlList.get(i-1),REPRESENT,i));
projectImages.add(projectConverter.toProductImage(projectId,imgUrlList.get(i-1),REPRESENT,i));
}else {
projectImages.add(projectConverter.postProjectImage(projectId, imgUrlList.get(i-1),NORMAL, i));
projectImages.add(projectConverter.toProductImage(projectId, imgUrlList.get(i-1),NORMAL, i));
}
}

Expand Down Expand Up @@ -65,16 +65,16 @@ public void updateImageLists(Project project, List<Long> deleteImageList, Multip
}
if(multipartFiles != null){
List<String> imgUrlList = s3UploadService.listUploadProjectFiles(project.getId(), multipartFiles);
patchImageLists(project.getId(), imgUrlList.get(0), imgUrlList, projectsImage.size()-deleteImageList.size());
patchImageLists(project.getId(), imgUrlList, projectsImage.size()- (deleteImageList != null ?
deleteImageList.size() : 0));
}
}

public void patchImageLists(Long projectId, String url, List<String> imgUrlList, int size) {
imgUrlList.add(url);
public void patchImageLists(Long projectId, List<String> imgUrlList, int size) {
List<ProjectImage> projectImages = new ArrayList<>();

for (int i=size ; i <= imgUrlList.size(); size++) {
projectImages.add(projectConverter.postProjectImage(projectId,imgUrlList.get(i-1),REPRESENT,i));
for (int i=1 ; i <= imgUrlList.size(); i++) {
projectImages.add(projectConverter.toProductImage(projectId,imgUrlList.get(i-1),NORMAL,size+i));
}

projectImgAdaptor.saveAll(projectImages);
Expand Down

0 comments on commit e2ee5f3

Please sign in to comment.