-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* refactor: workbook record, dto non-nullable 필드로 수정 * fix: article main card의 workbook 컬럼 default 타입 변경 (JSON_OBJECT -> JSON_ARRAY) * fix: article_main_card Insert(workbook제외), Update(workbook만) 쿼리 추가 * feat: add new funcation fromName in CategoryType * feat: member 조회시 작가일 경우 name도 가져오도록 추가 * feat: 아티클 신규 저장 시, article_main_card(workbook 제외) 저장하도록 반영 * refactor: 필드명 수정 * feat: workbook-article 연결시 article_main_card의 workbook 컬럼 업데이트 하도록 변경 * fix: remove V1.00.0.16__alter_article_main_card_table.sql * chore: 테스트용 임시 주석 처리 * refactor: 아티클 카테고리 조회 부분 리펙토링 * fix: article_main_card 테이블의 workbooks 컬럼의 디폴트 값({}) 대응 * chore: 미사용중인 주석 삭제 * feat: 기존 article_main_card 테이블에 존재하던 데이터도 지원되도록 반영 * refactor: ReadArticlesUseCase 리펙토링 * refactor: record class 명 수정(MemberIdAndNameRecord)
- Loading branch information
Showing
16 changed files
with
225 additions
and
112 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
16 changes: 16 additions & 0 deletions
16
...main/kotlin/com/few/api/repo/dao/article/command/ArticleMainCardExcludeWorkbookCommand.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,16 @@ | ||
package com.few.api.repo.dao.article.command | ||
|
||
import java.net.URL | ||
import java.time.LocalDateTime | ||
|
||
data class ArticleMainCardExcludeWorkbookCommand( | ||
val articleId: Long, | ||
val articleTitle: String, | ||
val mainImageUrl: URL, | ||
val categoryCd: Byte, | ||
val createdAt: LocalDateTime, | ||
val writerId: Long, | ||
val writerEmail: String, | ||
val writerName: String, | ||
val writerImgUrl: URL, | ||
) |
11 changes: 11 additions & 0 deletions
11
.../main/kotlin/com/few/api/repo/dao/article/command/UpdateArticleMainCardWorkbookCommand.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,11 @@ | ||
package com.few.api.repo.dao.article.command | ||
|
||
data class UpdateArticleMainCardWorkbookCommand( | ||
val articleId: Long, | ||
val workbooks: List<WorkbookCommand>, | ||
) | ||
|
||
data class WorkbookCommand( | ||
val id: Long, | ||
val title: String, | ||
) |
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
3 changes: 2 additions & 1 deletion
3
.../repo/dao/member/record/MemberIdRecord.kt → ...ao/member/record/MemberIdAndNameRecord.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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package com.few.api.repo.dao.member.record | ||
|
||
data class MemberIdRecord( | ||
data class MemberIdAndNameRecord( | ||
val memberId: Long, | ||
val writerName: String?, | ||
) |
58 changes: 58 additions & 0 deletions
58
api/src/main/kotlin/com/few/api/domain/admin/document/service/ArticleMainCardService.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,58 @@ | ||
package com.few.api.domain.admin.document.service | ||
|
||
import com.few.api.domain.admin.document.service.dto.AppendWorkbookToArticleMainCardInDto | ||
import com.few.api.domain.admin.document.service.dto.InitializeArticleMainCardInDto | ||
import com.few.api.exception.common.NotFoundException | ||
import com.few.api.repo.dao.article.ArticleMainCardDao | ||
import com.few.api.repo.dao.article.command.ArticleMainCardExcludeWorkbookCommand | ||
import com.few.api.repo.dao.article.command.UpdateArticleMainCardWorkbookCommand | ||
import com.few.api.repo.dao.article.command.WorkbookCommand | ||
import com.few.api.repo.dao.article.record.ArticleMainCardRecord | ||
import com.few.api.repo.dao.workbook.WorkbookDao | ||
import com.few.api.repo.dao.workbook.query.SelectWorkBookRecordQuery | ||
import org.springframework.stereotype.Service | ||
|
||
@Service | ||
class ArticleMainCardService( | ||
val articleMainCardDao: ArticleMainCardDao, | ||
val workbookDao: WorkbookDao, | ||
) { | ||
fun initialize(inDto: InitializeArticleMainCardInDto) { | ||
articleMainCardDao.insertArticleMainCard( | ||
ArticleMainCardExcludeWorkbookCommand( | ||
articleId = inDto.articleId, | ||
articleTitle = inDto.articleTitle, | ||
mainImageUrl = inDto.mainImageUrl, | ||
categoryCd = inDto.categoryCd, | ||
createdAt = inDto.createdAt, | ||
writerId = inDto.writerId, | ||
writerEmail = inDto.writerEmail, | ||
writerName = inDto.writerName, | ||
writerImgUrl = inDto.writerImgUrl | ||
) | ||
) | ||
} | ||
|
||
fun appendWorkbook(inDto: AppendWorkbookToArticleMainCardInDto) { | ||
val workbookRecord = workbookDao.selectWorkBook(SelectWorkBookRecordQuery(inDto.workbookId)) | ||
?: throw NotFoundException("workbook.notfound.id") | ||
|
||
val toBeAddedWorkbook = WorkbookCommand(inDto.workbookId, workbookRecord.title) | ||
|
||
val articleMainCardRecord: ArticleMainCardRecord = | ||
articleMainCardDao.selectArticleMainCardsRecord(setOf(inDto.articleId)) | ||
.ifEmpty { throw NotFoundException("articlemaincard.notfound.id") } | ||
.first() | ||
|
||
val workbookCommands = | ||
articleMainCardRecord.workbooks.map { WorkbookCommand(it.id!!, it.title!!) }.toMutableList() | ||
workbookCommands.add(toBeAddedWorkbook) | ||
|
||
articleMainCardDao.updateArticleMainCardSetWorkbook( | ||
UpdateArticleMainCardWorkbookCommand( | ||
articleId = inDto.articleId, | ||
workbooks = workbookCommands | ||
) | ||
) | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...lin/com/few/api/domain/admin/document/service/dto/AppendWorkbookToArticleMainCardInDto.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,6 @@ | ||
package com.few.api.domain.admin.document.service.dto | ||
|
||
data class AppendWorkbookToArticleMainCardInDto( | ||
val articleId: Long, | ||
val workbookId: Long, | ||
) |
16 changes: 16 additions & 0 deletions
16
...in/kotlin/com/few/api/domain/admin/document/service/dto/InitializeArticleMainCardInDto.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,16 @@ | ||
package com.few.api.domain.admin.document.service.dto | ||
|
||
import java.net.URL | ||
import java.time.LocalDateTime | ||
|
||
data class InitializeArticleMainCardInDto( | ||
val articleId: Long, | ||
val articleTitle: String, | ||
val mainImageUrl: URL, | ||
val categoryCd: Byte, | ||
val createdAt: LocalDateTime, | ||
val writerId: Long, | ||
val writerEmail: String, | ||
val writerName: String, | ||
val writerImgUrl: URL, | ||
) |
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.