Add missing organization/person/equipment routes

This commit is contained in:
Eike Kettner
2020-08-07 01:20:26 +02:00
parent 639ab7440e
commit f3ba224124
8 changed files with 115 additions and 1 deletions

View File

@ -11,6 +11,8 @@ trait OEquipment[F[_]] {
def findAll(account: AccountId, nameQuery: Option[String]): F[Vector[REquipment]]
def find(account: AccountId, id: Ident): F[Option[REquipment]]
def add(s: REquipment): F[AddResult]
def update(s: REquipment): F[AddResult]
@ -25,6 +27,9 @@ object OEquipment {
def findAll(account: AccountId, nameQuery: Option[String]): F[Vector[REquipment]] =
store.transact(REquipment.findAll(account.collective, nameQuery, _.name))
def find(account: AccountId, id: Ident): F[Option[REquipment]] =
store.transact(REquipment.findById(id)).map(_.filter(_.cid == account.collective))
def add(e: REquipment): F[AddResult] = {
def insert = REquipment.insert(e)
def exists = REquipment.existsByName(e.cid, e.name)

View File

@ -11,6 +11,7 @@ import docspell.store.records._
trait OOrganization[F[_]] {
def findAllOrg(account: AccountId, query: Option[String]): F[Vector[OrgAndContacts]]
def findOrg(account: AccountId, orgId: Ident): F[Option[OrgAndContacts]]
def findAllOrgRefs(account: AccountId, nameQuery: Option[String]): F[Vector[IdRef]]
@ -23,6 +24,8 @@ trait OOrganization[F[_]] {
query: Option[String]
): F[Vector[PersonAndContacts]]
def findPerson(account: AccountId, persId: Ident): F[Option[PersonAndContacts]]
def findAllPersonRefs(account: AccountId, nameQuery: Option[String]): F[Vector[IdRef]]
def addPerson(s: PersonAndContacts): F[AddResult]
@ -53,6 +56,11 @@ object OOrganization {
.compile
.toVector
def findOrg(account: AccountId, orgId: Ident): F[Option[OrgAndContacts]] =
store
.transact(QOrganization.getOrgAndContact(account.collective, orgId))
.map(_.map({ case (org, cont) => OrgAndContacts(org, cont) }))
def findAllOrgRefs(
account: AccountId,
nameQuery: Option[String]
@ -75,6 +83,11 @@ object OOrganization {
.compile
.toVector
def findPerson(account: AccountId, persId: Ident): F[Option[PersonAndContacts]] =
store
.transact(QOrganization.getPersonAndContact(account.collective, persId))
.map(_.map({ case (org, cont) => PersonAndContacts(org, cont) }))
def findAllPersonRefs(
account: AccountId,
nameQuery: Option[String]