From 7125dbba5bdc68206ae77a5e1a6c0513b8a1015b Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Sat, 8 Jul 2023 15:05:55 +0800 Subject: [PATCH] test --- app/db/db_master_list_cfg.go | 14 +++++++------- app/db/db_sys_cfg.go | 12 ++++++------ app/task/init.go | 1 + app/task/svc/svc_playlet_adv_order.go | 2 +- app/utils/cache/redis.go | 1 - etc/task.yml | 4 ++++ 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/app/db/db_master_list_cfg.go b/app/db/db_master_list_cfg.go index 2ab67ee..15c10c8 100644 --- a/app/db/db_master_list_cfg.go +++ b/app/db/db_master_list_cfg.go @@ -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 diff --git a/app/db/db_sys_cfg.go b/app/db/db_sys_cfg.go index 4982933..4a768af 100644 --- a/app/db/db_sys_cfg.go +++ b/app/db/db_sys_cfg.go @@ -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 diff --git a/app/task/init.go b/app/task/init.go index 56a6a85..38dbb54 100644 --- a/app/task/init.go +++ b/app/task/init.go @@ -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>", diff --git a/app/task/svc/svc_playlet_adv_order.go b/app/task/svc/svc_playlet_adv_order.go index 1b2055c..7c4699a 100644 --- a/app/task/svc/svc_playlet_adv_order.go +++ b/app/task/svc/svc_playlet_adv_order.go @@ -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 } diff --git a/app/utils/cache/redis.go b/app/utils/cache/redis.go index de3be89..3c4b914 100644 --- a/app/utils/cache/redis.go +++ b/app/utils/cache/redis.go @@ -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), diff --git a/etc/task.yml b/etc/task.yml index 8d83d52..8d98605 100644 --- a/etc/task.yml +++ b/etc/task.yml @@ -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'