-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Api-Release-v0.0.2-17
- Loading branch information
Showing
22 changed files
with
186 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 19 additions & 4 deletions
23
Match-Api/src/main/java/com/example/matchapi/admin/notice/service/AdminNoticeService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,44 @@ | ||
package com.example.matchapi.admin.notice.service; | ||
|
||
import com.example.matchdomain.notice.adaptor.NoticeAdapter; | ||
import com.example.matchdomain.notice.adaptor.NoticeContentAdaptor; | ||
import com.example.matchdomain.notice.entity.Notice; | ||
import com.example.matchdomain.notice.entity.NoticeContent; | ||
import com.example.matchdomain.notice.repository.NoticeContentRepository; | ||
import com.example.matchdomain.notice.repository.NoticeRepository; | ||
import com.example.matchinfrastructure.config.s3.S3UploadService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.cache.annotation.CacheEvict; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
import static com.example.matchdomain.common.model.ContentsType.IMG; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class AdminNoticeService { | ||
private final NoticeRepository noticeRepository; | ||
private final NoticeContentRepository noticeContentRepository; | ||
private final NoticeContentAdaptor noticeContentAdaptor; | ||
private final NoticeAdapter noticeAdapter; | ||
private final S3UploadService s3UploadService; | ||
|
||
@CacheEvict(value = "noticeCache", allEntries = true, cacheManager = "ehcacheManager") | ||
public void uploadNoticeList(List<NoticeContent> noticeContents, Notice notice) { | ||
notice = noticeRepository.save(notice); | ||
notice = noticeAdapter.save(notice); | ||
|
||
for(NoticeContent noticeContent : noticeContents){ | ||
noticeContent.setNoticeId(notice.getId()); | ||
} | ||
|
||
noticeContentRepository.saveAll(noticeContents); | ||
noticeContentAdaptor.saveAll(noticeContents); | ||
} | ||
|
||
public void deleteNotice(Long noticeId) { | ||
Notice notice = noticeAdapter.findNoticeDetail(noticeId); | ||
List<NoticeContent> noticeContents = notice.getNoticeContents(); | ||
for(NoticeContent noticeContent : noticeContents){ | ||
if(noticeContent.getContentsType().equals(IMG))s3UploadService.deleteFile(noticeContent.getContents()); | ||
} | ||
noticeAdapter.delete(notice); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.