Skip to content

Commit

Permalink
Merge pull request #139 from TaetaetaE01/main
Browse files Browse the repository at this point in the history
[fix] : request file 없을 때 수정
  • Loading branch information
TaetaetaE01 authored Oct 11, 2024
2 parents 86f6168 + f51b132 commit 3e068de
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public void registerEvent(EventRegisterRequest eventRegisterRequest, List<Multip
throw new BusinessException(NOT_COUNCIL_MEMBER);
}

fileUtil.CheckImageFiles(multipartFiles);

List<File> files = null;
if (fileService.checkExistRequestFile(multipartFiles)) {
fileUtil.CheckImageFiles(multipartFiles);

FileSaveDTO fileSaveDTO = FileSaveDTO.builder()
.fileType(EntityType.EVENT_TYPE.getType())
.multipartFileList(multipartFiles)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ public void registerMeetings(MeetingsRegisterRequest meetingsRegisterRequest, Li
throw new BusinessException(NOT_COUNCIL_MEMBER);
}

fileUtil.checkPdfFiles(multipartFiles);

List<File> files = null;
if (fileService.checkExistRequestFile(multipartFiles)) {
fileUtil.checkPdfFiles(multipartFiles);

FileSaveDTO fileSaveDTO = FileSaveDTO.builder()
.fileType(EntityType.MEETINGS_TYPE.getType())
.multipartFileList(multipartFiles)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class RuleAdminController {

@PostMapping
public ResponseEntity<ApiResponse<Void>> registerRule(@RequestPart(value = "ruleRegisterRequest") RuleRegisterRequest ruleRegisterRequest,
@RequestPart(value = "file", required = false) List<MultipartFile> multipartFiles) {
@RequestPart(value = "file") List<MultipartFile> multipartFiles) {
ruleService.registerRule(ruleRegisterRequest, multipartFiles);
return ResponseEntity.ok(ApiResponse.success(SUCCESS));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public void registerRule(RuleRegisterRequest ruleRegisterRequest, List<Multipart
throw new BusinessException(NOT_PRESIDENT_MEMBER);
}

fileUtil.checkPdfFiles(multipartFiles);

List<File> files = null;
if (fileService.checkExistRequestFile(multipartFiles)) {
fileUtil.checkPdfFiles(multipartFiles);

FileSaveDTO fileSaveDTO = FileSaveDTO.builder()
.fileType(EntityType.RULE_TYPE.getType())
.multipartFileList(multipartFiles)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.List;

public interface TransactionsService {
void register(MultipartFile multipartFile, Long affiliationId);
void register(MultipartFile multipartFiles, Long affiliationId);

void update(Long transactionsId, TransactionsUpdateRequest transactionsUpdateRequest);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.example.bigbrotherbe.global.common.enums.EntityType;
import com.example.bigbrotherbe.global.file.service.FileService;
import com.example.bigbrotherbe.global.auth.util.AuthUtil;
import com.example.bigbrotherbe.global.file.util.FileUtil;
import com.example.bigbrotherbe.global.ocr.dto.OcrDto;
import com.example.bigbrotherbe.global.ocr.service.OcrService;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -40,6 +41,7 @@ public class TransactionsServiceImpl implements TransactionsService {
private final FileService fileService;

private final AuthUtil authUtil;
private final FileUtil fileUtil;

@Override
@Transactional(rollbackFor = Exception.class)
Expand All @@ -48,16 +50,17 @@ public void register(MultipartFile multipartFile, Long affiliationId) {
throw new BusinessException(NO_EXIST_AFFILIATION);
}

if (multipartFile == null || multipartFile.isEmpty()) {
if (multipartFile == null) {
throw new BusinessException(EMPTY_FILE);
}

if (authUtil.checkCouncilRole(affiliationId)) {
throw new BusinessException(NOT_COUNCIL_MEMBER);
}

OcrDto ocrDTO = ocrService.extractText(multipartFile);
fileUtil.checkPdfFile(multipartFile);

OcrDto ocrDTO = ocrService.extractText(multipartFile);
List<String[]> parseTransactions = ocrDTO.getParseTransactions();
String parseAccountNumber = ocrDTO.getParseAccountNumber();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,11 @@ public void checkPdfFiles(List<MultipartFile> multipartFiles) {
throw new BusinessException(INVALID_PDF_TYPE);
});
}

public void checkPdfFile(MultipartFile file) {
String contentType = file.getContentType();
if (contentType == null || !contentType.equals(MediaType.APPLICATION_PDF_VALUE)) {
throw new BusinessException(INVALID_PDF_TYPE);
}
}
}

0 comments on commit 3e068de

Please sign in to comment.