瀏覽代碼

fixes api

master
Daniel 1 年之前
父節點
當前提交
a2e3bfca02
共有 27 個文件被更改,包括 244 次插入336 次删除
  1. +1
    -1
      angular/openapi.json
  2. +11
    -18
      angular/openapi.yaml
  3. +1
    -3
      angular/src/app/_forms/apiForms.ts
  4. +10
    -7
      angular/src/app/_services/account.service.ts
  5. +1
    -0
      angular/src/app/core/api/v1/.openapi-generator/FILES
  6. +5
    -5
      angular/src/app/core/api/v1/api/location.service.ts
  7. +0
    -178
      angular/src/app/core/api/v1/api/loginCheck.service.ts
  8. +4
    -4
      angular/src/app/core/api/v1/api/mediaObject.service.ts
  9. +5
    -5
      angular/src/app/core/api/v1/api/shippingCompany.service.ts
  10. +4
    -4
      angular/src/app/core/api/v1/api/trip.service.ts
  11. +4
    -4
      angular/src/app/core/api/v1/api/tripLocation.service.ts
  12. +5
    -5
      angular/src/app/core/api/v1/api/user.service.ts
  13. +4
    -4
      angular/src/app/core/api/v1/api/userTrip.service.ts
  14. +4
    -4
      angular/src/app/core/api/v1/api/userTripLocation.service.ts
  15. +4
    -4
      angular/src/app/core/api/v1/api/userTripWorkLog.service.ts
  16. +5
    -5
      angular/src/app/core/api/v1/api/vessel.service.ts
  17. +5
    -5
      angular/src/app/core/api/v1/api/zone.service.ts
  18. +3
    -5
      angular/src/app/core/api/v1/configuration.ts
  19. +0
    -17
      angular/src/app/core/api/v1/model/loginCheckPost200Response.ts
  20. +0
    -18
      angular/src/app/core/api/v1/model/loginCheckPostRequest.ts
  21. +3
    -6
      angular/src/app/core/api/v1/model/mediaObjectJsonld.ts
  22. +0
    -24
      angular/src/app/core/api/v1/model/mediaObjectJsonldMediaObjectRead.ts
  23. +0
    -1
      httpdocs/config/packages/api_platform.yaml
  24. +68
    -0
      httpdocs/src/ApiResource/MediaObjectApi.php
  25. +21
    -9
      httpdocs/src/Controller/CreateMediaObjectAction.php
  26. +44
    -0
      httpdocs/src/Mapper/MediaObjectEntityToApiMapper.php
  27. +32
    -0
      httpdocs/src/OpenApi/BearerTokenDecorator.php

+ 1
- 1
angular/openapi.json
文件差異過大導致無法顯示
查看文件


+ 11
- 18
angular/openapi.yaml 查看文件

@@ -2052,8 +2052,6 @@ components:
type: object
description: ''
deprecated: false
externalDocs:
url: 'https://schema.org/MediaObject'
properties:
'@context':
readOnly: true
@@ -2078,32 +2076,28 @@ components:
'@type':
readOnly: true
type: string
id:
dbId:
readOnly: true
type: integer
type:
- integer
- 'null'
contentUrl:
externalDocs:
url: 'https://schema.org/contentUrl'
type:
- string
- 'null'
file:
type:
- string
- 'null'
format: binary
filePath:
readOnly: true
type:
- string
- 'null'
createdBy:
$ref: '#/components/schemas/User.jsonld'
createdAt:
readOnly: true
type: string
type:
- string
- 'null'
format: date-time
required:
- file
ShippingCompany:
type: object
description: ''
@@ -2941,10 +2935,9 @@ components:
headers: { }
securitySchemes:
JWT:
type: apiKey
description: 'Value for the Authorization header parameter.'
name: Authorization
in: header
type: http
scheme: bearer
bearerFormat: JWT
security:
-
JWT: []


+ 1
- 3
angular/src/app/_forms/apiForms.ts 查看文件

@@ -17,11 +17,9 @@ export const locationJsonldForm = new FormGroup({
});

export const mediaObjectJsonldForm = new FormGroup({
id: new FormControl(null, []),
dbId: new FormControl(null, []),
contentUrl: new FormControl(null, []),
file: new FormControl(null, [Validators.required]),
filePath: new FormControl(null, []),
createdBy: new FormControl(null, []),
createdAt: new FormControl(null, [])
});



+ 10
- 7
angular/src/app/_services/account.service.ts 查看文件

@@ -6,7 +6,8 @@ import { map } from 'rxjs/operators';

import { environment } from '@environments/environment';
import { User } from '@app/_models';
import {LoginCheckService} from "@app/core/api/v1";
import {AuthService} from "@app/core/api/v1";


@Injectable({ providedIn: 'root' })
export class AccountService {
@@ -17,7 +18,7 @@ export class AccountService {
constructor(
private router: Router,
private http: HttpClient,
private loginCheckService: LoginCheckService
private loginCheckService: AuthService
) {
this.userSubject = new BehaviorSubject(JSON.parse(localStorage.getItem('user')!));
this.user = this.userSubject.asObservable();
@@ -28,13 +29,15 @@ export class AccountService {
}

login(email: string, password: string) {
return this.loginCheckService.checkPost(
return this.loginCheckService.postCredentialsItem(
{ email, password }
).pipe(map(user => {
).pipe(map(authResponse => {
// store user details and jwt token in local storage to keep user logged in between page refreshes
localStorage.setItem('user', JSON.stringify(user));
this.userSubject.next(user);
return user;
localStorage.setItem('user', JSON.stringify(authResponse.user));
if (authResponse.user) {
this.userSubject.next(authResponse.user);
}
return authResponse.user;
}));
//
// return this.http.post<User>(`${environment.apiUrl}/auth`, { email, password })


+ 1
- 0
angular/src/app/core/api/v1/.openapi-generator/FILES 查看文件

@@ -1,4 +1,5 @@
.gitignore
.openapi-generator-ignore
README.md
api.module.ts
api/api.ts


+ 5
- 5
angular/src/app/core/api/v1/api/location.service.ts 查看文件

@@ -139,7 +139,7 @@ export class LocationService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -212,7 +212,7 @@ export class LocationService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -283,7 +283,7 @@ export class LocationService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -359,7 +359,7 @@ export class LocationService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -441,7 +441,7 @@ export class LocationService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;


+ 0
- 178
angular/src/app/core/api/v1/api/loginCheck.service.ts 查看文件

@@ -1,178 +0,0 @@
/**
* Imaq Platform
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/* tslint:disable:no-unused-variable member-ordering */

import { Inject, Injectable, Optional } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams,
HttpResponse, HttpEvent, HttpParameterCodec, HttpContext
} from '@angular/common/http';
import { CustomHttpParameterCodec } from '../encoder';
import { Observable } from 'rxjs';

// @ts-ignore
import { LoginCheckPost200Response } from '../model/loginCheckPost200Response';
// @ts-ignore
import { LoginCheckPostRequest } from '../model/loginCheckPostRequest';

// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
import { Configuration } from '../configuration';



@Injectable({
providedIn: 'root'
})
export class LoginCheckService {

protected basePath = 'http://localhost';
public defaultHeaders = new HttpHeaders();
public configuration = new Configuration();
public encoder: HttpParameterCodec;

constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string|string[], @Optional() configuration: Configuration) {
if (configuration) {
this.configuration = configuration;
}
if (typeof this.configuration.basePath !== 'string') {
if (Array.isArray(basePath) && basePath.length > 0) {
basePath = basePath[0];
}

if (typeof basePath !== 'string') {
basePath = this.basePath;
}
this.configuration.basePath = basePath;
}
this.encoder = this.configuration.encoder || new CustomHttpParameterCodec();
}


// @ts-ignore
private addToHttpParams(httpParams: HttpParams, value: any, key?: string): HttpParams {
if (typeof value === "object" && value instanceof Date === false) {
httpParams = this.addToHttpParamsRecursive(httpParams, value);
} else {
httpParams = this.addToHttpParamsRecursive(httpParams, value, key);
}
return httpParams;
}

private addToHttpParamsRecursive(httpParams: HttpParams, value?: any, key?: string): HttpParams {
if (value == null) {
return httpParams;
}

if (typeof value === "object") {
if (Array.isArray(value)) {
(value as any[]).forEach( elem => httpParams = this.addToHttpParamsRecursive(httpParams, elem, key));
} else if (value instanceof Date) {
if (key != null) {
httpParams = httpParams.append(key, (value as Date).toISOString().substring(0, 10));
} else {
throw Error("key may not be null if value is Date");
}
} else {
Object.keys(value).forEach( k => httpParams = this.addToHttpParamsRecursive(
httpParams, value[k], key != null ? `${key}.${k}` : k));
}
} else if (key != null) {
httpParams = httpParams.append(key, value);
} else {
throw Error("key may not be null if value is not object or array");
}
return httpParams;
}

/**
* Creates a user token.
* Creates a user token.
* @param loginCheckPostRequest The login data
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public checkPost(loginCheckPostRequest: LoginCheckPostRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<LoginCheckPost200Response>;
public checkPost(loginCheckPostRequest: LoginCheckPostRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<LoginCheckPost200Response>>;
public checkPost(loginCheckPostRequest: LoginCheckPostRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<LoginCheckPost200Response>>;
public checkPost(loginCheckPostRequest: LoginCheckPostRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
if (loginCheckPostRequest === null || loginCheckPostRequest === undefined) {
throw new Error('Required parameter loginCheckPostRequest was null or undefined when calling checkPost.');
}

let localVarHeaders = this.defaultHeaders;

let localVarCredential: string | undefined;
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
if (localVarHttpHeaderAcceptSelected === undefined) {
// to determine the Accept header
const httpHeaderAccepts: string[] = [
'application/json'
];
localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
}
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}

let localVarHttpContext: HttpContext | undefined = options && options.context;
if (localVarHttpContext === undefined) {
localVarHttpContext = new HttpContext();
}

let localVarTransferCache: boolean | undefined = options && options.transferCache;
if (localVarTransferCache === undefined) {
localVarTransferCache = true;
}


// to determine the Content-Type header
const consumes: string[] = [
'application/json'
];
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
if (httpContentTypeSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected);
}

let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}

let localVarPath = `/api/auth`;
return this.httpClient.request<LoginCheckPost200Response>('post', `${this.configuration.basePath}${localVarPath}`,
{
context: localVarHttpContext,
body: loginCheckPostRequest,
responseType: <any>responseType_,
withCredentials: this.configuration.withCredentials,
headers: localVarHeaders,
observe: observe,
transferCache: localVarTransferCache,
reportProgress: reportProgress
}
);
}

}

+ 4
- 4
angular/src/app/core/api/v1/api/mediaObject.service.ts 查看文件

@@ -135,7 +135,7 @@ export class MediaObjectService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -208,7 +208,7 @@ export class MediaObjectService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -279,7 +279,7 @@ export class MediaObjectService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -348,7 +348,7 @@ export class MediaObjectService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;


+ 5
- 5
angular/src/app/core/api/v1/api/shippingCompany.service.ts 查看文件

@@ -139,7 +139,7 @@ export class ShippingCompanyService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -212,7 +212,7 @@ export class ShippingCompanyService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -283,7 +283,7 @@ export class ShippingCompanyService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -359,7 +359,7 @@ export class ShippingCompanyService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -441,7 +441,7 @@ export class ShippingCompanyService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;


+ 4
- 4
angular/src/app/core/api/v1/api/trip.service.ts 查看文件

@@ -124,7 +124,7 @@ export class TripService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -197,7 +197,7 @@ export class TripService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -273,7 +273,7 @@ export class TripService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -355,7 +355,7 @@ export class TripService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;


+ 4
- 4
angular/src/app/core/api/v1/api/tripLocation.service.ts 查看文件

@@ -124,7 +124,7 @@ export class TripLocationService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -197,7 +197,7 @@ export class TripLocationService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -273,7 +273,7 @@ export class TripLocationService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -355,7 +355,7 @@ export class TripLocationService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;


+ 5
- 5
angular/src/app/core/api/v1/api/user.service.ts 查看文件

@@ -144,7 +144,7 @@ export class UserService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -217,7 +217,7 @@ export class UserService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -288,7 +288,7 @@ export class UserService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -364,7 +364,7 @@ export class UserService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -446,7 +446,7 @@ export class UserService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;


+ 4
- 4
angular/src/app/core/api/v1/api/userTrip.service.ts 查看文件

@@ -124,7 +124,7 @@ export class UserTripService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -197,7 +197,7 @@ export class UserTripService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -273,7 +273,7 @@ export class UserTripService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -355,7 +355,7 @@ export class UserTripService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;


+ 4
- 4
angular/src/app/core/api/v1/api/userTripLocation.service.ts 查看文件

@@ -124,7 +124,7 @@ export class UserTripLocationService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -197,7 +197,7 @@ export class UserTripLocationService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -273,7 +273,7 @@ export class UserTripLocationService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -355,7 +355,7 @@ export class UserTripLocationService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;


+ 4
- 4
angular/src/app/core/api/v1/api/userTripWorkLog.service.ts 查看文件

@@ -124,7 +124,7 @@ export class UserTripWorkLogService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -197,7 +197,7 @@ export class UserTripWorkLogService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -273,7 +273,7 @@ export class UserTripWorkLogService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -355,7 +355,7 @@ export class UserTripWorkLogService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;


+ 5
- 5
angular/src/app/core/api/v1/api/vessel.service.ts 查看文件

@@ -139,7 +139,7 @@ export class VesselService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -212,7 +212,7 @@ export class VesselService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -283,7 +283,7 @@ export class VesselService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -359,7 +359,7 @@ export class VesselService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -441,7 +441,7 @@ export class VesselService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;


+ 5
- 5
angular/src/app/core/api/v1/api/zone.service.ts 查看文件

@@ -139,7 +139,7 @@ export class ZoneService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -212,7 +212,7 @@ export class ZoneService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -283,7 +283,7 @@ export class ZoneService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -359,7 +359,7 @@ export class ZoneService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
@@ -441,7 +441,7 @@ export class ZoneService {
// authentication (JWT) required
localVarCredential = this.configuration.lookupCredential('JWT');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', localVarCredential);
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;


+ 3
- 5
angular/src/app/core/api/v1/configuration.ts 查看文件

@@ -90,11 +90,9 @@ export class Configuration {
// init default JWT credential
if (!this.credentials['JWT']) {
this.credentials['JWT'] = () => {
if (this.apiKeys === null || this.apiKeys === undefined) {
return undefined;
} else {
return this.apiKeys['JWT'] || this.apiKeys['Authorization'];
}
return typeof this.accessToken === 'function'
? this.accessToken()
: this.accessToken;
};
}
}


+ 0
- 17
angular/src/app/core/api/v1/model/loginCheckPost200Response.ts 查看文件

@@ -1,17 +0,0 @@
/**
* Imaq Platform
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/


export interface LoginCheckPost200Response {
readonly token: string;
}


+ 0
- 18
angular/src/app/core/api/v1/model/loginCheckPostRequest.ts 查看文件

@@ -1,18 +0,0 @@
/**
* Imaq Platform
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/


export interface LoginCheckPostRequest {
email: string;
password: string;
}


+ 3
- 6
angular/src/app/core/api/v1/model/mediaObjectJsonld.ts 查看文件

@@ -9,7 +9,6 @@
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { UserJsonld } from './userJsonld';
import { LocationJsonldContext } from './locationJsonldContext';


@@ -20,11 +19,9 @@ export interface MediaObjectJsonld {
context?: LocationJsonldContext;
readonly id?: string;
readonly type?: string;
readonly id?: number;
readonly dbId?: number | null;
contentUrl?: string | null;
file: Blob | null;
filePath?: string | null;
createdBy?: UserJsonld;
readonly createdAt?: string;
readonly filePath?: string | null;
readonly createdAt?: string | null;
}


+ 0
- 24
angular/src/app/core/api/v1/model/mediaObjectJsonldMediaObjectRead.ts 查看文件

@@ -1,24 +0,0 @@
/**
* Imaq Platform
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { LocationJsonldContext } from './locationJsonldContext';


/**
*
*/
export interface MediaObjectJsonldMediaObjectRead {
context?: LocationJsonldContext;
readonly id?: string;
readonly type?: string;
contentUrl?: string | null;
}


+ 0
- 1
httpdocs/config/packages/api_platform.yaml 查看文件

@@ -17,7 +17,6 @@ api_platform:
pagination_items_per_page: 50
pagination_maximum_items_per_page: 100


swagger:
api_keys:
JWT:


+ 68
- 0
httpdocs/src/ApiResource/MediaObjectApi.php 查看文件

@@ -0,0 +1,68 @@
<?php

namespace App\ApiResource;

use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Post;
use ApiPlatform\OpenApi\Model;
use App\Controller\CreateMediaObjectAction;
use App\Entity\MediaObject;
use App\State\EntityClassDtoStateProcessor;
use App\State\EntityToDtoStateProvider;
use ApiPlatform\Doctrine\Orm\State\Options;

#[ApiResource(
shortName: 'MediaObject',
operations: [
new Get(),
new GetCollection(),
new Post(
controller: CreateMediaObjectAction::class,
openapi: new Model\Operation(
requestBody: new Model\RequestBody(
content: new \ArrayObject([
'multipart/form-data' => [
'schema' => [
'type' => 'object',
'properties' => [
'file' => [
'type' => 'string',
'format' => 'binary'
]
]
]
]
])
)
),
deserialize: false
),
new Delete(),
],
security: 'is_granted("ROLE_USER")',
provider: EntityToDtoStateProvider::class,
processor: EntityClassDtoStateProcessor::class,
stateOptions: new Options(entityClass: MediaObject::class),
)]
class MediaObjectApi
{
#[ApiProperty(readable: false, writable: false, identifier: true)]
public ?int $id = null;

#[ApiProperty(writable: false)]
public ?int $dbId = null;

#[ApiProperty(types: ['https://schema.org/contentUrl'])]
public ?string $contentUrl = null;

// Optional: Wenn Sie das Filepath in der API sehen möchten
#[ApiProperty(writable: false)]
public ?string $filePath = null;

#[ApiProperty(writable: false)]
public ?\DateTimeImmutable $createdAt = null;
}

+ 21
- 9
httpdocs/src/Controller/CreateMediaObjectAction.php 查看文件

@@ -1,35 +1,47 @@
<?php
/**
* @author Daniel Knudsen <d.knudsen@spawntree.de>
* @date 25.01.24
*/


namespace App\Controller;

use App\ApiResource\MediaObjectApi;
use App\Entity\MediaObject;
use App\Entity\User;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Finder\Exception\AccessDeniedException;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfonycasts\MicroMapper\MicroMapperInterface;

#[AsController]
final class CreateMediaObjectAction extends AbstractController
{
public function __invoke(Request $request): MediaObject
public function __construct(
private MicroMapperInterface $microMapper,
private EntityManagerInterface $em
) {
}

public function __invoke(Request $request): JsonResponse
{
$uploadedFile = $request->files->get('file');
if (!$uploadedFile) {
throw new BadRequestHttpException('"file" is required');
}

// Sicherstellen dass ein User vorhanden ist
$user = $this->getUser();
assert($user instanceof User);
if (!$user instanceof User) {
throw new AccessDeniedException('User must be logged in');
}

$mediaObject = new MediaObject($user);
$mediaObject->file = $uploadedFile;
$this->em->persist($mediaObject);
$this->em->flush();

return $mediaObject;
$mediaObjectApi = $this->microMapper->map($mediaObject, MediaObjectApi::class);
return new JsonResponse($mediaObjectApi);
}
}

+ 44
- 0
httpdocs/src/Mapper/MediaObjectEntityToApiMapper.php 查看文件

@@ -0,0 +1,44 @@
<?php

namespace App\Mapper;

use App\ApiResource\MediaObjectApi;
use App\Entity\MediaObject;
use Symfonycasts\MicroMapper\AsMapper;
use Symfonycasts\MicroMapper\MapperInterface;
use Vich\UploaderBundle\Storage\StorageInterface;

#[AsMapper(from: MediaObject::class, to: MediaObjectApi::class)]
class MediaObjectEntityToApiMapper implements MapperInterface
{
public function __construct(
private StorageInterface $storage
) {
}

public function load(object $from, string $toClass, array $context): object
{
$entity = $from;
assert($entity instanceof MediaObject);

$dto = new MediaObjectApi();
$dto->id = $entity->getId();

return $dto;
}

public function populate(object $from, object $to, array $context): object
{
$entity = $from;
$dto = $to;
assert($entity instanceof MediaObject);
assert($dto instanceof MediaObjectApi);

$dto->dbId = $entity->getId();
$dto->filePath = $entity->getFilePath();
$dto->contentUrl = $this->storage->resolveUri($entity, 'file');
$dto->createdAt = $entity->getCreatedAt();

return $dto;
}
}

+ 32
- 0
httpdocs/src/OpenApi/BearerTokenDecorator.php 查看文件

@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace App\OpenApi;

use ApiPlatform\OpenApi\OpenApi;
use ApiPlatform\OpenApi\Factory\OpenApiFactoryInterface;
use Symfony\Component\DependencyInjection\Attribute\AsDecorator;

#[AsDecorator(decorates: 'api_platform.openapi.factory')]
class BearerTokenDecorator implements OpenApiFactoryInterface
{
public function __construct(
private readonly OpenApiFactoryInterface $decorated
) {}

public function __invoke(array $context = []): OpenApi
{
$openApi = ($this->decorated)($context);

$schemas = $openApi->getComponents()->getSecuritySchemes();

$schemas['JWT'] = new \ArrayObject([
'type' => 'http',
'scheme' => 'bearer',
'bearerFormat' => 'JWT'
]);

return $openApi;
}
}

Loading…
取消
儲存