-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(#53): converted banner service classes java to kotlin
- Loading branch information
1 parent
3567db5
commit d15f258
Showing
2 changed files
with
33 additions
and
39 deletions.
There are no files selected for viewing
39 changes: 0 additions & 39 deletions
39
archive-application/src/main/java/site/archive/service/banner/BannerService.java
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
archive-application/src/main/kotlin/site/archive/service/banner/BannerService.kt
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package site.archive.service.banner | ||
|
||
import org.springframework.stereotype.Service | ||
import org.springframework.transaction.annotation.Transactional | ||
import site.archive.domain.banner.Banner | ||
import site.archive.domain.banner.BannerRepository | ||
import site.archive.domain.banner.BannerType | ||
import site.archive.dto.v2.BannerListResponseDto | ||
import site.archive.dto.v2.BannerResponseDto | ||
|
||
@Service | ||
@Transactional(readOnly = true) | ||
class BannerService(val bannerRepository: BannerRepository) { | ||
|
||
fun getAllBanner(): BannerListResponseDto { | ||
val bannerResponse = bannerRepository.findAllByOrderByCreatedAtDesc() | ||
.map { BannerResponseDto(it.type.toString(), it.summaryImage, it.mainContent) } | ||
.toList() | ||
return BannerListResponseDto(bannerResponse) | ||
} | ||
|
||
@Transactional | ||
fun createBanner(summaryImageUri: String, mainContent: String, type: BannerType): BannerResponseDto { | ||
val banner = bannerRepository.save(Banner(summaryImageUri, mainContent, type)) | ||
return BannerResponseDto.from(banner) | ||
} | ||
|
||
@Transactional | ||
fun deleteBanner(bannerId: Long) { | ||
bannerRepository.deleteById(bannerId) | ||
} | ||
|
||
} |