Skip to content

Commit

Permalink
Merge pull request #529 from Travel-in-nanaland/feat/#495-report
Browse files Browse the repository at this point in the history
[Feat] report 관련 이미지 처리 수정
  • Loading branch information
jyajoo authored Dec 5, 2024
2 parents 373319c + ab116fc commit d1257a5
Show file tree
Hide file tree
Showing 13 changed files with 246 additions and 240 deletions.
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
package com.jeju.nanaland.domain.common.service;

import static com.jeju.nanaland.global.exception.ErrorCode.*;

import com.jeju.nanaland.domain.common.entity.VideoFile;
import com.jeju.nanaland.domain.common.repository.VideoFileRepository;
import com.jeju.nanaland.global.exception.ServerErrorException;
import com.jeju.nanaland.global.image_upload.S3VideoService;
import com.jeju.nanaland.global.file.service.FileUploadService;
import com.jeju.nanaland.global.image_upload.dto.S3VideoDto;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

@Slf4j
@Service
@RequiredArgsConstructor
public class VideoFileService {

private final S3VideoService s3VideoService;
private final VideoFileRepository videoFileRepository;
private final FileService fileService;
private final FileUploadService fileUploadService;

public VideoFile saveS3VideoFile(S3VideoDto s3VideoDto) {
VideoFile videoFile = VideoFile.builder()
Expand All @@ -32,15 +24,8 @@ public VideoFile saveS3VideoFile(S3VideoDto s3VideoDto) {
}

// S3에 저장될 경로 지정
public VideoFile uploadAndSaveVideoFile(File file, String directory) {
try {
MultipartFile multipartFile = fileService.convertFileToMultipartFile(file);
CompletableFuture<S3VideoDto> futureVideoDto = s3VideoService.uploadVideoToS3(multipartFile, directory);
S3VideoDto s3VideoDto = futureVideoDto.join();
return saveS3VideoFile(s3VideoDto);
} catch (IOException e) {
log.error("파일 업로드 오류: {}", e.getMessage());
throw new ServerErrorException(FILE_FAIL_ERROR.getMessage());
}
public VideoFile getAndSaveVideoFile(String fileKey) {
S3VideoDto s3VideoDto = fileUploadService.getCloudVideoUrls(fileKey);
return saveS3VideoFile(s3VideoDto);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ public BaseResponse<Null> withdrawal(
description = "유저 닉네임, 설명, 프로필 사진 수정")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(responseCode = "400", description = "파일키 형식이 맞지 않는 등 입력값이 올바르지 않은 경우", content = @Content),
@ApiResponse(responseCode = "401", description = "accessToken이 유효하지 않은 경우", content = @Content),
@ApiResponse(responseCode = "500", description = "이미지 업로드에 실패한 경우", content = @Content)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.jeju.nanaland.global.exception.ErrorCode;
import com.jeju.nanaland.global.exception.NotFoundException;
import com.jeju.nanaland.global.exception.ServerErrorException;
import com.jeju.nanaland.global.file.data.FileCategory;
import com.jeju.nanaland.global.file.service.FileUploadService;
import com.jeju.nanaland.global.image_upload.dto.S3ImageDto;
import java.util.ArrayList;
Expand Down Expand Up @@ -54,6 +55,7 @@ public void updateProfile(MemberInfoDto memberInfoDto, MemberRequest.ProfileUpda
Member member = memberInfoDto.getMember();
validateNickname(profileUpdateDto.getNickname(), member);
if (fileKey != null) {
fileUploadService.validateFileExtension(fileKey, FileCategory.MEMBER_PROFILE);
S3ImageDto s3ImageDto = fileUploadService.getCloudImageUrls(fileKey);
member.getProfileImageFile().updateImageFile(s3ImageDto.getOriginUrl(), s3ImageDto.getThumbnailUrl());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,17 @@
import com.jeju.nanaland.global.BaseResponse;
import com.jeju.nanaland.global.auth.AuthMember;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequiredArgsConstructor
Expand All @@ -37,43 +33,31 @@ public class ReportController {
@Operation(summary = "정보 수정 제안", description = "게시물 id와 카테고리를 통해 게시물 정보 수정 제안 요청")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(responseCode = "400", description = "잘못된 요청 (이메일 형식 오류, category로 NANA 요청)", content = @Content),
@ApiResponse(responseCode = "400", description = "잘못된 요청 (이메일 형식 오류, category로 NANA 요청, 파일키 형식 오류)", content = @Content),
@ApiResponse(responseCode = "404", description = "해당 게시물이 없는 경우", content = @Content),
@ApiResponse(responseCode = "500", description = "사진파일 업로드 실패 또는 관리자에게로 메일 전송 실패", content = @Content)
})
@PostMapping(value = "/info-fix",
consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@PostMapping(value = "/info-fix")
public BaseResponse<String> requestPostInfoFix(
@AuthMember MemberInfoDto memberInfoDto,
@RequestPart("reqDto") @Valid ReportRequest.InfoFixDto reqDto,
@Parameter(
description = "정보 수정 요청 이미지파일 리스트",
content = @Content(mediaType = MediaType.MULTIPART_FORM_DATA_VALUE)
)
@RequestPart(value = "multipartFileList", required = false) List<MultipartFile> imageList) {
@RequestBody @Valid ReportRequest.InfoFixDto reqDto) {

reportService.requestPostInfoFix(memberInfoDto, reqDto, imageList);
reportService.requestPostInfoFix(memberInfoDto, reqDto);
return BaseResponse.success(POST_INFO_FIX_REPORT_SUCCESS);
}

@Operation(summary = "신고 기능")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(responseCode = "400", description = "잘못된 요청인 경우", content = @Content),
@ApiResponse(responseCode = "400", description = "파일키 형식이 맞지 않는 등 입력값이 올바르지 않은 경우", content = @Content),
@ApiResponse(responseCode = "404", description = "해당 게시물이 없는 경우", content = @Content),
@ApiResponse(responseCode = "500", description = "사진파일 업로드 실패 또는 관리자에게로 메일 전송 실패", content = @Content)
})
@PostMapping(value = "/claim",
consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@PostMapping(value = "/claim")
public BaseResponse<String> requestClaimReport(
@AuthMember MemberInfoDto memberInfoDto,
@RequestPart("reqDto") @Valid ReportRequest.ClaimReportDto reqDto,
@Parameter(
description = "신고 요청 파일 리스트",
content = @Content(mediaType = MediaType.MULTIPART_FORM_DATA_VALUE)
)
@RequestPart(value = "multipartFileList", required = false) List<MultipartFile> fileList) {
reportService.requestClaimReport(memberInfoDto, reqDto, fileList);
@RequestBody @Valid ReportRequest.ClaimReportDto reqDto) {
reportService.requestClaimReport(memberInfoDto, reqDto);
return BaseResponse.success(POST_REVIEW_REPORT_SUCCESS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand Down Expand Up @@ -61,6 +62,9 @@ public static class InfoFixDto {
example = "[email protected]"
)
private String email;

@Schema(description = "파일 키 리스트", example = "[\"test/fileKey1.jpg\", \"test/fileKey2.jpeg\", \"test/fileKey3.png\"]")
private List<String> fileKeys;
}

@Data
Expand Down Expand Up @@ -110,5 +114,8 @@ public static class ClaimReportDto {
example = "[email protected]"
)
private String email;

@Schema(description = "파일 키 리스트", example = "[\"test/fileKey1.jpg\", \"test/fileKey2.jpeg\", \"test/fileKey3.png\"]")
private List<String> fileKeys;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class ClaimReportVideoFile {
private Long id;

@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@JoinColumn(name = "image_file_id", nullable = false)
@JoinColumn(name = "video_file_id", nullable = false)
private VideoFile videoFile;

@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
Expand Down
Loading

0 comments on commit d1257a5

Please sign in to comment.