-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feat/#131] 이메일 구독 내용 채워서 구현 #156
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b00b1fe
refactor: SendArticleEmailArgs의 content 재정의
belljun3395 0fd274f
feat: BatchCategoryType, BatchMemberType 추가
belljun3395 6774d15
refactor: WorkBookSubscriberWriter 수정
belljun3395 85f885a
test: SendArticleEmailArgs의 content 재정의 반영
belljun3395 41a56d9
refactor: 유료 계정 전환으로 인한 이메일 테스트 Disabled 처리
belljun3395 7a99f0f
fix: 요일이 영어로 내려가는 문제 해결
belljun3395 0e5fc67
refactor: articleLink 변경 사항 반영
belljun3395 cc97080
test: b00b1fede169ef0da21bd53d932515a9e34585a1 반영
belljun3395 4f761da
refactor: 인터페이스를 사용하여 상속 대신하고 data 클래스로 변경
belljun3395 7d60508
refactor: article 이메일 템플릿 변경 반영
belljun3395 eb5d543
fix: 수신 거부 링크 오타 수정
belljun3395 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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, "[email protected]") | ||
.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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CategoryType과 BatchCategoryType이 가진 카테고리 값들은 왜 서로 다른가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아하!
https://github.com/YAPP-Github/24th-Web-Team-1-BE/blob/b689823876c54ecc58bf4c16d3d4dac183315fbd/data/src/main/kotlin/com/few/data/common/code/CategoryType.kt
여기서 수정되는데 아직 반영이 안되어 있어 그럽니다!