瀏覽代碼

Ajout de la gestion des lieux et des catégories

Vincent 4 月之前
父節點
當前提交
72576370b1
共有 3 個文件被更改,包括 21 次插入1 次删除
  1. 14 0
      models/Core/Category.ts
  2. 2 0
      models/Freemium/Event.ts
  3. 5 1
      services/utils/urlUtils.ts

+ 14 - 0
models/Core/Category.ts

@@ -0,0 +1,14 @@
+import { Uid } from 'pinia-orm/dist/decorators'
+import ApiResource from '~/models/ApiResource'
+
+/**
+ * Category
+ *
+ * Represents a category details for an event.
+ */
+export default class Category extends ApiResource {
+  static entity = 'categories'
+
+  @Uid()
+  declare id: number | string | null
+}

+ 2 - 0
models/Freemium/Event.ts

@@ -5,6 +5,7 @@ import {Attr, Num} from "pinia-orm/decorators";
 import File from "~/models/Core/File";
 import Place from "~/models/Place/Place";
 import Country from "~/models/Core/Country";
+import Category from "~/models/Core/Category";
 
 /**
  * AP2i Model : Freemium / Event
@@ -83,5 +84,6 @@ export default class Event extends ApiModel {
   declare priceMaxi: number | null
 
   @Attr(() => [])
+  @IriEncoded(Category)
   declare categories: Array<string> | null
 }

+ 5 - 1
services/utils/urlUtils.ts

@@ -144,7 +144,11 @@ class UrlUtils {
    *
    * @see https://api-platform.com/docs/admin/handling-relations/
    */
-  public static makeIRI(entity: string, id: number) {
+  public static makeIRI(entity: string, id: number|string) {
+    if(_.isString(id)){
+      id = parseInt(id)
+    }
+
     if (!_.isNumber(id)) {
       throw new TypeError('Invalid id : ' + id)
     }