Przeglądaj źródła

add save price

master
shenjiachi 1 tydzień temu
rodzic
commit
fa8d86fd28
2 zmienionych plików z 10 dodań i 1 usunięć
  1. +1
    -0
      src/dao/egg_energy_price_dao.go
  2. +9
    -1
      src/implement/egg_energy_price_implement.go

+ 1
- 0
src/dao/egg_energy_price_dao.go Wyświetl plik

@@ -6,4 +6,5 @@ type EggEnergyPriceDao interface {
//TODO:: You can add specific method definitions here
EggEnergyPriceList(startAt string, endAt string, hour string) ([]model.EggEnergyPrice, error)
EggEnergyPriceGetLastOne() (*model.EggEnergyPrice, bool, error)
EggEnergyPriceInsert(eggEnergyPrice *model.EggEnergyPrice) (int64, error)
}

+ 9
- 1
src/implement/egg_energy_price_implement.go Wyświetl plik

@@ -31,9 +31,17 @@ 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.Desc("id").Get(&m)
exist, err := e.Db.OrderBy("date").OrderBy("hour").Get(&m)
if err != nil {
return nil, false, zhios_order_relate_logx.Error(err.Error())
}
return &m, exist, nil
}

func (e EggEnergyPriceDb) EggEnergyPriceInsert(eggEnergyPrice *model.EggEnergyPrice) (int64, error) {
_, err := e.Db.InsertOne(eggEnergyPrice)
if err != nil {
return 0, err
}
return eggEnergyPrice.Id, nil
}

Ładowanie…
Anuluj
Zapisz