Browse Source

add save price

master
shenjiachi 6 days ago
parent
commit
fa8d86fd28
2 changed files with 10 additions and 1 deletions
  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 View File

@@ -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 View File

@@ -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
}

Loading…
Cancel
Save