From 6741e929ccf6f3a0622afb54d52931424846db7b Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 22 Apr 2026 09:48:16 +0200 Subject: [PATCH] purchase as string --- models/resources/resource.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/models/resources/resource.go b/models/resources/resource.go index d8d2f53..a2376b7 100755 --- a/models/resources/resource.go +++ b/models/resources/resource.go @@ -22,7 +22,7 @@ import ( // AbstractResource is the struct containing all of the attributes commons to all ressources type AbstractResource struct { utils.AbstractObject // AbstractObject contains the basic fields of an object (id, name) - PurchaseInfo *purchase_resource.PurchaseResource `json:"purchase_info,omitempty"` // is_buy precise if a resource is buy or not + PurchaseID string `json:"purchase_id,omitempty"` // is_buy precise if a resource is buy or not Type string `json:"type,omitempty" bson:"type,omitempty"` // Type is the type of the resource Logo string `json:"logo,omitempty" bson:"logo,omitempty"` // Logo is the logo of the resource Description string `json:"description,omitempty" bson:"description,omitempty"` // Description is the description of the resource @@ -36,6 +36,20 @@ type AbstractResource struct { Outputs []models.Param `json:"outputs,omitempty" bson:"outputs,omitempty"` } +func (ri *AbstractResource) Extend(typ ...string) map[string][]tools.DataType { + dt := map[string][]tools.DataType{} + for _, t := range typ { + switch t { + case "purchase": + if _, ok := dt[t]; !ok { + dt[t] = []tools.DataType{} + } + dt[t] = append(dt[t], tools.PURCHASE_RESOURCE) + } + } + return dt +} + func (abs *AbstractResource) VerifyBuy() { p := &purchase_resource.PurchaseResource{} access := p.GetAccessor(&tools.APIRequest{Admin: true}) @@ -46,7 +60,7 @@ func (abs *AbstractResource) VerifyBuy() { }, }, "", false, 0, 1) if len(purchase) > 0 { - abs.PurchaseInfo = purchase[0].(*purchase_resource.PurchaseResource) + abs.PurchaseID = purchase[0].GetID() } }