add purchase info

This commit is contained in:
mr
2026-04-08 16:34:21 +02:00
parent 284533ad1d
commit 92eb2663bc

View File

@@ -22,7 +22,7 @@ import (
// AbstractResource is the struct containing all of the attributes commons to all ressources // AbstractResource is the struct containing all of the attributes commons to all ressources
type AbstractResource struct { type AbstractResource struct {
utils.AbstractObject // AbstractObject contains the basic fields of an object (id, name) 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 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 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 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{} p := &purchase_resource.PurchaseResource{}
access := p.GetAccessor(&tools.APIRequest{Admin: true}) access := p.GetAccessor(&tools.APIRequest{Admin: true})
access.Search(&dbs.Filters{ purchase, _, _ := access.Search(&dbs.Filters{
And: map[string][]dbs.Filter{ And: map[string][]dbs.Filter{
"resource_id": {{Operator: dbs.EQUAL.String(), Value: abs.GetID()}}, "resource_id": {{Operator: dbs.EQUAL.String(), Value: abs.GetID()}},
}, },
}, "", false, 0, 1) }, "", false, 0, 1)
if len(purchase) > 0 {
abs.PurchaseInfo = purchase[0].(*purchase_resource.PurchaseResource)
}
} }
func (abs *AbstractResource) GetEnv() []models.Param { func (abs *AbstractResource) GetEnv() []models.Param {