mirror of
https://github.com/FJurmanovic/wallet-go-api.git
synced 2026-02-06 06:08:16 +00:00
fixes on structuring
This commit is contained in:
@@ -2,10 +2,6 @@ package common
|
||||
|
||||
import (
|
||||
"log"
|
||||
"time"
|
||||
"wallet-api/pkg/models"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
func CheckError(err error) {
|
||||
@@ -13,13 +9,3 @@ func CheckError(err error) {
|
||||
log.Fatalf("Error occured. %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func CreateDbModel() models.CommonModel {
|
||||
date := time.Now()
|
||||
dbModel := models.CommonModel{
|
||||
Id: uuid.NewString(),
|
||||
DateCreated: date,
|
||||
DateUpdated: date,
|
||||
}
|
||||
return dbModel
|
||||
}
|
||||
|
||||
17
pkg/utl/common/embeds.go
Normal file
17
pkg/utl/common/embeds.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/go-pg/pg/v10/orm"
|
||||
)
|
||||
|
||||
func GenerateEmbed(qr *orm.Query, embed string) *orm.Query{
|
||||
if embed != "" {
|
||||
rels := strings.Split(embed, ",")
|
||||
for _, rel := range rels {
|
||||
qr = qr.Relation(rel)
|
||||
}
|
||||
}
|
||||
return qr
|
||||
}
|
||||
Reference in New Issue
Block a user