Skip to content

Commit

Permalink
Merge branch 'develop' into feat/json-serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
leeeryboy authored Sep 17, 2023
2 parents a973c24 + e744b21 commit 6dd812a
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ class MainRepositoryImpl(
mainImportantResponses.add(
MainImportantResponse(
id = it.id,
title = it.title,
title = it.titleForMain!!,
description = it.description,
createdAt = it.createdAt,
category = "notice"
)
Expand All @@ -97,7 +98,8 @@ class MainRepositoryImpl(
mainImportantResponses.add(
MainImportantResponse(
id = it.id,
title = it.title,
title = it.titleForMain!!,
description = it.description,
createdAt = it.createdAt,
category = "news"
)
Expand All @@ -108,7 +110,8 @@ class MainRepositoryImpl(
mainImportantResponses.add(
MainImportantResponse(
id = it.id,
title = it.title,
title = it.titleForMain!!,
description = it.description,
createdAt = it.createdAt,
category = "seminar"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import java.time.LocalDateTime
data class MainImportantResponse(
val id: Long,
val title: String,
val description: String,
val createdAt: LocalDateTime?,
val category: String,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class NewsEntity(
var isDeleted: Boolean = false,
var title: String,

var titleForMain: String?,

@Column(columnDefinition = "mediumtext")
var description: String,

Expand Down Expand Up @@ -44,6 +46,7 @@ class NewsEntity(
fun of(newsDto: NewsDto): NewsEntity {
return NewsEntity(
title = newsDto.title,
titleForMain = newsDto.titleForMain,
description = newsDto.description,
plainTextDescription = cleanTextFromHtml(newsDto.description),
date = newsDto.date,
Expand All @@ -60,6 +63,7 @@ class NewsEntity(
this.plainTextDescription = cleanTextFromHtml(updateNewsRequest.description)
}
this.title = updateNewsRequest.title
this.titleForMain = updateNewsRequest.titleForMain
this.date = updateNewsRequest.date
this.isPrivate = updateNewsRequest.isPrivate
this.isSlide = updateNewsRequest.isSlide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import java.time.LocalDateTime
data class NewsDto(
val id: Long,
val title: String,
val titleForMain: String?,
val description: String,
val tags: List<String>,
val createdAt: LocalDateTime?,
Expand All @@ -33,6 +34,7 @@ data class NewsDto(
NewsDto(
id = this.id,
title = this.title,
titleForMain = this.titleForMain,
description = this.description,
tags = this.newsTags.map { it.tag.name.krName },
createdAt = this.createdAt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ class NewsServiceImpl(
attachmentService.uploadAllAttachments(newNews, attachments)
}

if (request.isImportant && request.titleForMain.isNullOrEmpty()) {
throw CserealException.Csereal400("중요 제목이 입력되어야 합니다")
}

newsRepository.save(newNews)

val imageURL = mainImageService.createImageURL(newNews.mainImage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import jakarta.persistence.*
class NoticeEntity(
var isDeleted: Boolean = false,
var title: String,
var titleForMain: String?,

@Column(columnDefinition = "mediumtext")
var description: String,

Expand Down Expand Up @@ -43,6 +45,7 @@ class NoticeEntity(
}

this.title = updateNoticeRequest.title
this.titleForMain = updateNoticeRequest.titleForMain
this.description = updateNoticeRequest.description
this.isPrivate = updateNoticeRequest.isPrivate
this.isPinned = updateNoticeRequest.isPinned
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import java.time.LocalDateTime
data class NoticeDto(
val id: Long,
val title: String,
val titleForMain: String?,
val description: String,
val author: String?,
val tags: List<String>,
Expand All @@ -33,6 +34,7 @@ data class NoticeDto(
NoticeDto(
id = this.id,
title = this.title,
titleForMain = this.titleForMain,
description = this.description,
author = this.author.name,
tags = this.noticeTags.map { it.tag.name.krName },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class NoticeServiceImpl(

val newNotice = NoticeEntity(
title = request.title,
titleForMain = request.titleForMain,
description = request.description,
plainTextDescription = cleanTextFromHtml(request.description),
isPrivate = request.isPrivate,
Expand All @@ -103,6 +104,10 @@ class NoticeServiceImpl(
attachmentService.uploadAllAttachments(newNotice, attachments)
}

if (request.isImportant && request.titleForMain.isNullOrEmpty()) {
throw CserealException.Csereal400("중요 제목이 입력되어야 합니다")
}

noticeRepository.save(newNotice)

val attachmentResponses = attachmentService.createAttachmentResponses(newNotice.attachments)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class SeminarEntity(

var title: String,

var titleForMain: String?,

@Column(columnDefinition = "mediumtext")
var description: String,

Expand Down Expand Up @@ -70,6 +72,7 @@ class SeminarEntity(

return SeminarEntity(
title = seminarDto.title,
titleForMain = seminarDto.titleForMain,
description = seminarDto.description,
plainTextDescription = plainTextDescription,
introduction = seminarDto.introduction,
Expand Down Expand Up @@ -108,6 +111,7 @@ class SeminarEntity(
}

title = updateSeminarRequest.title
titleForMain = updateSeminarRequest.titleForMain
introduction = updateSeminarRequest.introduction
name = updateSeminarRequest.name
speakerURL = updateSeminarRequest.speakerURL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import java.time.LocalDateTime
data class SeminarDto(
val id: Long,
val title: String,
val titleForMain: String?,
val description: String,
val introduction: String,
val name: String,
Expand Down Expand Up @@ -43,6 +44,7 @@ data class SeminarDto(
SeminarDto(
id = this.id,
title = this.title,
titleForMain = this.titleForMain,
description = this.description,
introduction = this.introduction,
name = this.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ class SeminarServiceImpl(
attachmentService.uploadAllAttachments(seminar, newAttachments)
}

if (request.isImportant && request.titleForMain.isNullOrEmpty()) {
throw CserealException.Csereal400("중요 제목이 입력되어야 합니다")
}

val attachmentResponses = attachmentService.createAttachmentResponses(seminar.attachments)

val imageURL = mainImageService.createImageURL(seminar.mainImage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,25 @@ class NewsServiceTest(
val newsDTO = NewsDto(
id = -1,
title = "title",
titleForMain = null,
description = """
<h1>Hello, World!</h1>
<p>This is news description.</p>
<h3>Goodbye, World!</h3>
""".trimIndent(),
tags = emptyList(),
createdAt = null,
modifiedAt = null,
date = null,
isPrivate = false,
isSlide = false,
isImportant = false,
prevId = null,
prevTitle = null,
nextId = null,
nextTitle = null,
imageURL = null,
attachments = null,
tags = emptyList(),
createdAt = null,
modifiedAt = null,
date = null,
isPrivate = false,
isSlide = false,
isImportant = false,
prevId = null,
prevTitle = null,
nextId = null,
nextTitle = null,
imageURL = null,
attachments = null,
)

When("DTO를 이용하여 뉴스를 생성하면") {
Expand All @@ -64,17 +65,18 @@ class NewsServiceTest(
val newsEntity = newsRepository.save(
NewsEntity(
title = "title",
titleForMain = null,
description = """
<h1>Hello, World!</h1>
<p>This is news description.</p>
<h3>Goodbye, World!</h3>
""".trimIndent(),
plainTextDescription = "Hello, World! This is news description. Goodbye, World!",
date = null,
isPrivate = false,
isSlide = false,
isImportant = false,
)
plainTextDescription = "Hello, World! This is news description. Goodbye, World!",
date = null,
isPrivate = false,
isSlide = false,
isImportant = false,
)
)

When("저장된 뉴스의 Description을 수정하면") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class NoticeServiceTest(
val noticeDto = NoticeDto(
id = -1,
title = "title",
titleForMain = null,
description = """
<h1>Hello, World!</h1>
<p>This is a test notice.</p>
Expand Down Expand Up @@ -96,6 +97,7 @@ class NoticeServiceTest(
val noticeEntity = noticeRepository.save(
NoticeEntity(
title = "title",
titleForMain = null,
description = """
<h1>Hello, World!</h1>
<p>This is a test notice.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class SeminarServiceTest(
val seminarDTO = SeminarDto(
id = -1,
title = "title",
titleForMain = null,
description = """
<h1>Hello, World!</h1>
<p>This is seminar description.</p>
Expand Down Expand Up @@ -86,6 +87,7 @@ class SeminarServiceTest(
val originalSeminar = seminarRepository.save(
SeminarEntity(
title = "title",
titleForMain = null,
description = """
<h1>Hello, World!</h1>
<p>This is seminar description.</p>
Expand Down

0 comments on commit 6dd812a

Please sign in to comment.