From 92eb2663bc6917afc9c5ca1bdc59d7a299676168 Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 8 Apr 2026 16:34:21 +0200 Subject: [PATCH] add purchase info --- models/resources/resource.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/models/resources/resource.go b/models/resources/resource.go index b2275bf..d8d2f53 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) - IsBuy bool `json:"is_buy"` // is_buy precise if a resource is buy or not + PurchaseInfo *purchase_resource.PurchaseResource `json:"purchase_info,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 @@ -40,12 +40,14 @@ func (abs *AbstractResource) VerifyBuy() { p := &purchase_resource.PurchaseResource{} access := p.GetAccessor(&tools.APIRequest{Admin: true}) - access.Search(&dbs.Filters{ + purchase, _, _ := access.Search(&dbs.Filters{ And: map[string][]dbs.Filter{ "resource_id": {{Operator: dbs.EQUAL.String(), Value: abs.GetID()}}, }, }, "", false, 0, 1) - + if len(purchase) > 0 { + abs.PurchaseInfo = purchase[0].(*purchase_resource.PurchaseResource) + } } func (abs *AbstractResource) GetEnv() []models.Param {