Ver a proveniência

add save price

master
shenjiachi há 1 semana
ascendente
cometimento
fa8d86fd28
2 ficheiros alterados com 10 adições e 1 eliminações
  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 Ver ficheiro

@@ -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 Ver ficheiro

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

Carregando…
Cancelar
Guardar