1
0

add hs-office-membership API and controller

This commit is contained in:
Michael Hoennig
2022-10-18 13:57:35 +02:00
parent 27f29ef665
commit c862df7846
9 changed files with 886 additions and 37 deletions

View File

@ -28,3 +28,5 @@ map:
null: org.openapitools.jackson.nullable.JsonNullable
/api/hs/office/sepamandates/{debitorUUID}:
null: org.openapitools.jackson.nullable.JsonNullable
/api/hs/office/memberships/{membershipUUID}:
null: org.openapitools.jackson.nullable.JsonNullable

View File

@ -0,0 +1,75 @@
components:
schemas:
HsOfficeReasonForTermination:
type: string
enum:
- NONE
- CANCELLATION
- TRANSFER
- DEATH
- LIQUIDATION
- EXPULSION
HsOfficeMembership:
type: object
properties:
uuid:
type: string
format: uuid
partner:
$ref: './hs-office-partner-schemas.yaml#/components/schemas/HsOfficePartner'
mainDebitor:
$ref: './hs-office-debitor-schemas.yaml#/components/schemas/HsOfficeDebitor'
memberNumber:
type: integer
validFrom:
type: string
format: date
validTo:
type: string
format: date
reasonForTermination:
$ref: '#/components/schemas/HsOfficeReasonForTermination'
HsOfficeMembershipPatch:
type: object
properties:
validTo:
type: string
format: date
reasonForTermination:
$ref: '#/components/schemas/HsOfficeReasonForTermination'
additionalProperties: false
HsOfficeMembershipInsert:
type: object
properties:
partnerUuid:
type: string
format: uuid
nullable: false
mainDebitorUuid:
type: string
format: uuid
nullable: false
memberNumber:
type: integer
nullable: false
validFrom:
type: string
format: date
nullable: false
validTo:
type: string
format: date
nullable: true
reasonForTermination:
$ref: '#/components/schemas/HsOfficeReasonForTermination'
required:
- partnerUuid
- debitorUuid
- validFrom
additionalProperties: false

View File

@ -0,0 +1,83 @@
get:
tags:
- hs-office-memberships
description: 'Fetch a single membership by its uuid, if visible for the current subject.'
operationId: getMembershipByUuid
parameters:
- $ref: './auth.yaml#/components/parameters/currentUser'
- $ref: './auth.yaml#/components/parameters/assumedRoles'
- name: membershipUUID
in: path
required: true
schema:
type: string
format: uuid
description: UUID of the membership to fetch.
responses:
"200":
description: OK
content:
'application/json':
schema:
$ref: './hs-office-membership-schemas.yaml#/components/schemas/HsOfficeMembership'
"401":
$ref: './error-responses.yaml#/components/responses/Unauthorized'
"403":
$ref: './error-responses.yaml#/components/responses/Forbidden'
patch:
tags:
- hs-office-memberships
description: 'Updates a single membership by its uuid, if permitted for the current subject.'
operationId: patchMembership
parameters:
- $ref: './auth.yaml#/components/parameters/currentUser'
- $ref: './auth.yaml#/components/parameters/assumedRoles'
- name: membershipUUID
in: path
required: true
schema:
type: string
format: uuid
requestBody:
content:
'application/json':
schema:
$ref: './hs-office-membership-schemas.yaml#/components/schemas/HsOfficeMembershipPatch'
responses:
"200":
description: OK
content:
'application/json':
schema:
$ref: './hs-office-membership-schemas.yaml#/components/schemas/HsOfficeMembership'
"401":
$ref: './error-responses.yaml#/components/responses/Unauthorized'
"403":
$ref: './error-responses.yaml#/components/responses/Forbidden'
delete:
tags:
- hs-office-memberships
description: 'Delete a single membership by its uuid, if permitted for the current subject.'
operationId: deleteMembershipByUuid
parameters:
- $ref: './auth.yaml#/components/parameters/currentUser'
- $ref: './auth.yaml#/components/parameters/assumedRoles'
- name: membershipUUID
in: path
required: true
schema:
type: string
format: uuid
description: UUID of the membership to delete.
responses:
"204":
description: No Content
"401":
$ref: './error-responses.yaml#/components/responses/Unauthorized'
"403":
$ref: './error-responses.yaml#/components/responses/Forbidden'
"404":
$ref: './error-responses.yaml#/components/responses/NotFound'

View File

@ -0,0 +1,64 @@
get:
summary: Returns a list of (optionally filtered) memberships.
description: Returns the list of (optionally filtered) memberships which are visible to the current user or any of it's assumed roles.
tags:
- hs-office-memberships
operationId: listMemberships
parameters:
- $ref: './auth.yaml#/components/parameters/currentUser'
- $ref: './auth.yaml#/components/parameters/assumedRoles'
- name: partnerUuid
in: query
required: false
schema:
type: string
format: uuid
description: UUID of the business partner.
- name: memberNumber
in: query
required: false
schema:
type: integer
description: Member number.
responses:
"200":
description: OK
content:
'application/json':
schema:
type: array
items:
$ref: './hs-office-membership-schemas.yaml#/components/schemas/HsOfficeMembership'
"401":
$ref: './error-responses.yaml#/components/responses/Unauthorized'
"403":
$ref: './error-responses.yaml#/components/responses/Forbidden'
post:
summary: Adds a new membership.
tags:
- hs-office-memberships
operationId: addMembership
parameters:
- $ref: './auth.yaml#/components/parameters/currentUser'
- $ref: './auth.yaml#/components/parameters/assumedRoles'
requestBody:
description: A JSON object describing the new membership.
required: true
content:
application/json:
schema:
$ref: '/hs-office-membership-schemas.yaml#/components/schemas/HsOfficeMembershipInsert'
responses:
"201":
description: Created
content:
'application/json':
schema:
$ref: './hs-office-membership-schemas.yaml#/components/schemas/HsOfficeMembership'
"401":
$ref: './error-responses.yaml#/components/responses/Unauthorized'
"403":
$ref: './error-responses.yaml#/components/responses/Forbidden'
"409":
$ref: './error-responses.yaml#/components/responses/Conflict'

View File

@ -69,3 +69,12 @@ paths:
/api/hs/office/sepamandates/{sepaMandateUUID}:
$ref: "./hs-office-sepamandates-with-uuid.yaml"
# Membership
/api/hs/office/memberships:
$ref: "./hs-office-memberships.yaml"
/api/hs/office/memberships/{membershipUUID}:
$ref: "./hs-office-memberships-with-uuid.yaml"

View File

@ -13,7 +13,7 @@ create table if not exists hs_office_membership
uuid uuid unique references RbacObject (uuid) initially deferred,
partnerUuid uuid not null references hs_office_partner(uuid),
mainDebitorUuid uuid not null references hs_office_debitor(uuid),
memberNumber numeric(5) not null,
memberNumber numeric(5) not null unique,
validity daterange not null,
reasonForTermination HsOfficeReasonForTermination not null default 'NONE'
);