Skip to content

Commit

Permalink
Merge pull request #141 from TaetaetaE01/main
Browse files Browse the repository at this point in the history
[fix] file update, delete path 수정 및 dto 네이밍 통일
  • Loading branch information
TaetaetaE01 authored Oct 17, 2024
2 parents 40f6bdb + 36362c5 commit 5105eb5
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ public void updateEvent(Long eventId, EventUpdateRequest eventUpdateRequest, Lis
throw new BusinessException(NOT_COUNCIL_MEMBER);
}

fileUtil.CheckImageFiles(multipartFiles);

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

FileUpdateDTO fileUpdateDTO = FileUpdateDTO.builder()
.fileType(EntityType.EVENT_TYPE.getType())
.multipartFileList(multipartFiles)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.example.bigbrotherbe.domain.faq.controller;

import com.example.bigbrotherbe.domain.faq.dto.request.FAQModifyRequest;
import com.example.bigbrotherbe.domain.faq.dto.request.FAQUpdateRequest;
import com.example.bigbrotherbe.domain.faq.dto.request.FAQRegisterRequest;
import com.example.bigbrotherbe.domain.faq.dto.response.FAQResponse;
import com.example.bigbrotherbe.domain.faq.entity.FAQ;
Expand Down Expand Up @@ -38,9 +38,9 @@ public ResponseEntity<ApiResponse<Void>> registerFAQ(@RequestPart(value = "faqRe

@PutMapping("/{faqId}")
public ResponseEntity<ApiResponse<Void>> modifyFAQ(@PathVariable("faqId") Long faqId,
@RequestPart(value = "faqModifyRequest") FAQModifyRequest faqModifyRequest,
@RequestPart(value = "faqUpdateRequest") FAQUpdateRequest faqUpdateRequest,
@RequestPart(value = "file", required = false) List<MultipartFile> multipartFiles) {
faqService.modify(faqId, faqModifyRequest, multipartFiles);
faqService.modify(faqId, faqUpdateRequest, multipartFiles);
return ResponseEntity.ok(ApiResponse.success(SUCCESS));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class FAQModifyRequest {
public class FAQUpdateRequest {
private String title;
private String content;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.example.bigbrotherbe.domain.faq.service;

import com.example.bigbrotherbe.domain.faq.dto.request.FAQModifyRequest;
import com.example.bigbrotherbe.domain.faq.dto.request.FAQUpdateRequest;
import com.example.bigbrotherbe.domain.faq.dto.request.FAQRegisterRequest;
import com.example.bigbrotherbe.domain.faq.dto.response.FAQResponse;
import com.example.bigbrotherbe.domain.faq.entity.FAQ;
Expand All @@ -13,7 +13,7 @@
public interface FAQService {
public void register(FAQRegisterRequest faqRegisterRequest, List<MultipartFile> multipartFiles);

public void modify(Long faqId, FAQModifyRequest faqModifyRequest, List<MultipartFile> multipartFiles);
public void modify(Long faqId, FAQUpdateRequest faqUpdateRequest, List<MultipartFile> multipartFiles);

public void delete(Long faqId);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.example.bigbrotherbe.domain.faq.service;

import com.example.bigbrotherbe.domain.affiliation.service.AffiliationService;
import com.example.bigbrotherbe.domain.faq.dto.request.FAQModifyRequest;
import com.example.bigbrotherbe.domain.faq.dto.request.FAQUpdateRequest;
import com.example.bigbrotherbe.domain.faq.dto.request.FAQRegisterRequest;
import com.example.bigbrotherbe.domain.faq.dto.response.FAQResponse;
import com.example.bigbrotherbe.domain.faq.entity.FAQ;
Expand Down Expand Up @@ -69,7 +69,7 @@ public void register(FAQRegisterRequest faqRegisterRequest, List<MultipartFile>

@Override
@Transactional(rollbackFor = Exception.class)
public void modify(Long faqId, FAQModifyRequest faqModifyRequest, List<MultipartFile> multipartFiles) {
public void modify(Long faqId, FAQUpdateRequest faqUpdateRequest, List<MultipartFile> multipartFiles) {
FAQ faq = faqRepository.findById(faqId)
.orElseThrow(() -> new BusinessException(NO_EXIST_FAQ));

Expand All @@ -88,7 +88,7 @@ public void modify(Long faqId, FAQModifyRequest faqModifyRequest, List<Multipart
files = fileService.updateFile(fileUpdateDTO);
}

faq.update(faqModifyRequest.getTitle(), faqModifyRequest.getContent(), files);
faq.update(faqUpdateRequest.getTitle(), faqUpdateRequest.getContent(), files);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.example.bigbrotherbe.domain.notice.controller;

import com.example.bigbrotherbe.domain.notice.dto.request.NoticeModifyRequest;
import com.example.bigbrotherbe.domain.notice.dto.request.NoticeUpdateRequest;
import com.example.bigbrotherbe.domain.notice.dto.request.NoticeRegisterRequest;
import com.example.bigbrotherbe.domain.notice.dto.response.NoticeResponse;
import com.example.bigbrotherbe.domain.notice.entity.Notice;
Expand Down Expand Up @@ -38,9 +38,9 @@ public ResponseEntity<ApiResponse<Void>> registerNotice(@RequestPart(value = "no

@PutMapping("/{noticeId}")
public ResponseEntity<ApiResponse<Void>> modifyNotice(@PathVariable("noticeId") Long noticeId,
@RequestPart(value = "noticeModifyRequest") NoticeModifyRequest noticeModifyRequest,
@RequestPart(value = "noticeUpdateRequest") NoticeUpdateRequest noticeUpdateRequest,
@RequestPart(value = "file", required = false) List<MultipartFile> multipartFiles) {
noticeService.modify(noticeId, noticeModifyRequest, multipartFiles);
noticeService.modify(noticeId, noticeUpdateRequest, multipartFiles);
return ResponseEntity.ok(ApiResponse.success(SUCCESS));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.util.List;

@Getter
@ToString
@AllArgsConstructor
@NoArgsConstructor
@Builder
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package com.example.bigbrotherbe.domain.notice.dto.request;

import com.example.bigbrotherbe.domain.notice.entity.Notice;
import lombok.*;

@Getter
@ToString
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class NoticeModifyRequest {
public class NoticeUpdateRequest {
private String title;
private String content;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.example.bigbrotherbe.domain.notice.service;

import com.example.bigbrotherbe.domain.notice.dto.request.NoticeModifyRequest;
import com.example.bigbrotherbe.domain.notice.dto.request.NoticeUpdateRequest;
import com.example.bigbrotherbe.domain.notice.dto.request.NoticeRegisterRequest;
import com.example.bigbrotherbe.domain.notice.dto.response.NoticeResponse;
import com.example.bigbrotherbe.domain.notice.entity.Notice;
Expand All @@ -13,7 +13,7 @@
public interface NoticeService {
public void register(NoticeRegisterRequest noticeRegisterRequest, List<MultipartFile> multipartFiles);

public void modify(Long noticeId, NoticeModifyRequest noticeModifyRequest, List<MultipartFile> multipartFiles);
public void modify(Long noticeId, NoticeUpdateRequest noticeUpdateRequest, List<MultipartFile> multipartFiles);

public void delete(Long noticeId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.example.bigbrotherbe.domain.member.entity.Member;
import com.example.bigbrotherbe.domain.notice.dto.response.NoticeResponse;
import com.example.bigbrotherbe.domain.notice.entity.Notice;
import com.example.bigbrotherbe.domain.notice.dto.request.NoticeModifyRequest;
import com.example.bigbrotherbe.domain.notice.dto.request.NoticeUpdateRequest;
import com.example.bigbrotherbe.domain.notice.dto.request.NoticeRegisterRequest;
import com.example.bigbrotherbe.domain.notice.repository.NoticeRepository;
import com.example.bigbrotherbe.global.common.exception.BusinessException;
Expand Down Expand Up @@ -71,7 +71,7 @@ public void register(NoticeRegisterRequest noticeRegisterRequest, List<Multipart

@Override
@Transactional(rollbackFor = Exception.class)
public void modify(Long noticeId, NoticeModifyRequest noticeModifyRequest, List<MultipartFile> multipartFiles) {
public void modify(Long noticeId, NoticeUpdateRequest noticeUpdateRequest, List<MultipartFile> multipartFiles) {
Notice notice = noticeRepository.findById(noticeId)
.orElseThrow(() -> new BusinessException(NO_EXIST_NOTICE));

Expand All @@ -90,7 +90,7 @@ public void modify(Long noticeId, NoticeModifyRequest noticeModifyRequest, List<
files = fileService.updateFile(fileUpdateDTO);
}

notice.update(noticeModifyRequest.getTitle(), noticeModifyRequest.getContent(), files);
notice.update(noticeUpdateRequest.getTitle(), noticeUpdateRequest.getContent(), files);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public List<File> updateFile(FileUpdateDTO fileUpdateDTO) {
String fileType = fileUpdateDTO.getFileType();

files.forEach(file -> {
String fileName = file.getUrl().split("/")[3];
String fileName = file.getUrl().split("/")[4];
s3Util.deleteFile(fileType + "/" + fileName);
});

Expand All @@ -82,7 +82,7 @@ public void deleteFile(FileDeleteDTO deleteDTO) {

String fileType = deleteDTO.getFileType();
files.forEach(file -> {
String fileName = file.getUrl().split("/")[3];
String fileName = file.getUrl().split("/")[4];
s3Util.deleteFile(fileType + "/" + fileName);
});
}
Expand Down

0 comments on commit 5105eb5

Please sign in to comment.