1
0

get endpoints for coopassets+coopshares

This commit is contained in:
Michael Hoennig
2022-10-25 10:32:57 +02:00
parent 6f3c03e6b6
commit e5ec867819
7 changed files with 316 additions and 195 deletions

View File

@@ -4,6 +4,7 @@ import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeCoopAssetsApi;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeCoopAssetsTransactionInsertResource;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeCoopAssetsTransactionResource;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeCoopSharesTransactionResource;
import net.hostsharing.hsadminng.mapper.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
@@ -78,6 +79,22 @@ public class HsOfficeCoopAssetsTransactionController implements HsOfficeCoopAsse
return ResponseEntity.created(uri).body(mapped);
}
@Override
@Transactional(readOnly = true)
public ResponseEntity<HsOfficeCoopAssetsTransactionResource> getCoopAssetTransactionByUuid(
final String currentUser, final String assumedRoles, final UUID assetTransactionUuid) {
context.define(currentUser, assumedRoles);
final var result = coopAssetsTransactionRepo.findByUuid(assetTransactionUuid);
if (result.isEmpty()) {
return ResponseEntity.notFound().build();
}
return ResponseEntity.ok(mapper.map(result.get(), HsOfficeCoopAssetsTransactionResource.class));
}
private void validate(final HsOfficeCoopAssetsTransactionInsertResource requestBody) {
final var violations = new ArrayList<String>();
validateDebitTransaction(requestBody, violations);

View File

@@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.office.coopshares;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeContactResource;
import net.hostsharing.hsadminng.mapper.Mapper;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeCoopSharesApi;
@@ -79,6 +80,21 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar
return ResponseEntity.created(uri).body(mapped);
}
@Override
@Transactional(readOnly = true)
public ResponseEntity<HsOfficeCoopSharesTransactionResource> getCoopShareTransactionByUuid(
final String currentUser, final String assumedRoles, final UUID shareTransactionUuid) {
context.define(currentUser, assumedRoles);
final var result = coopSharesTransactionRepo.findByUuid(shareTransactionUuid);
if (result.isEmpty()) {
return ResponseEntity.notFound().build();
}
return ResponseEntity.ok(mapper.map(result.get(), HsOfficeCoopSharesTransactionResource.class));
}
private void validate(final HsOfficeCoopSharesTransactionInsertResource requestBody) {
final var violations = new ArrayList<String>();
validateSubscriptionTransaction(requestBody, violations);

View File

@@ -0,0 +1,27 @@
get:
tags:
- hs-office-coopAssets
description: 'Fetch a single asset transaction by its uuid, if visible for the current subject.'
operationId: getCoopAssetTransactionByUuid
parameters:
- $ref: './auth.yaml#/components/parameters/currentUser'
- $ref: './auth.yaml#/components/parameters/assumedRoles'
- name: assetTransactionUUID
in: path
required: true
schema:
type: string
format: uuid
description: UUID of the asset transaction to fetch.
responses:
"200":
description: OK
content:
'application/json':
schema:
$ref: './hs-office-coopassets-schemas.yaml#/components/schemas/HsOfficeCoopAssetsTransaction'
"401":
$ref: './error-responses.yaml#/components/responses/Unauthorized'
"403":
$ref: './error-responses.yaml#/components/responses/Forbidden'

View File

@@ -0,0 +1,27 @@
get:
tags:
- hs-office-coopShares
description: 'Fetch a single share transaction by its uuid, if visible for the current subject.'
operationId: getCoopShareTransactionByUuid
parameters:
- $ref: './auth.yaml#/components/parameters/currentUser'
- $ref: './auth.yaml#/components/parameters/assumedRoles'
- name: shareTransactionUUID
in: path
required: true
schema:
type: string
format: uuid
description: UUID of the share transaction to fetch.
responses:
"200":
description: OK
content:
'application/json':
schema:
$ref: './hs-office-coopshares-schemas.yaml#/components/schemas/HsOfficeCoopSharesTransaction'
"401":
$ref: './error-responses.yaml#/components/responses/Unauthorized'
"403":
$ref: './error-responses.yaml#/components/responses/Forbidden'

View File

@@ -85,8 +85,13 @@ paths:
/api/hs/office/coopsharestransactions:
$ref: "./hs-office-coopshares.yaml"
/api/hs/office/coopsharestransactions/{shareTransactionUUID}:
$ref: "./hs-office-coopshares-with-uuid.yaml"
# Coop Assets Transaction
# Coop Assets Transaction
/api/hs/office/coopassetstransactions:
$ref: "./hs-office-coopassets.yaml"
/api/hs/office/coopassetstransactions/{assetTransactionUUID}:
$ref: "./hs-office-coopassets-with-uuid.yaml"