diff --git a/notification-domain/src/main/kotlin/io/github/v1servicenotification/category/Category.kt b/notification-domain/src/main/kotlin/io/github/v1servicenotification/category/Category.kt index 6b80768a..864abdb7 100644 --- a/notification-domain/src/main/kotlin/io/github/v1servicenotification/category/Category.kt +++ b/notification-domain/src/main/kotlin/io/github/v1servicenotification/category/Category.kt @@ -12,4 +12,6 @@ class Category( val destination: String, val defaultActivated: Boolean, + + val topic: Topic, ) diff --git a/notification-domain/src/main/kotlin/io/github/v1servicenotification/category/Topic.kt b/notification-domain/src/main/kotlin/io/github/v1servicenotification/category/Topic.kt new file mode 100644 index 00000000..22441cc8 --- /dev/null +++ b/notification-domain/src/main/kotlin/io/github/v1servicenotification/category/Topic.kt @@ -0,0 +1,10 @@ +package io.github.v1servicenotification.category + +enum class Topic( + name: String, +) { + SCHEDULE("일정"), + FEED("피드"), + APPLICATION("신청"), + ALL("전체"), +} diff --git a/notification-domain/src/main/kotlin/io/github/v1servicenotification/category/api/CategoryApi.kt b/notification-domain/src/main/kotlin/io/github/v1servicenotification/category/api/CategoryApi.kt index d4248f69..84dce9e5 100644 --- a/notification-domain/src/main/kotlin/io/github/v1servicenotification/category/api/CategoryApi.kt +++ b/notification-domain/src/main/kotlin/io/github/v1servicenotification/category/api/CategoryApi.kt @@ -1,10 +1,11 @@ package io.github.v1servicenotification.category.api +import io.github.v1servicenotification.category.Topic import io.github.v1servicenotification.category.api.response.CategoryListResponse import java.util.UUID interface CategoryApi { fun queryNotificationCategory(defaultActivated: Boolean): CategoryListResponse - fun createCategory(name: String, destination: String, defaultActivated: Boolean) + fun createCategory(name: String, destination: String, defaultActivated: Boolean, topic: Topic) fun removeCategory(categoryId: UUID) } diff --git a/notification-domain/src/main/kotlin/io/github/v1servicenotification/category/api/response/CategoryElement.kt b/notification-domain/src/main/kotlin/io/github/v1servicenotification/category/api/response/CategoryElement.kt index fe85c685..2eabe0c4 100644 --- a/notification-domain/src/main/kotlin/io/github/v1servicenotification/category/api/response/CategoryElement.kt +++ b/notification-domain/src/main/kotlin/io/github/v1servicenotification/category/api/response/CategoryElement.kt @@ -1,9 +1,11 @@ package io.github.v1servicenotification.category.api.response +import io.github.v1servicenotification.category.Topic import java.util.UUID class CategoryElement( val id: UUID, val name: String, val destination: String, + val topic: Topic, ) diff --git a/notification-domain/src/main/kotlin/io/github/v1servicenotification/category/service/CategoryApiImpl.kt b/notification-domain/src/main/kotlin/io/github/v1servicenotification/category/service/CategoryApiImpl.kt index 54c43e9a..b75fc022 100644 --- a/notification-domain/src/main/kotlin/io/github/v1servicenotification/category/service/CategoryApiImpl.kt +++ b/notification-domain/src/main/kotlin/io/github/v1servicenotification/category/service/CategoryApiImpl.kt @@ -2,6 +2,7 @@ package io.github.v1servicenotification.category.service import io.github.v1servicenotification.annotation.DomainService import io.github.v1servicenotification.category.Category +import io.github.v1servicenotification.category.Topic import io.github.v1servicenotification.category.api.CategoryApi import io.github.v1servicenotification.category.api.response.CategoryElement import io.github.v1servicenotification.category.api.response.CategoryListResponse @@ -19,17 +20,18 @@ class CategoryApiImpl( override fun queryNotificationCategory(defaultActivated: Boolean): CategoryListResponse { return CategoryListResponse( queryCategoryRepositorySpi.findAllByDefaultActivated(defaultActivated) - .map { CategoryElement(it.id, it.name, it.destination) } + .map { CategoryElement(it.id, it.name, it.destination, it.topic) } .toList() ) } - override fun createCategory(name: String, destination: String, defaultActivated: Boolean) { + override fun createCategory(name: String, destination: String, defaultActivated: Boolean, topic: Topic) { updateCategoryRepositorySpi.saveCategory( Category( name = name, destination = destination, defaultActivated = defaultActivated, + topic = topic ) ) } diff --git a/notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/api/dto/response/DetailElement.kt b/notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/api/dto/response/DetailElement.kt index 795bcd14..ffe3efb7 100644 --- a/notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/api/dto/response/DetailElement.kt +++ b/notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/api/dto/response/DetailElement.kt @@ -1,5 +1,6 @@ package io.github.v1servicenotification.detail.api.dto.response +import io.github.v1servicenotification.category.Topic import java.time.LocalDateTime import java.util.UUID @@ -12,4 +13,5 @@ class DetailElement( val userId: UUID, val categoryName: String, val destination: String, + val topic: Topic, ) diff --git a/notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/service/DetailApiImpl.kt b/notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/service/DetailApiImpl.kt index c73a4ffd..c9f5af33 100644 --- a/notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/service/DetailApiImpl.kt +++ b/notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/service/DetailApiImpl.kt @@ -92,6 +92,7 @@ class DetailApiImpl( userId = it.userId, categoryName = it.name, destination = it.destination, + topic = it.topic ) } .toList() diff --git a/notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/spi/QueryDetailRepositorySpi.kt b/notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/spi/QueryDetailRepositorySpi.kt index d8e79086..fdb1cdba 100644 --- a/notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/spi/QueryDetailRepositorySpi.kt +++ b/notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/spi/QueryDetailRepositorySpi.kt @@ -1,11 +1,11 @@ package io.github.v1servicenotification.detail.spi import io.github.v1servicenotification.annotation.Spi -import io.github.v1servicenotification.detail.spi.dto.DetailModel +import io.github.v1servicenotification.detail.spi.dto.TopicDetailModel import java.util.UUID @Spi interface QueryDetailRepositorySpi { - fun findAllByUserId(userId: UUID): List + fun findAllByUserId(userId: UUID): List fun findAllByUseridAndIsReadFalse(userId: UUID): Int } diff --git a/notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/spi/dto/DetailModel.kt b/notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/spi/dto/DetailModel.kt index 8daf0bd5..559c639c 100644 --- a/notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/spi/dto/DetailModel.kt +++ b/notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/spi/dto/DetailModel.kt @@ -1,5 +1,6 @@ package io.github.v1servicenotification.detail.spi.dto +import io.github.v1servicenotification.category.Topic import java.time.LocalDateTime import java.util.UUID diff --git a/notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/spi/dto/TopicDetailModel.kt b/notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/spi/dto/TopicDetailModel.kt new file mode 100644 index 00000000..ce8699a9 --- /dev/null +++ b/notification-domain/src/main/kotlin/io/github/v1servicenotification/detail/spi/dto/TopicDetailModel.kt @@ -0,0 +1,28 @@ +package io.github.v1servicenotification.detail.spi.dto + +import io.github.v1servicenotification.category.Topic +import java.time.LocalDateTime +import java.util.UUID + +class TopicDetailModel( + val id: UUID, + + val title: String, + + val content: String, + + val sentAt: LocalDateTime, + + isRead: Boolean, + + val userId: UUID, + + val name: String, + + val destination: String, + + val topic: Topic, +) { + var isRead: Boolean = isRead + private set +} diff --git a/notification-domain/src/main/kotlin/io/github/v1servicenotification/setting/service/SettingApiImpl.kt b/notification-domain/src/main/kotlin/io/github/v1servicenotification/setting/service/SettingApiImpl.kt index e8c66535..a546152a 100644 --- a/notification-domain/src/main/kotlin/io/github/v1servicenotification/setting/service/SettingApiImpl.kt +++ b/notification-domain/src/main/kotlin/io/github/v1servicenotification/setting/service/SettingApiImpl.kt @@ -50,6 +50,7 @@ class SettingApiImpl( id = it.id, name = it.name, destination = it.destination, + topic = it.topic ) } .toList() diff --git a/notification-domain/src/main/kotlin/io/github/v1servicenotification/stubs/InMemoryDetailRepository.kt b/notification-domain/src/main/kotlin/io/github/v1servicenotification/stubs/InMemoryDetailRepository.kt index 6568fad4..b8a748ce 100644 --- a/notification-domain/src/main/kotlin/io/github/v1servicenotification/stubs/InMemoryDetailRepository.kt +++ b/notification-domain/src/main/kotlin/io/github/v1servicenotification/stubs/InMemoryDetailRepository.kt @@ -6,6 +6,7 @@ import io.github.v1servicenotification.detail.Detail import io.github.v1servicenotification.detail.spi.PostDetailRepositorySpi import io.github.v1servicenotification.detail.spi.QueryDetailRepositorySpi import io.github.v1servicenotification.detail.spi.dto.DetailModel +import io.github.v1servicenotification.detail.spi.dto.TopicDetailModel import java.util.UUID class InMemoryDetailRepository( @@ -21,12 +22,12 @@ class InMemoryDetailRepository( detailMap[detail.id] = detail } - override fun findAllByUserId(userId: UUID): List { + override fun findAllByUserId(userId: UUID): List { return detailMap.filter { it.value.userId == userId } .map { val category = categoryMap[it.value.categoryId] ?: throw CategoryNotFoundException.EXCEPTION - DetailModel( + TopicDetailModel( it.value.id, it.value.title, it.value.content, @@ -35,6 +36,7 @@ class InMemoryDetailRepository( it.value.userId, category.name, category.destination, + category.topic ) } } diff --git a/notification-domain/src/test/kotlin/io/github/v1servicenotification/category/CategoryImplTest.kt b/notification-domain/src/test/kotlin/io/github/v1servicenotification/category/CategoryImplTest.kt index 2f83a295..7fe828c1 100644 --- a/notification-domain/src/test/kotlin/io/github/v1servicenotification/category/CategoryImplTest.kt +++ b/notification-domain/src/test/kotlin/io/github/v1servicenotification/category/CategoryImplTest.kt @@ -26,6 +26,7 @@ class CategoryImplTest { name = name, destination = destination, defaultActivated = defaultActivated, + topic = Topic.ALL ) updateCategorySpi.findAllByDefaultActivated(true) @@ -48,6 +49,7 @@ class CategoryImplTest { name = name, destination = destination, defaultActivated = defaultActivated, + topic = Topic.ALL ) Assertions.assertThat(updateCategorySpi.findAllByDefaultActivated(true).size).isEqualTo(0) @@ -61,6 +63,7 @@ class CategoryImplTest { "Test category", "Test destination", true, + topic = Topic.ALL ) ) assertThat(category.queryNotificationCategory(true).categories.size) @@ -75,6 +78,7 @@ class CategoryImplTest { "Test category", "Test destination", false, + topic = Topic.ALL ) ) @@ -90,6 +94,7 @@ class CategoryImplTest { "Test category", "Test destination", false, + topic = Topic.ALL ) ) assertThat(category.queryNotificationCategory(false).categories.size) @@ -104,6 +109,7 @@ class CategoryImplTest { "Test category", "Test destination", true, + topic = Topic.ALL ) ) @@ -124,6 +130,7 @@ class CategoryImplTest { name = name, destination = destination, defaultActivated = defaultActivated, + topic = Topic.ALL ) ) diff --git a/notification-domain/src/test/kotlin/io/github/v1servicenotification/detail/DetailApiImplTest.kt b/notification-domain/src/test/kotlin/io/github/v1servicenotification/detail/DetailApiImplTest.kt index 9deaeb47..d17d64af 100644 --- a/notification-domain/src/test/kotlin/io/github/v1servicenotification/detail/DetailApiImplTest.kt +++ b/notification-domain/src/test/kotlin/io/github/v1servicenotification/detail/DetailApiImplTest.kt @@ -1,6 +1,7 @@ package io.github.v1servicenotification.detail import io.github.v1servicenotification.category.Category +import io.github.v1servicenotification.category.Topic import io.github.v1servicenotification.category.exception.CategoryNotFoundException import io.github.v1servicenotification.detail.exception.NotificationDetailNotFoundException import io.github.v1servicenotification.detail.service.DetailApiImpl @@ -32,6 +33,7 @@ class DetailApiImplTest { "Test category", "Test destination", true, + topic = Topic.ALL ) val userId = UUID.randomUUID() @@ -65,6 +67,7 @@ class DetailApiImplTest { name = categoryName, destination = destination, defaultActivated = true, + topic = Topic.ALL ) categorySpi.saveCategory(category) @@ -102,6 +105,7 @@ class DetailApiImplTest { name = categoryName, destination = destination, defaultActivated = true, + topic = Topic.ALL ) categorySpi.saveCategory(category) @@ -136,6 +140,7 @@ class DetailApiImplTest { name = categoryName, destination = destination, defaultActivated = false, + topic = Topic.ALL ) categorySpi.saveCategory(category) @@ -180,6 +185,7 @@ class DetailApiImplTest { name = categoryName, destination = destination, defaultActivated = true, + topic = Topic.ALL ) categorySpi.saveCategory(category) diff --git a/notification-domain/src/test/kotlin/io/github/v1servicenotification/setting/SettingApiImplTest.kt b/notification-domain/src/test/kotlin/io/github/v1servicenotification/setting/SettingApiImplTest.kt index 28181e34..b34c8c2d 100644 --- a/notification-domain/src/test/kotlin/io/github/v1servicenotification/setting/SettingApiImplTest.kt +++ b/notification-domain/src/test/kotlin/io/github/v1servicenotification/setting/SettingApiImplTest.kt @@ -1,6 +1,7 @@ package io.github.v1servicenotification.setting import io.github.v1servicenotification.category.Category +import io.github.v1servicenotification.category.Topic import io.github.v1servicenotification.setting.service.SettingApiImpl import io.github.v1servicenotification.stubs.InMemoryCategoryRepository import io.github.v1servicenotification.stubs.InMemorySettingRepository @@ -22,7 +23,7 @@ class SettingApiImplTest { val userId = UUID.randomUUID() val categoryId = UUID.randomUUID() - val category = Category(categoryId, "Test name", "Test destination", false) + val category = Category(categoryId, "Test name", "Test destination", false, Topic.ALL) settingSpi.saveCategory(category) @@ -45,7 +46,7 @@ class SettingApiImplTest { val userId = UUID.randomUUID() val categoryId = UUID.randomUUID() categorySpi.saveCategory( - Category(categoryId, "Test name", "Test destination", false) + Category(categoryId, "Test name", "Test destination", false, Topic.ALL) ) Assertions.assertThat(settingApi.deActivateCategory(categoryId, userId)) .isEqualTo(201) @@ -58,7 +59,7 @@ class SettingApiImplTest { val userId = UUID.randomUUID() val categoryId = UUID.randomUUID() categorySpi.saveCategory( - Category(categoryId, "Test name", "Test destination", false) + Category(categoryId, "Test name", "Test destination", false, Topic.ALL) ) assertThat(settingApi.activateCategory(categoryId, userId)) .isEqualTo(201) diff --git a/notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/category/domain/CategoryEntity.kt b/notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/category/domain/CategoryEntity.kt index 63df33d6..74845044 100644 --- a/notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/category/domain/CategoryEntity.kt +++ b/notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/category/domain/CategoryEntity.kt @@ -1,11 +1,14 @@ package io.github.v1servicenotification.domain.category.domain +import io.github.v1servicenotification.category.Topic import io.github.v1servicenotification.domain.setting.domain.SettingEntity import io.github.v1servicenotification.global.entity.BaseUUIDEntity import java.util.UUID import javax.persistence.Table import javax.persistence.Column import javax.persistence.Entity +import javax.persistence.EnumType +import javax.persistence.Enumerated import javax.persistence.FetchType import javax.persistence.OneToMany import javax.validation.constraints.NotNull @@ -30,4 +33,7 @@ class CategoryEntity( @OneToMany(mappedBy = "settingId.categoryEntity", fetch = FetchType.LAZY) val settingList: List = emptyList(), + @field:NotNull + @Enumerated(EnumType.STRING) + val topic: Topic ) : BaseUUIDEntity(id) diff --git a/notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/category/mapper/CategoryMapperImpl.kt b/notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/category/mapper/CategoryMapperImpl.kt index 8fbb3de6..22fb135a 100644 --- a/notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/category/mapper/CategoryMapperImpl.kt +++ b/notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/category/mapper/CategoryMapperImpl.kt @@ -13,6 +13,7 @@ class CategoryMapperImpl: CategoryMapper { name = category.name, destination = category.destination, defaultActivated = category.defaultActivated, + topic = category.topic, ) } @@ -22,6 +23,7 @@ class CategoryMapperImpl: CategoryMapper { name = categoryEntity.name, destination = categoryEntity.destination, defaultActivated = categoryEntity.defaultActivated, + topic = categoryEntity.topic, ) } } \ No newline at end of file diff --git a/notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/category/presentation/CategoryController.kt b/notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/category/presentation/CategoryController.kt index e5289b48..ba767070 100644 --- a/notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/category/presentation/CategoryController.kt +++ b/notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/category/presentation/CategoryController.kt @@ -38,6 +38,7 @@ class CategoryController( name = request.name, destination = request.destination, defaultActivated = request.defaultActivated, + topic = request.topic ) } diff --git a/notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/category/presentation/dto/request/CreateCategoryRequest.kt b/notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/category/presentation/dto/request/CreateCategoryRequest.kt index 0b98495a..9f6c981f 100644 --- a/notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/category/presentation/dto/request/CreateCategoryRequest.kt +++ b/notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/category/presentation/dto/request/CreateCategoryRequest.kt @@ -1,5 +1,6 @@ package io.github.v1servicenotification.domain.category.presentation.dto.request +import io.github.v1servicenotification.category.Topic import javax.validation.constraints.NotNull import kotlin.properties.Delegates @@ -15,4 +16,7 @@ class CreateCategoryRequest { var defaultActivated by Delegates.notNull() private set + + lateinit var topic: Topic + private set } diff --git a/notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/detail/domain/repository/CustomDetailRepositoryImpl.kt b/notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/detail/domain/repository/CustomDetailRepositoryImpl.kt index cd5788c4..ebc2983f 100644 --- a/notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/detail/domain/repository/CustomDetailRepositoryImpl.kt +++ b/notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/detail/domain/repository/CustomDetailRepositoryImpl.kt @@ -4,7 +4,7 @@ import com.querydsl.jpa.impl.JPAQueryFactory import io.github.v1servicenotification.detail.Detail import io.github.v1servicenotification.detail.spi.PostDetailRepositorySpi import io.github.v1servicenotification.detail.spi.QueryDetailRepositorySpi -import io.github.v1servicenotification.detail.spi.dto.DetailModel +import io.github.v1servicenotification.detail.spi.dto.TopicDetailModel import io.github.v1servicenotification.domain.category.domain.QCategoryEntity.categoryEntity import io.github.v1servicenotification.domain.detail.domain.QDetailEntity.detailEntity import io.github.v1servicenotification.domain.detail.domain.repository.vo.QDetailVO @@ -18,7 +18,7 @@ class CustomDetailRepositoryImpl( private val detailMapper: DetailMapper, private val query: JPAQueryFactory, ) : QueryDetailRepositorySpi, PostDetailRepositorySpi { - override fun findAllByUserId(userId: UUID): List { + override fun findAllByUserId(userId: UUID): List { return query .select( QDetailVO( @@ -30,6 +30,7 @@ class CustomDetailRepositoryImpl( detailEntity.userId, categoryEntity.name, categoryEntity.destination, + categoryEntity.topic ) ) .from(detailEntity) @@ -37,7 +38,7 @@ class CustomDetailRepositoryImpl( .join(detailEntity.categoryEntity, categoryEntity) .fetch() .map { - DetailModel( + TopicDetailModel( id = it.id, title = it.title, content = it.content, @@ -46,6 +47,7 @@ class CustomDetailRepositoryImpl( userId = it.userId, name = it.name, destination = it.destination, + topic = it.topic, ) } .toList() diff --git a/notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/detail/domain/repository/vo/DetailVO.kt b/notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/detail/domain/repository/vo/DetailVO.kt index 038a452c..6c44b170 100644 --- a/notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/detail/domain/repository/vo/DetailVO.kt +++ b/notification-infrastructure/src/main/kotlin/io/github/v1servicenotification/domain/detail/domain/repository/vo/DetailVO.kt @@ -1,6 +1,7 @@ package io.github.v1servicenotification.domain.detail.domain.repository.vo import com.querydsl.core.annotations.QueryProjection +import io.github.v1servicenotification.category.Topic import java.time.LocalDateTime import java.util.UUID @@ -21,6 +22,7 @@ class DetailVO @QueryProjection constructor( val destination: String, + val topic: Topic, ) { var isRead: Boolean = isRead private set