huangjiajun hace 1 año
padre
commit
7125dbba5b
Se han modificado 6 ficheros con 19 adiciones y 15 borrados
  1. +7
    -7
      app/db/db_master_list_cfg.go
  2. +6
    -6
      app/db/db_sys_cfg.go
  3. +1
    -0
      app/task/init.go
  4. +1
    -1
      app/task/svc/svc_playlet_adv_order.go
  5. +0
    -1
      app/utils/cache/redis.go
  6. +4
    -0
      etc/task.yml

+ 7
- 7
app/db/db_master_list_cfg.go Ver fichero

@@ -19,21 +19,21 @@ func (masterListCfgDb *MasterListCfgDb) Set() { // set方法

func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetAll() (*[]model.MasterListCfg, error) {
var cfgList []model.MasterListCfg
if err := Db.Cols("k,v,memo").Find(&cfgList); err != nil {
if err := masterListCfgDb.Db.Cols("k,v,memo").Find(&cfgList); err != nil {
return nil, logx.Error(err)
}
return &cfgList, nil
}
func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetCron() (*[]model.MasterListCfg, error) {
var cfgList []model.MasterListCfg
if err := Db.Where("`k` LIKE 'zhimeng_cron\\_%' AND v != ''").Cols("k,v,memo").Find(&cfgList); err != nil {
if err := masterListCfgDb.Db.Where("`k` LIKE 'zhimeng_cron\\_%' AND v != ''").Cols("k,v,memo").Find(&cfgList); err != nil {
return nil, logx.Error(err)
}
return &cfgList, nil
}
func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetOneNoDataNoErr(key string) (*model.MasterListCfg, error) {
var cfgList model.MasterListCfg
has, err := Db.Where("`k`=?", key).Get(&cfgList)
has, err := masterListCfgDb.Db.Where("`k`=?", key).Get(&cfgList)
if err != nil {
return nil, logx.Error(err)
}
@@ -45,14 +45,14 @@ func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetOneNoDataNoErr(key strin

func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetOne(uid, key string) (*model.MasterListCfg, error) {
var cfgList model.MasterListCfg
if has, err := Db.Where("`k`=? and uid=?", key, uid).Get(&cfgList); err != nil || has == false {
if has, err := masterListCfgDb.Db.Where("`k`=? and uid=?", key, uid).Get(&cfgList); err != nil || has == false {
return nil, logx.Error(err)
}
return &cfgList, nil
}
func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetOneData(uid, key string) string {
var cfgList model.MasterListCfg
if has, err := Db.Where("`k`=? and uid=?", key, uid).Get(&cfgList); err != nil || has == false {
if has, err := masterListCfgDb.Db.Where("`k`=? and uid=?", key, uid).Get(&cfgList); err != nil || has == false {
return ""
}
return cfgList.V
@@ -60,7 +60,7 @@ func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetOneData(uid, key string)

func (masterListCfgDb *MasterListCfgDb) MasterListCfgInsert(uid, key, val, memo string) bool {
cfg := model.MasterListCfg{Uid: uid, K: key, V: val, Memo: memo}
_, err := Db.InsertOne(&cfg)
_, err := masterListCfgDb.Db.InsertOne(&cfg)
if err != nil {
logx.Error(err)
return false
@@ -70,7 +70,7 @@ func (masterListCfgDb *MasterListCfgDb) MasterListCfgInsert(uid, key, val, memo

func (masterListCfgDb *MasterListCfgDb) MasterListCfgUpdate(uid, key, val string) bool {
cfg := model.MasterListCfg{K: key, V: val}
_, err := Db.Where("`k`=? and uid=?", key, uid).Cols("val").Update(&cfg)
_, err := masterListCfgDb.Db.Where("`k`=? and uid=?", key, uid).Cols("val").Update(&cfg)
if err != nil {
logx.Error(err)
return false


+ 6
- 6
app/db/db_sys_cfg.go Ver fichero

@@ -19,21 +19,21 @@ func (sysCfgDb *SysCfgDb) Set() { // set方法

func (sysCfgDb *SysCfgDb) SysCfgGetAll() (*[]model.SysCfg, error) {
var cfgList []model.SysCfg
if err := Db.Cols("k,v,memo").Find(&cfgList); err != nil {
if err := sysCfgDb.Db.Cols("k,v,memo").Find(&cfgList); err != nil {
return nil, logx.Error(err)
}
return &cfgList, nil
}
func (sysCfgDb *SysCfgDb) SysCfgGetCron() (*[]model.SysCfg, error) {
var cfgList []model.SysCfg
if err := Db.Where("`k` LIKE 'zhimeng_cron\\_%' AND v != ''").Cols("k,v,memo").Find(&cfgList); err != nil {
if err := sysCfgDb.Db.Where("`k` LIKE 'zhimeng_cron\\_%' AND v != ''").Cols("k,v,memo").Find(&cfgList); err != nil {
return nil, logx.Error(err)
}
return &cfgList, nil
}
func (sysCfgDb *SysCfgDb) SysCfgGetOneNoDataNoErr(key string) (*model.SysCfg, error) {
var cfgList model.SysCfg
has, err := Db.Where("`k`=?", key).Get(&cfgList)
has, err := sysCfgDb.Db.Where("`k`=?", key).Get(&cfgList)
if err != nil {
return nil, logx.Error(err)
}
@@ -45,14 +45,14 @@ func (sysCfgDb *SysCfgDb) SysCfgGetOneNoDataNoErr(key string) (*model.SysCfg, er

func (sysCfgDb *SysCfgDb) SysCfgGetOne(key string) (*model.SysCfg, error) {
var cfgList model.SysCfg
if has, err := Db.Where("`k`=?", key).Get(&cfgList); err != nil || has == false {
if has, err := sysCfgDb.Db.Where("`k`=?", key).Get(&cfgList); err != nil || has == false {
return nil, logx.Error(err)
}
return &cfgList, nil
}
func (sysCfgDb *SysCfgDb) SysCfgGetOneData(key string) string {
var cfgList model.SysCfg
if has, err := Db.Where("`k`=?", key).Get(&cfgList); err != nil || has == false {
if has, err := sysCfgDb.Db.Where("`k`=?", key).Get(&cfgList); err != nil || has == false {
return ""
}
return cfgList.V
@@ -60,7 +60,7 @@ func (sysCfgDb *SysCfgDb) SysCfgGetOneData(key string) string {

func (sysCfgDb *SysCfgDb) SysCfgInsert(key, val, memo string) bool {
cfg := model.SysCfg{K: key, V: val, Memo: memo}
_, err := Db.InsertOne(&cfg)
_, err := sysCfgDb.Db.InsertOne(&cfg)
if err != nil {
logx.Error(err)
return false


+ 1
- 0
app/task/init.go Ver fichero

@@ -69,6 +69,7 @@ func reload() {
func doTask(fnName string) func() {
return func() {
begin := time.Now().Local()
jobs[fnName]()
end := time.Now().Local()
logx.Infof(
" AutoTask <%s> started at <%s>, ended at <%s> duration <%s>",


+ 1
- 1
app/task/svc/svc_playlet_adv_order.go Ver fichero

@@ -120,7 +120,7 @@ func PlayletAdvOrderYesterday(hours int, runtimeStr string) {
"page_size": pageSize,
"page_index": pageNo,
}
count := getVideoOrder(uid, arg)
count := getAdvOrder(uid, arg)
if count == 0 {
break
}


+ 0
- 1
app/utils/cache/redis.go Ver fichero

@@ -48,7 +48,6 @@ func NewRedis(addr string) {
Wait: true,
Dial: func() (redigo.Conn, error) {
c, err := redigo.Dial("tcp", addr,
redigo.DialPassword(redisPassword),
redigo.DialConnectTimeout(redisDialTTL),
redigo.DialReadTimeout(redisReadTTL),
redigo.DialWriteTimeout(redisWriteTTL),


+ 4
- 0
etc/task.yml Ver fichero

@@ -5,6 +5,10 @@ local: true
# 缓存
redis_addr: '120.24.28.6:32572'

redis_addr_second:
addr: '120.24.28.6:32572'
pwd: ''

# 数据库
db:
host: '119.23.182.117:3306'


Cargando…
Cancelar
Guardar