diff --git a/src/main/scala/net/yoshinorin/qualtet/domains/contents/ContentService.scala b/src/main/scala/net/yoshinorin/qualtet/domains/contents/ContentService.scala index cc3dbae3..dbb49158 100644 --- a/src/main/scala/net/yoshinorin/qualtet/domains/contents/ContentService.scala +++ b/src/main/scala/net/yoshinorin/qualtet/domains/contents/ContentService.scala @@ -271,7 +271,7 @@ class ContentService[F[_]: Monad]( * @param path a content path * @return ResponseContent instance */ - def findByPathWithMeta(path: Path): IO[Option[ContentResponseModel]] = { + def findByPathWithMeta(path: Path): IO[Option[ContentDetailResponseModel]] = { this.findBy(path)(findByPathWithMetaCont) } @@ -285,7 +285,7 @@ class ContentService[F[_]: Monad]( executer.transact(findByIdCont(id)) } - def findBy[A](data: A)(f: A => ContT[F, Option[ContentWithMeta], Option[ContentWithMeta]]): IO[Option[ContentResponseModel]] = { + def findBy[A](data: A)(f: A => ContT[F, Option[ContentWithMeta], Option[ContentWithMeta]]): IO[Option[ContentDetailResponseModel]] = { executer.transact(f(data)).flatMap { case None => IO(None) case Some(x) => @@ -295,7 +295,7 @@ class ContentService[F[_]: Monad]( IO( Some( - ContentResponseModel( + ContentDetailResponseModel( id = x.id, title = x.title, robotsAttributes = x.robotsAttributes, diff --git a/src/main/scala/net/yoshinorin/qualtet/domains/contents/models/ContentResponseModel.scala b/src/main/scala/net/yoshinorin/qualtet/domains/contents/models/ContentResponseModel.scala index f0926d7a..c9fc5a90 100644 --- a/src/main/scala/net/yoshinorin/qualtet/domains/contents/models/ContentResponseModel.scala +++ b/src/main/scala/net/yoshinorin/qualtet/domains/contents/models/ContentResponseModel.scala @@ -7,7 +7,7 @@ import net.yoshinorin.qualtet.domains.externalResources.ExternalResources import net.yoshinorin.qualtet.domains.robots.Attributes import net.yoshinorin.qualtet.domains.tags.Tag -final case class ContentResponseModel( +final case class ContentDetailResponseModel( id: ContentId, title: String, robotsAttributes: Attributes, @@ -21,8 +21,8 @@ final case class ContentResponseModel( updatedAt: Long ) -object ContentResponseModel { - given codecResponseContent: JsonValueCodec[ContentResponseModel] = JsonCodecMaker.make( +object ContentDetailResponseModel { + given codecResponseContent: JsonValueCodec[ContentDetailResponseModel] = JsonCodecMaker.make( CodecMakerConfig .withRequireCollectionFields(true) .withTransientEmpty(false) @@ -31,5 +31,5 @@ object ContentResponseModel { .withTransientEmpty(false) .withTransientDefault(false) ) - given codecResponseContents: JsonValueCodec[Seq[ContentResponseModel]] = JsonCodecMaker.make + given codecResponseContents: JsonValueCodec[Seq[ContentDetailResponseModel]] = JsonCodecMaker.make } diff --git a/src/test/scala/net/yoshinorin/qualtet/domains/contents/ContentSpec.scala b/src/test/scala/net/yoshinorin/qualtet/domains/contents/ContentSpec.scala index a4dd4c8b..12995e6c 100644 --- a/src/test/scala/net/yoshinorin/qualtet/domains/contents/ContentSpec.scala +++ b/src/test/scala/net/yoshinorin/qualtet/domains/contents/ContentSpec.scala @@ -126,7 +126,7 @@ class ContentSpec extends AnyWordSpec { """.stripMargin.replaceAll("\n", "").replaceAll(" ", "") val json = - ContentResponseModel( + ContentDetailResponseModel( id = ContentId("01h08dm4th59wsk81d4h96cf6b"), title = "title", robotsAttributes = Attributes("noarchive, noimageindex"), @@ -195,7 +195,7 @@ class ContentSpec extends AnyWordSpec { val json = Seq( - ContentResponseModel( + ContentDetailResponseModel( id = ContentId("01h08dm4th59wsk81d4h96cf6b"), title = "title1", robotsAttributes = Attributes("noarchive, noimageindex"), @@ -220,7 +220,7 @@ class ContentSpec extends AnyWordSpec { publishedAt = 1567814290, updatedAt = 1567814299 ), - ContentResponseModel( + ContentDetailResponseModel( id = ContentId("01h08dm4th59wsk81d4h96cf6c"), title = "title2", robotsAttributes = Attributes("all"), diff --git a/src/test/scala/net/yoshinorin/qualtet/http/routes/v1/ContentRouteSpec.scala b/src/test/scala/net/yoshinorin/qualtet/http/routes/v1/ContentRouteSpec.scala index 9f35989c..d3258b57 100644 --- a/src/test/scala/net/yoshinorin/qualtet/http/routes/v1/ContentRouteSpec.scala +++ b/src/test/scala/net/yoshinorin/qualtet/http/routes/v1/ContentRouteSpec.scala @@ -10,7 +10,7 @@ import org.typelevel.ci.* import net.yoshinorin.qualtet.auth.RequestToken import net.yoshinorin.qualtet.domains.authors.AuthorResponseModel import net.yoshinorin.qualtet.domains.Path -import net.yoshinorin.qualtet.domains.contents.{Content, ContentId, ContentRequestModel, ContentResponseModel} +import net.yoshinorin.qualtet.domains.contents.{Content, ContentDetailResponseModel, ContentId, ContentRequestModel} import net.yoshinorin.qualtet.domains.robots.Attributes import net.yoshinorin.qualtet.http.errors.ResponseProblemDetails import net.yoshinorin.qualtet.fixture.Fixture.* @@ -455,7 +455,7 @@ class ContentRouteV1Spec extends AnyWordSpec { assert(response.status === Ok) assert(response.contentType.get === `Content-Type`(MediaType.application.json)) - val maybeContent = unsafeDecode[ContentResponseModel](response) + val maybeContent = unsafeDecode[ContentDetailResponseModel](response) assert(maybeContent.authorName === validAuthor.displayName.toString().toLowerCase()) assert(maybeContent.content === "
this is a html ContentRouteSpec2
") assert(maybeContent.description === "this is a html ContentRouteSpec2")