@@ -0,0 +1,9 @@ | |||||
package dao | |||||
import ( | |||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" | |||||
) | |||||
type CronTaskDao interface { | |||||
MapCrontabCfg() *[]model.CronTask | |||||
} |
@@ -3,7 +3,6 @@ package dao | |||||
import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" | import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" | ||||
type EggEnergyPriceDao interface { | type EggEnergyPriceDao interface { | ||||
//TODO:: You can add specific method definitions here | |||||
EggEnergyPriceList(startAt string, endAt string, hour string) ([]model.EggEnergyPrice, error) | EggEnergyPriceList(startAt string, endAt string, hour string) ([]model.EggEnergyPrice, error) | ||||
EggEnergyPriceGetLastOne() (*model.EggEnergyPrice, bool, error) | EggEnergyPriceGetLastOne() (*model.EggEnergyPrice, bool, error) | ||||
EggEnergyPriceInsert(eggEnergyPrice *model.EggEnergyPrice) (int64, error) | EggEnergyPriceInsert(eggEnergyPrice *model.EggEnergyPrice) (int64, error) | ||||
@@ -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 | |||||
} |
@@ -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)"` | |||||
} |