Poking around.
This commit is contained in:
parent
456e625e82
commit
1195bab53c
1 changed files with 36 additions and 0 deletions
|
@ -2,9 +2,17 @@ package gs.smolban.db.doobie
|
|||
|
||||
import cats.data.EitherT
|
||||
import cats.effect.Async
|
||||
import doobie.*
|
||||
import doobie.implicits.*
|
||||
import gs.smolban.db.DbError
|
||||
import gs.smolban.db.TicketDb
|
||||
import gs.smolban.model.CreatedAt
|
||||
import gs.smolban.model.CreatedBy
|
||||
import gs.smolban.model.Group
|
||||
import gs.smolban.model.Ticket
|
||||
import gs.smolban.model.users.User
|
||||
import gs.uuid.v0.UUIDFormat
|
||||
import java.util.UUID
|
||||
|
||||
final class DoobieTicketDb[F[_]: Async] extends TicketDb[F]:
|
||||
/** @inheritdoc
|
||||
|
@ -25,3 +33,31 @@ final class DoobieTicketDb[F[_]: Async] extends TicketDb[F]:
|
|||
/** @inheritdoc
|
||||
*/
|
||||
override def deleteTicket(ref: Ticket.Reference): F[Boolean] = ???
|
||||
|
||||
object DoobieTicketDb:
|
||||
|
||||
object Sql:
|
||||
|
||||
implicit val ticketIdGet: Get[Ticket.Id] = Get[Long].tmap(Ticket.Id(_))
|
||||
implicit val ticketIdPut: Put[Ticket.Id] = Put[Long].tcontramap(_.toLong())
|
||||
|
||||
implicit val groupIdGet: Get[Group.Id] = Get[Array[Byte]].tmap { bytes =>
|
||||
Group.Id(gs.uuid.v0.UUID(gs.uuid.v0.UUIDFormat.fromBytes(bytes)))
|
||||
}
|
||||
|
||||
implicit val groupIdPut: Put[Group.Id] = Put[Array[Byte]].tcontramap { id =>
|
||||
gs.uuid.v0.UUIDFormat.toBytes(id.toUUID().toUUID)
|
||||
}
|
||||
|
||||
/* private case class TicketContents( createdAt: CreatedAt, createdBy:
|
||||
* CreatedBy, title: String, description: String, status: Ticket.Status,
|
||||
* assignee: Option[User.Id] )
|
||||
*
|
||||
* def readTicket(ticketId: Ticket.Id, groupId: Group.Id) = sql""" SELECT
|
||||
* created_at, created_by, title, description, status, assignee FROM tickets
|
||||
* WHERE ticket_id = $ticketId AND group_id = $groupId
|
||||
* """.query[TicketContents] */
|
||||
|
||||
end Sql
|
||||
|
||||
end DoobieTicketDb
|
||||
|
|
Loading…
Add table
Reference in a new issue