updated
This commit is contained in:
@@ -44,6 +44,9 @@ func GetAllOperations(userid string) ([]model.Operation, error) {
|
||||
return nil, e
|
||||
}
|
||||
for i := range operations {
|
||||
if operations[i].CategoryID == "" {
|
||||
continue
|
||||
}
|
||||
var category model.Category
|
||||
e := Db.First(&category, "ID = ?", operations[i].CategoryID).Error
|
||||
if e != nil {
|
||||
|
||||
@@ -1,45 +1,44 @@
|
||||
[
|
||||
{
|
||||
"title": "Operation 1",
|
||||
"amount": 100,
|
||||
"date": "2022-01-01T00:00:00Z",
|
||||
"type": "income",
|
||||
"icon": "😀",
|
||||
"categoryid": "8f8b5f62-5d30-44a0-8de0-0485200f53a5"
|
||||
},
|
||||
{
|
||||
"title": "Operation 2",
|
||||
"amount": 200,
|
||||
"date": "2022-01-02T00:00:00Z",
|
||||
"type": "expense",
|
||||
"icon": "😂"
|
||||
},
|
||||
{
|
||||
"title": "Operation 2",
|
||||
"amount": 200,
|
||||
"date": "2022-01-02T00:00:00Z",
|
||||
"type": "expense",
|
||||
"icon": "😂"
|
||||
},
|
||||
{
|
||||
"title": "Operation 1",
|
||||
"amount": 100,
|
||||
"date": "2022-01-02T00:00:00Z",
|
||||
"type": "income",
|
||||
"icon": "😀"
|
||||
},
|
||||
{
|
||||
"title": "Operation 2",
|
||||
"amount": 200,
|
||||
"date": "2022-06-02T00:00:00Z",
|
||||
"type": "expense",
|
||||
"icon": "😂"
|
||||
},
|
||||
{
|
||||
"title": "Operation 2",
|
||||
"amount": 200,
|
||||
"date": "2022-06-22T00:00:00Z",
|
||||
"type": "expense",
|
||||
"icon": "😂"
|
||||
}
|
||||
]
|
||||
{
|
||||
"title": "Operation 1",
|
||||
"amount": 100,
|
||||
"date": "2022-01-01T00:00:00Z",
|
||||
"type": "income",
|
||||
"icon": "😀"
|
||||
},
|
||||
{
|
||||
"title": "Operation 2",
|
||||
"amount": 200,
|
||||
"date": "2022-01-02T00:00:00Z",
|
||||
"type": "expense",
|
||||
"icon": "😂"
|
||||
},
|
||||
{
|
||||
"title": "Operation 2",
|
||||
"amount": 200,
|
||||
"date": "2022-01-02T00:00:00Z",
|
||||
"type": "expense",
|
||||
"icon": "😂"
|
||||
},
|
||||
{
|
||||
"title": "Operation 1",
|
||||
"amount": 100,
|
||||
"date": "2022-01-02T00:00:00Z",
|
||||
"type": "income",
|
||||
"icon": "😀"
|
||||
},
|
||||
{
|
||||
"title": "Operation 2",
|
||||
"amount": 200,
|
||||
"date": "2022-06-02T00:00:00Z",
|
||||
"type": "expense",
|
||||
"icon": "😂"
|
||||
},
|
||||
{
|
||||
"title": "Operation 2",
|
||||
"amount": 200,
|
||||
"date": "2022-06-22T00:00:00Z",
|
||||
"type": "expense",
|
||||
"icon": "😂"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -10,7 +10,7 @@ type Operation struct {
|
||||
Date string `json:"date"`
|
||||
UserID string `json:"userid"`
|
||||
CategoryID string `json:"categoryid"`
|
||||
SubcategoryID string `json:"subcategoryid"`
|
||||
Category Category `gorm:"foreignKey:CategoryID"`
|
||||
Subcategory Subcategory `gorm:"foreignKey:SubcategoryID"`
|
||||
SubcategoryID *string `json:"subcategoryid,omitempty"`
|
||||
Category Category `json:"category,omitzero"`
|
||||
Subcategory Subcategory `json:"subcategory,omitzero"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user