Explorar el Código

update

master
dengbiao hace 1 semana
padre
commit
a9a84aba82
Se han modificado 4 ficheros con 42 adiciones y 1 borrados
  1. +9
    -0
      src/dao/cron_task_dao.go
  2. +0
    -1
      src/dao/egg_energy_price_dao.go
  3. +26
    -0
      src/implement/cron_task_implement.go
  4. +7
    -0
      src/model/cron_task.go

+ 9
- 0
src/dao/cron_task_dao.go Ver fichero

@@ -0,0 +1,9 @@
package dao

import (
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
)

type CronTaskDao interface {
MapCrontabCfg() *[]model.CronTask
}

+ 0
- 1
src/dao/egg_energy_price_dao.go Ver fichero

@@ -3,7 +3,6 @@ package dao
import "code.fnuoos.com/EggPlanet/egg_models.git/src/model"

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)


+ 26
- 0
src/implement/cron_task_implement.go Ver fichero

@@ -0,0 +1,26 @@
package implement

import (
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx"
"xorm.io/xorm"
)

func NewCronTaskDb(engine *xorm.Engine) dao.CronTaskDao {
return &CronTaskDb{Db: engine}
}

type CronTaskDb struct {
Db *xorm.Engine
}

func (cdb CronTaskDb) MapCrontabCfg() *[]model.CronTask {
var c []model.CronTask
// 数据库查询如果有下划线会认为是一个任意字符
if err := cdb.Db.Where("`key` LIKE 'cron\\_%' AND val != ''").Cols("`key`,`val`").Find(&c); err != nil || len(c) == 0 {
zhios_order_relate_logx.Warn(err)
return nil
}
return &c
}

+ 7
- 0
src/model/cron_task.go Ver fichero

@@ -0,0 +1,7 @@
package model

type CronTask struct {
Key string `json:"key" xorm:"not null pk comment('键') VARCHAR(64)"`
Val string `json:"val" xorm:"not null comment('值') TEXT"`
Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(255)"`
}

Cargando…
Cancelar
Guardar