Skip to content

Commit

Permalink
refactor : ์—๋Ÿฌ fix
Browse files Browse the repository at this point in the history
  • Loading branch information
imenuuu committed Feb 18, 2024
1 parent 837a01c commit 83d4422
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ public CommonResponse<String> createToken(@PathVariable Long userId){
return CommonResponse.onSuccess(accessToken + " " + refreshToken);
}
@PostMapping("/badge/{badgeId}")
public CommonResponse<String> postBadgeImage(@PathVariable Long badgeId, @RequestPart MultipartFile multipartFile){
wineBadgeService.uploadBadgeImage(badgeId, multipartFile);
public CommonResponse<String> postBadgeImage(@PathVariable Long badgeId,
@RequestPart MultipartFile activateImg,
@RequestPart MultipartFile unActivateImg){
//wineBadgeService.uploadBadgeImage(badgeId, multipartFile);
wineBadgeService.uploadBadgeImage(badgeId, activateImg, unActivateImg);
return CommonResponse.onSuccess("์„ฑ๊ณต");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public CommonResponse<TastingNoteResponse.NoteFilterDTO> getNoteFilter(@Paramete
}


@PatchMapping("/{noteId}")
@RequestMapping(value = "/{noteId}", consumes = {"multipart/form-data"}, method = RequestMethod.PATCH)
public CommonResponse<TastingNoteResponse.UpdateTastingNoteDTO> updateTastingNote(
@AuthenticationPrincipal User user,
@PathVariable Long noteId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,27 +261,32 @@ public TastingNoteImage TastingImg(TastingNote tastingNote, String imgUrl) {
.build();
}

public PageResponse<List<TastingNoteResponse.TastingNoteListDTO>> TastingNoteList(Page<TastingNote> tastingNotes) {
public PageResponse<List<TastingNoteResponse.TastingNoteListDTO>> toTastingNoteList(Page<TastingNote> tastingNotes) {
List<TastingNoteResponse.TastingNoteListDTO> tastingNoteListDTOS = new ArrayList<>();

int no = 0;
tastingNotes.getContent().forEach(
result -> {
tastingNoteListDTOS.add(
TastingNoteResponse.TastingNoteListDTO.builder()
.noteId(result.getId())
.wineName(result.getWine().getName())
.country(result.getWine().getCountry())
.starRating(result.getStarRating())
.buyAgain(result.getBuyAgain())
.wineType(result.getWine().getType())
.build()
);
toTastingNoteListDTO(result, no));
}
);

return new PageResponse<>( tastingNotes.isLast(),tastingNotes.getTotalElements(), tastingNoteListDTOS);
}

private TastingNoteResponse.TastingNoteListDTO toTastingNoteListDTO(TastingNote result, int no) {
no++;
return TastingNoteResponse.TastingNoteListDTO.builder()
.noteId(result.getId())
.wineName(result.getWine().getName())
.country(result.getWine().getCountry())
.starRating(result.getStarRating())
.buyAgain(result.getBuyAgain())
.wineType(result.getWine().getType())
.build();
}

public TastingNoteResponse.TastingNoteDTO TastingNote(TastingNote tastingNote) {
Wine wine = tastingNote.getWine();
List<TastingNoteImage> tastingNoteImages = tastingNote.getTastingNoteImages();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public static class UpdateTastingNoteDTO {
private List<SmellKeyword> deleteSmellKeywordList;

@Schema(name = "deleteImgLists ์‚ญ์ œ์‚ฌํ•ญ ์žˆ์„ ๊ฒฝ์šฐ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”",description = "ํ…Œ์ด์ŠคํŒ… ๋…ธํŠธ ์ด๋ฏธ์ง€ ๋ฆฌ์ŠคํŠธ", required = false)
private List<Long> deleteImgLists;
private List<Long> deleteImgList;

public Boolean getBuyAgain() {
return buyAgain;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private void updateSmellKeyword(TastingNoteRequest.UpdateTastingNoteDTO request,

private void updateTastingNoteImg(TastingNoteRequest.UpdateTastingNoteDTO request, TastingNote tastingNote, List<MultipartFile> multipartFiles) {
tastingNoteImageUpload(tastingNote, multipartFiles);
imageDelete(request.getDeleteImgLists());
imageDelete(request.getDeleteImgList());
}

private void updateTastingNoteInfo(TastingNoteRequest.UpdateTastingNoteDTO request, TastingNote tastingNote) {
Expand Down Expand Up @@ -174,6 +174,6 @@ private void tastingNoteImageUpload(TastingNote tastingNote, List<MultipartFile>
public PageResponse<List<TastingNoteResponse.TastingNoteListDTO>> getTastingNoteList(User user, Integer page, Integer size, Integer order, List<Country> countries, List<WineType> wineTypes, Integer buyAgain) {
Page<TastingNote> tastingNotes = tastingNoteRepository.findTastingNotes(user, page, size, order, countries, wineTypes, buyAgain);

return tastingNoteConvertor.TastingNoteList(tastingNotes);
return tastingNoteConvertor.toTastingNoteList(tastingNotes);
}
}

0 comments on commit 83d4422

Please sign in to comment.