Skip to content

Commit

Permalink
feature/213 πŸ› POI 라이브러리 좩돌 제거 (#224)
Browse files Browse the repository at this point in the history
* ✨ 비속어 μ—‘μ…€ νŒŒμ‹± ν›„ db μ €μž₯ API κ΅¬ν˜„, λ‹‰λ„€μž„ 필터링 κΈ°λŠ₯ κ΅¬ν˜„

* πŸ› POI 라이브러리 좩돌 μ—λŸ¬
  • Loading branch information
HyoBN authored Oct 18, 2023
1 parent 7446ae5 commit cf5cb89
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 54 deletions.
2 changes: 1 addition & 1 deletion src/main/java/zipdabang/server/service/RootService.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public interface RootService {

Optional<PushAlarm> findPushAlarmById(Long pushAlarmId);

void ParseExcelFile(MultipartFile file) throws IOException;
// void ParseExcelFile(MultipartFile file) throws IOException;
public boolean isNicknameContainsSlangWord(String nickname);
public boolean isNicknameReservedWord(String nickname);
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,44 +151,45 @@ public Optional<PushAlarm> findPushAlarmById(Long pushAlarmId) {
return pushAlarmRepository.findById(pushAlarmId);
}

@Override
@Transactional
public void ParseExcelFile(MultipartFile inputFile) throws IOException{
InputStream file = inputFile.getInputStream();
Workbook workbook = WorkbookFactory.create(file);
Sheet sheet = workbook.getSheetAt(0);

// 비속어 μ €μž₯
for (int i=0;i<sheet.getPhysicalNumberOfRows();i++) {
Cell cell = sheet.getRow(i).getCell(0);
if (cell.getCellType().equals(CellType.BLANK)) {
file.close();
break;
} else if (cell.getCellType().equals(CellType.NUMERIC)) {
slangWordRepository.save(new SlangWord(Double.toString(cell.getNumericCellValue())));
} else{
slangWordRepository.save(new SlangWord(cell.getStringCellValue()));
}
}

// μ˜ˆμ•½μ–΄ μ €μž₯
sheet = workbook.getSheetAt(1);

for (int i=0;i<sheet.getPhysicalNumberOfRows();i++) {
Cell cell = sheet.getRow(i).getCell(0);
if (cell.getCellType().equals(CellType.BLANK)) {
file.close();
break;
} else if (cell.getCellType().equals(CellType.NUMERIC)) {
reservedWordRepository.save(new ReservedWord(Double.toString(cell.getNumericCellValue())));
} else{
reservedWordRepository.save(new ReservedWord(cell.getStringCellValue()));
}
}

file.close();
}

// μ—‘μ…€ 파일 νŒŒμ‹± 및 비속어/μ˜ˆμ•½μ–΄ db에 μ €μž₯ λ©”μ†Œλ“œ.

// @Override
// @Transactional
// public void ParseExcelFile(MultipartFile inputFile) throws IOException{
// InputStream file = inputFile.getInputStream();
// Workbook workbook = WorkbookFactory.create(file);
// Sheet sheet = workbook.getSheetAt(0);
//
// // 비속어 μ €μž₯
// for (int i=0;i<sheet.getPhysicalNumberOfRows();i++) {
// Cell cell = sheet.getRow(i).getCell(0);
// if (cell.getCellType().equals(CellType.BLANK)) {
// file.close();
// break;
// } else if (cell.getCellType().equals(CellType.NUMERIC)) {
// slangWordRepository.save(new SlangWord(Double.toString(cell.getNumericCellValue())));
// } else{
// slangWordRepository.save(new SlangWord(cell.getStringCellValue()));
// }
// }
//
// // μ˜ˆμ•½μ–΄ μ €μž₯
// sheet = workbook.getSheetAt(1);
//
// for (int i=0;i<sheet.getPhysicalNumberOfRows();i++) {
// Cell cell = sheet.getRow(i).getCell(0);
// if (cell.getCellType().equals(CellType.BLANK)) {
// file.close();
// break;
// } else if (cell.getCellType().equals(CellType.NUMERIC)) {
// reservedWordRepository.save(new ReservedWord(Double.toString(cell.getNumericCellValue())));
// } else{
// reservedWordRepository.save(new ReservedWord(cell.getStringCellValue()));
// }
// }
//
// file.close();
// }

@Override
public boolean isNicknameContainsSlangWord(String nickname) {
Expand Down
23 changes: 8 additions & 15 deletions src/main/java/zipdabang/server/web/controller/RootController.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,20 +145,13 @@ public ResponseDto<RootResponseDto.ReadPushAlarm> readPushAlarm(@CheckTempMember
}


@Operation(summary = "λ‹‰λ„€μž„ ν•„ν„°λ§μš© μ—‘μ…€ νŒŒμ‹± API βœ”οΈπŸ”‘", description = "λ‹‰λ„€μž„ ν•„ν„°λ§μš© μ—‘μ…€ νŒŒμ‹± API")
@PostMapping(value = "/excel", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE})
// @Parameters({
// @Parameter(name = "member", hidden = true)
// @Operation(summary = "λ‹‰λ„€μž„ ν•„ν„°λ§μš© μ—‘μ…€ νŒŒμ‹± API βœ”οΈ", description = "λ‹‰λ„€μž„ ν•„ν„°λ§μš© μ—‘μ…€ νŒŒμ‹± API")
// @PostMapping(value = "/excel", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE})
// @ApiResponses({
// @ApiResponse(responseCode = "2000", description = "OK 성곡"),
// })
@ApiResponses({
@ApiResponse(responseCode = "2000", description = "OK 성곡"),
})
public ResponseDto<RootResponseDto.ExcelParsingDto> parsingExcelFile(@ModelAttribute MultipartFile file) throws IOException{
// 멀버 idκ°€ 3이면 κ°€λŠ₯ν•˜λ„λ‘ λ„£κΈ°
// resources에 μ—‘μ…€ 파일 λ„£κ³  ν•΄λ‹Ή 경둜둜 파일 μ°ΎκΈ°.
// νŒŒμ‹±ν•΄μ„œ λ‹‰λ„€μž„λ“€ λ‹€ db λ§Œλ“€μ–΄μ„œ μ €μž₯ν•˜κΈ°.
// valid μ–΄λ…Έν…Œμ΄μ…˜μ—μ„œ 필터링.
rootService.ParseExcelFile(file);
return null;
}
// public ResponseDto<RootResponseDto.ExcelParsingDto> parsingExcelFile(@ModelAttribute MultipartFile file) throws IOException{
// rootService.ParseExcelFile(file);
// return null;
// }
}

0 comments on commit cf5cb89

Please sign in to comment.