error adjust
This commit is contained in:
parent
df556f7c7a
commit
7f294374e8
@ -11,13 +11,13 @@ import (
|
|||||||
type LibDataEnum int
|
type LibDataEnum int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
INVALID LibDataEnum = iota
|
INVALID LibDataEnum = iota
|
||||||
DATA_RESOURCE = utils.DATA_RESOURCE
|
DATA_RESOURCE = utils.DATA_RESOURCE
|
||||||
PROCESSING_RESOURCE = utils.PROCESSING_RESOURCE
|
PROCESSING_RESOURCE = utils.PROCESSING_RESOURCE
|
||||||
STORAGE_RESOURCE = utils.STORAGE_RESOURCE
|
STORAGE_RESOURCE = utils.STORAGE_RESOURCE
|
||||||
DATACENTER_RESOURCE = utils.DATACENTER_RESOURCE
|
DATACENTER_RESOURCE = utils.DATACENTER_RESOURCE
|
||||||
WORKFLOW_RESOURCE = utils.WORKFLOW_RESOURCE
|
WORKFLOW_RESOURCE = utils.WORKFLOW_RESOURCE
|
||||||
WORKFLOW = utils.WORKFLOW
|
WORKFLOW = utils.WORKFLOW
|
||||||
)
|
)
|
||||||
|
|
||||||
func (d LibDataEnum) EnumIndex() int {
|
func (d LibDataEnum) EnumIndex() int {
|
||||||
@ -26,8 +26,8 @@ func (d LibDataEnum) EnumIndex() int {
|
|||||||
|
|
||||||
type LibData struct {
|
type LibData struct {
|
||||||
Data utils.DBObject `bson:"data" json:"data"`
|
Data utils.DBObject `bson:"data" json:"data"`
|
||||||
Code int `bson:"code" json:"code"`
|
Code int `bson:"code" json:"code"`
|
||||||
Err error `bson:"error" json:"error"`
|
Err string `bson:"error" json:"error"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func Init(appName string) {
|
func Init(appName string) {
|
||||||
@ -42,27 +42,27 @@ func GetLogger() zerolog.Logger {
|
|||||||
|
|
||||||
func LoadOne(collection LibDataEnum, id string) LibData {
|
func LoadOne(collection LibDataEnum, id string) LibData {
|
||||||
d, code, err := models.Model(collection.EnumIndex()).GetAccessor().LoadOne(id)
|
d, code, err := models.Model(collection.EnumIndex()).GetAccessor().LoadOne(id)
|
||||||
return LibData{Data: d, Code: code, Err: err}
|
return LibData{Data: d, Code: code, Err: err.Error()}
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateOne(collection LibDataEnum, set map[string]interface{}, id string) LibData {
|
func UpdateOne(collection LibDataEnum, set map[string]interface{}, id string) LibData {
|
||||||
d, code, err := models.Model(collection.EnumIndex()).GetAccessor().UpdateOne(set, id)
|
d, code, err := models.Model(collection.EnumIndex()).GetAccessor().UpdateOne(set, id)
|
||||||
return LibData{Data: d, Code: code, Err: err}
|
return LibData{Data: d, Code: code, Err: err.Error()}
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteOne(collection LibDataEnum, id string) LibData {
|
func DeleteOne(collection LibDataEnum, id string) LibData {
|
||||||
d, code, err := models.Model(collection.EnumIndex()).GetAccessor().DeleteOne(id)
|
d, code, err := models.Model(collection.EnumIndex()).GetAccessor().DeleteOne(id)
|
||||||
return LibData{Data: d, Code: code, Err: err}
|
return LibData{Data: d, Code: code, Err: err.Error()}
|
||||||
}
|
}
|
||||||
|
|
||||||
func StoreOne(collection LibDataEnum, object map[string]interface{}) LibData {
|
func StoreOne(collection LibDataEnum, object map[string]interface{}) LibData {
|
||||||
model := models.Model(collection.EnumIndex())
|
model := models.Model(collection.EnumIndex())
|
||||||
d, code, err := model.GetAccessor().StoreOne(model.Deserialize(object))
|
d, code, err := model.GetAccessor().StoreOne(model.Deserialize(object))
|
||||||
return LibData{Data: d, Code: code, Err: err}
|
return LibData{Data: d, Code: code, Err: err.Error()}
|
||||||
}
|
}
|
||||||
|
|
||||||
func CopyOne(collection LibDataEnum, object map[string]interface{}) LibData {
|
func CopyOne(collection LibDataEnum, object map[string]interface{}) LibData {
|
||||||
model := models.Model(collection.EnumIndex())
|
model := models.Model(collection.EnumIndex())
|
||||||
d, code, err := model.GetAccessor().CopyOne(model.Deserialize(object))
|
d, code, err := model.GetAccessor().CopyOne(model.Deserialize(object))
|
||||||
return LibData{Data: d, Code: code, Err: err}
|
return LibData{Data: d, Code: code, Err: err.Error()}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestStoreOneDatacenter(t *testing.T) {
|
func TestStoreOneDatacenter(t *testing.T) {
|
||||||
dc := DatacenterResource{Owner: "toto", BookingPrice: 123,
|
dc := DatacenterResource{BookingPrice: 123,
|
||||||
AbstractResource: resources.AbstractResource{
|
AbstractResource: resources.AbstractResource{
|
||||||
AbstractObject: utils.AbstractObject{Name: "testDatacenter"},
|
AbstractObject: utils.AbstractObject{Name: "testDatacenter"},
|
||||||
Description: "Lorem Ipsum",
|
Description: "Lorem Ipsum",
|
||||||
@ -28,7 +28,7 @@ func TestStoreOneDatacenter(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestLoadOneDatacenter(t *testing.T) {
|
func TestLoadOneDatacenter(t *testing.T) {
|
||||||
dc := DatacenterResource{Owner: "toto", BookingPrice: 123,
|
dc := DatacenterResource{BookingPrice: 123,
|
||||||
AbstractResource: resources.AbstractResource{
|
AbstractResource: resources.AbstractResource{
|
||||||
AbstractObject: utils.AbstractObject{Name: "testDatacenter"},
|
AbstractObject: utils.AbstractObject{Name: "testDatacenter"},
|
||||||
Description: "Lorem Ipsum",
|
Description: "Lorem Ipsum",
|
||||||
|
Loading…
Reference in New Issue
Block a user