-
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.
* refactor: SendArticleEmailArgs의 content 재정의 * feat: BatchCategoryType, BatchMemberType 추가 * refactor: WorkBookSubscriberWriter 수정 * test: SendArticleEmailArgs의 content 재정의 반영 * refactor: 유료 계정 전환으로 인한 이메일 테스트 Disabled 처리 * fix: 요일이 영어로 내려가는 문제 해결 * refactor: articleLink 변경 사항 반영 * test: b00b1fe 반영 * refactor: 인터페이스를 사용하여 상속 대신하고 data 클래스로 변경 * refactor: article 이메일 템플릿 변경 반영 * fix: 수신 거부 링크 오타 수정
- Loading branch information
1 parent
768bfff
commit 17ee380
Showing
12 changed files
with
424 additions
and
190 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
batch/src/main/kotlin/com/few/batch/data/common/code/BatchCategoryType.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,27 @@ | ||
package com.few.batch.data.common.code | ||
|
||
/** | ||
* BatchCategoryType is origin from CategoryType in few-data module. | ||
* @see com.few.data.common.code.CategoryType | ||
*/ | ||
enum class BatchCategoryType(val code: Byte, val displayName: String) { | ||
ECONOMY(0, "경제"), | ||
IT(10, "IT"), | ||
MARKETING(20, "마케팅"), | ||
CULTURE(30, "교양"), | ||
SCIENCE(40, "과학"); | ||
|
||
companion object { | ||
fun fromCode(code: Byte): BatchCategoryType? { | ||
return entries.find { it.code == code } | ||
} | ||
|
||
fun convertToCode(displayName: String): Byte { | ||
return entries.find { it.name == displayName }?.code ?: throw IllegalArgumentException("Invalid category name") | ||
} | ||
|
||
fun convertToDisplayName(code: Byte): String { | ||
return entries.find { it.code == code }?.displayName ?: throw IllegalArgumentException("Invalid category code") | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
batch/src/main/kotlin/com/few/batch/data/common/code/BatchMemberType.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,17 @@ | ||
package com.few.batch.data.common.code | ||
|
||
/** | ||
* BatchMemberType is origin from MemberType in few-data module. | ||
* @see com.few.data.common.code.MemberType | ||
*/ | ||
enum class BatchMemberType(val code: Byte, val displayName: String) { | ||
NORMAL(60, "일반멤버"), | ||
ADMIN(0, "어드민멤버"), | ||
WRITER(120, "작가멤버"); | ||
|
||
companion object { | ||
fun fromCode(code: Byte): BatchMemberType? { | ||
return values().find { it.code == code } | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
package com.few.batch.service.article.writer | ||
|
||
import com.few.batch.data.common.code.BatchCategoryType | ||
import com.few.batch.data.common.code.BatchMemberType | ||
import com.few.batch.service.article.dto.WorkBookSubscriberItem | ||
import jooq.jooq_dsl.tables.ArticleIfo | ||
import jooq.jooq_dsl.tables.MappingWorkbookArticle | ||
import jooq.jooq_dsl.tables.Member | ||
import jooq.jooq_dsl.tables.Subscription | ||
import com.few.email.service.article.dto.Content | ||
import jooq.jooq_dsl.tables.* | ||
import org.jooq.DSLContext | ||
import org.jooq.JSON | ||
import org.springframework.boot.test.context.TestComponent | ||
import java.net.URL | ||
import java.time.LocalDate | ||
import kotlin.random.Random | ||
|
||
fun List<TestWorkBookSubscriberDto>.toServiceDto(): List<WorkBookSubscriberItem> { | ||
|
@@ -23,7 +26,14 @@ data class TestWorkBookSubscriberDto( | |
val memberId: Long, | ||
val targetWorkBookId: Long, | ||
val progress: Long, | ||
val content: String | ||
val content: Content | ||
) | ||
|
||
data class ArticleDto( | ||
val articleId: Long, | ||
val dayCol: Int, | ||
val content: String, | ||
val title: String | ||
) | ||
|
||
@TestComponent | ||
|
@@ -36,11 +46,20 @@ class WorkBookSubscriberWriterTestSetHelper( | |
dslContext.insertInto(Member.MEMBER) | ||
.set(Member.MEMBER.ID, i.toLong()) | ||
.set(Member.MEMBER.EMAIL, "member$i@gmail.com") | ||
.set(Member.MEMBER.TYPE_CD, 0) // todo fix | ||
.set(Member.MEMBER.TYPE_CD, BatchMemberType.NORMAL.code) | ||
.execute() | ||
} | ||
} | ||
|
||
fun setUpWriter(id: Long) { | ||
dslContext.insertInto(Member.MEMBER) | ||
.set(Member.MEMBER.ID, id) | ||
.set(Member.MEMBER.EMAIL, "[email protected]") | ||
.set(Member.MEMBER.TYPE_CD, BatchMemberType.WRITER.code) | ||
.set(Member.MEMBER.DESCRIPTION, JSON.valueOf("{\"url\": \"http://localhost:8080\", \"name\": \"writer\"}")) | ||
.execute() | ||
} | ||
|
||
fun setUpSubscriptions(start: Int = 1, count: Int, workbookId: Long = 1) { | ||
for (i in start..count) { | ||
dslContext.insertInto(Subscription.SUBSCRIPTION) | ||
|
@@ -51,7 +70,7 @@ class WorkBookSubscriberWriterTestSetHelper( | |
} | ||
} | ||
|
||
fun setUpMappingWorkbookArticle(start: Int = 1, count: Int, workbookId: Long = 1, dayCorrection: Int = 0) { | ||
fun setUpMappingWorkbookArticle(start: Int = 1, count: Int, workbookId: Long = 1, dayCorrection: Int = 1) { | ||
for (i in start..count) { | ||
dslContext.insertInto(MappingWorkbookArticle.MAPPING_WORKBOOK_ARTICLE) | ||
.set(MappingWorkbookArticle.MAPPING_WORKBOOK_ARTICLE.WORKBOOK_ID, workbookId) | ||
|
@@ -61,6 +80,18 @@ class WorkBookSubscriberWriterTestSetHelper( | |
} | ||
} | ||
|
||
fun setUpArticleMst(start: Int = 1, count: Int, writerId: Long) { | ||
for (i in start..count) { | ||
dslContext.insertInto(ArticleMst.ARTICLE_MST) | ||
.set(ArticleMst.ARTICLE_MST.ID, i.toLong()) | ||
.set(ArticleMst.ARTICLE_MST.TITLE, "title$i") | ||
.set(ArticleMst.ARTICLE_MST.MEMBER_ID, writerId) | ||
.set(ArticleMst.ARTICLE_MST.CATEGORY_CD, BatchCategoryType.fromCode(0)!!.code) | ||
.set(ArticleMst.ARTICLE_MST.MAIN_IMAGE_URL, "http://localhost:8080") | ||
.execute() | ||
} | ||
} | ||
|
||
fun setUpArticleIfo(start: Int = 1, count: Int) { | ||
for (i in start..count) { | ||
dslContext.insertInto(ArticleIfo.ARTICLE_IFO) | ||
|
@@ -92,11 +123,36 @@ class WorkBookSubscriberWriterTestSetHelper( | |
.and(MappingWorkbookArticle.MAPPING_WORKBOOK_ARTICLE.DELETED_AT.isNull) | ||
.fetchOneInto(String::class.java) | ||
|
||
val articleDto = dslContext.select( | ||
MappingWorkbookArticle.MAPPING_WORKBOOK_ARTICLE.ARTICLE_ID, | ||
MappingWorkbookArticle.MAPPING_WORKBOOK_ARTICLE.DAY_COL, | ||
ArticleIfo.ARTICLE_IFO.CONTENT, | ||
ArticleMst.ARTICLE_MST.TITLE | ||
).from(MappingWorkbookArticle.MAPPING_WORKBOOK_ARTICLE) | ||
.join(ArticleIfo.ARTICLE_IFO) | ||
.on(MappingWorkbookArticle.MAPPING_WORKBOOK_ARTICLE.ARTICLE_ID.eq(ArticleIfo.ARTICLE_IFO.ARTICLE_MST_ID)) | ||
.join(ArticleMst.ARTICLE_MST) | ||
.on(ArticleIfo.ARTICLE_IFO.ARTICLE_MST_ID.eq(ArticleMst.ARTICLE_MST.ID)) | ||
.where(MappingWorkbookArticle.MAPPING_WORKBOOK_ARTICLE.WORKBOOK_ID.eq(workbookId)) | ||
.and(MappingWorkbookArticle.MAPPING_WORKBOOK_ARTICLE.DAY_COL.eq(it[Subscription.SUBSCRIPTION.PROGRESS].toInt() + 1)) | ||
.fetchOneInto(ArticleDto::class.java) | ||
|
||
val dto = TestWorkBookSubscriberDto( | ||
memberId = it[Subscription.SUBSCRIPTION.MEMBER_ID], | ||
targetWorkBookId = workbookId, | ||
progress = it[Subscription.SUBSCRIPTION.PROGRESS], | ||
content = content!! | ||
content = Content( | ||
articleLink = URL("https://www.fewletter.com/article/${articleDto!!.articleId}"), | ||
currentDate = LocalDate.now(), | ||
category = BatchCategoryType.fromCode(0)!!.displayName, | ||
articleDay = articleDto.dayCol, | ||
articleTitle = articleDto.title, | ||
writerName = "writer", | ||
writerLink = URL("http://localhost:8080"), | ||
articleContent = articleDto.content, | ||
problemLink = URL("https://www.fewletter.com/problem?articleId=${articleDto.articleId}"), | ||
unsubscribeLink = URL("https://www.fewletter.com/unsbuscribe?user=member${it[Subscription.SUBSCRIPTION.MEMBER_ID]}@gmail.com&workbookId=$workbookId&articleId=${articleDto.articleId}") | ||
) | ||
) | ||
items.add(dto) | ||
} | ||
|
3 changes: 3 additions & 0 deletions
3
data/src/main/kotlin/com/few/data/common/code/CategoryType.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
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.