@@ -31,7 +31,7 @@ func (e EggEnergyPriceDb) EggEnergyPriceList(startAt string, endAt string, hour
func (e EggEnergyPriceDb) EggEnergyPriceGetLastOne() (*model.EggEnergyPrice, bool, error) {
var m model.EggEnergyPrice
exist, err := e.Db.OrderBy("date").OrderBy("hour ").Get(&m)
exist, err := e.Db.Desc("id ").Get(&m)
if err != nil {
return nil, false, zhios_order_relate_logx.Error(err.Error())
}
@@ -41,7 +41,15 @@ func (e EggEnergyPriceDb) EggEnergyPriceGetLastOne() (*model.EggEnergyPrice, boo
func (e EggEnergyPriceDb) EggEnergyPriceInsert(eggEnergyPrice *model.EggEnergyPrice) (int64, error) {
_, err := e.Db.InsertOne(eggEnergyPrice)
if err != nil {
return 0, err
return 0, zhios_order_relate_logx.Error( err.Error())
}
return eggEnergyPrice.Id, nil
}
func (e EggEnergyPriceDb) EggEnergyPriceUpdate(eggEnergyPrice *model.EggEnergyPrice) (int64, error) {
affected, err := e.Db.ID(eggEnergyPrice.Id).Cols("price").Update(eggEnergyPrice)
if err != nil {
return 0, zhios_order_relate_logx.Error(err.Error())
}
return affected, nil
}