dengbiao 6 giorni fa
parent
commit
a9a84aba82
4 ha cambiato i file con 42 aggiunte e 1 eliminazioni
  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 Vedi File

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

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

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

@@ -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)"`
}

Caricamento…
Annulla
Salva