@@ -19,21 +19,21 @@ func (masterListCfgDb *MasterListCfgDb) Set() { // set方法 | |||||
func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetAll() (*[]model.MasterListCfg, error) { | func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetAll() (*[]model.MasterListCfg, error) { | ||||
var cfgList []model.MasterListCfg | 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 nil, logx.Error(err) | ||||
} | } | ||||
return &cfgList, nil | return &cfgList, nil | ||||
} | } | ||||
func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetCron() (*[]model.MasterListCfg, error) { | func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetCron() (*[]model.MasterListCfg, error) { | ||||
var cfgList []model.MasterListCfg | 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 nil, logx.Error(err) | ||||
} | } | ||||
return &cfgList, nil | return &cfgList, nil | ||||
} | } | ||||
func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetOneNoDataNoErr(key string) (*model.MasterListCfg, error) { | func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetOneNoDataNoErr(key string) (*model.MasterListCfg, error) { | ||||
var cfgList model.MasterListCfg | var cfgList model.MasterListCfg | ||||
has, err := Db.Where("`k`=?", key).Get(&cfgList) | |||||
has, err := masterListCfgDb.Db.Where("`k`=?", key).Get(&cfgList) | |||||
if err != nil { | if err != nil { | ||||
return nil, logx.Error(err) | 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) { | func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetOne(uid, key string) (*model.MasterListCfg, error) { | ||||
var cfgList model.MasterListCfg | 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 nil, logx.Error(err) | ||||
} | } | ||||
return &cfgList, nil | return &cfgList, nil | ||||
} | } | ||||
func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetOneData(uid, key string) string { | func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetOneData(uid, key string) string { | ||||
var cfgList model.MasterListCfg | 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 "" | ||||
} | } | ||||
return cfgList.V | return cfgList.V | ||||
@@ -60,7 +60,7 @@ func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetOneData(uid, key string) | |||||
func (masterListCfgDb *MasterListCfgDb) MasterListCfgInsert(uid, key, val, memo string) bool { | func (masterListCfgDb *MasterListCfgDb) MasterListCfgInsert(uid, key, val, memo string) bool { | ||||
cfg := model.MasterListCfg{Uid: uid, K: key, V: val, Memo: memo} | cfg := model.MasterListCfg{Uid: uid, K: key, V: val, Memo: memo} | ||||
_, err := Db.InsertOne(&cfg) | |||||
_, err := masterListCfgDb.Db.InsertOne(&cfg) | |||||
if err != nil { | if err != nil { | ||||
logx.Error(err) | logx.Error(err) | ||||
return false | return false | ||||
@@ -70,7 +70,7 @@ func (masterListCfgDb *MasterListCfgDb) MasterListCfgInsert(uid, key, val, memo | |||||
func (masterListCfgDb *MasterListCfgDb) MasterListCfgUpdate(uid, key, val string) bool { | func (masterListCfgDb *MasterListCfgDb) MasterListCfgUpdate(uid, key, val string) bool { | ||||
cfg := model.MasterListCfg{K: key, V: val} | 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 { | if err != nil { | ||||
logx.Error(err) | logx.Error(err) | ||||
return false | return false | ||||
@@ -19,21 +19,21 @@ func (sysCfgDb *SysCfgDb) Set() { // set方法 | |||||
func (sysCfgDb *SysCfgDb) SysCfgGetAll() (*[]model.SysCfg, error) { | func (sysCfgDb *SysCfgDb) SysCfgGetAll() (*[]model.SysCfg, error) { | ||||
var cfgList []model.SysCfg | 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 nil, logx.Error(err) | ||||
} | } | ||||
return &cfgList, nil | return &cfgList, nil | ||||
} | } | ||||
func (sysCfgDb *SysCfgDb) SysCfgGetCron() (*[]model.SysCfg, error) { | func (sysCfgDb *SysCfgDb) SysCfgGetCron() (*[]model.SysCfg, error) { | ||||
var cfgList []model.SysCfg | 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 nil, logx.Error(err) | ||||
} | } | ||||
return &cfgList, nil | return &cfgList, nil | ||||
} | } | ||||
func (sysCfgDb *SysCfgDb) SysCfgGetOneNoDataNoErr(key string) (*model.SysCfg, error) { | func (sysCfgDb *SysCfgDb) SysCfgGetOneNoDataNoErr(key string) (*model.SysCfg, error) { | ||||
var cfgList model.SysCfg | var cfgList model.SysCfg | ||||
has, err := Db.Where("`k`=?", key).Get(&cfgList) | |||||
has, err := sysCfgDb.Db.Where("`k`=?", key).Get(&cfgList) | |||||
if err != nil { | if err != nil { | ||||
return nil, logx.Error(err) | 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) { | func (sysCfgDb *SysCfgDb) SysCfgGetOne(key string) (*model.SysCfg, error) { | ||||
var cfgList model.SysCfg | 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 nil, logx.Error(err) | ||||
} | } | ||||
return &cfgList, nil | return &cfgList, nil | ||||
} | } | ||||
func (sysCfgDb *SysCfgDb) SysCfgGetOneData(key string) string { | func (sysCfgDb *SysCfgDb) SysCfgGetOneData(key string) string { | ||||
var cfgList model.SysCfg | 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 "" | ||||
} | } | ||||
return cfgList.V | return cfgList.V | ||||
@@ -60,7 +60,7 @@ func (sysCfgDb *SysCfgDb) SysCfgGetOneData(key string) string { | |||||
func (sysCfgDb *SysCfgDb) SysCfgInsert(key, val, memo string) bool { | func (sysCfgDb *SysCfgDb) SysCfgInsert(key, val, memo string) bool { | ||||
cfg := model.SysCfg{K: key, V: val, Memo: memo} | cfg := model.SysCfg{K: key, V: val, Memo: memo} | ||||
_, err := Db.InsertOne(&cfg) | |||||
_, err := sysCfgDb.Db.InsertOne(&cfg) | |||||
if err != nil { | if err != nil { | ||||
logx.Error(err) | logx.Error(err) | ||||
return false | return false | ||||
@@ -69,6 +69,7 @@ func reload() { | |||||
func doTask(fnName string) func() { | func doTask(fnName string) func() { | ||||
return func() { | return func() { | ||||
begin := time.Now().Local() | begin := time.Now().Local() | ||||
jobs[fnName]() | |||||
end := time.Now().Local() | end := time.Now().Local() | ||||
logx.Infof( | logx.Infof( | ||||
" AutoTask <%s> started at <%s>, ended at <%s> duration <%s>", | " AutoTask <%s> started at <%s>, ended at <%s> duration <%s>", | ||||
@@ -120,7 +120,7 @@ func PlayletAdvOrderYesterday(hours int, runtimeStr string) { | |||||
"page_size": pageSize, | "page_size": pageSize, | ||||
"page_index": pageNo, | "page_index": pageNo, | ||||
} | } | ||||
count := getVideoOrder(uid, arg) | |||||
count := getAdvOrder(uid, arg) | |||||
if count == 0 { | if count == 0 { | ||||
break | break | ||||
} | } | ||||
@@ -48,7 +48,6 @@ func NewRedis(addr string) { | |||||
Wait: true, | Wait: true, | ||||
Dial: func() (redigo.Conn, error) { | Dial: func() (redigo.Conn, error) { | ||||
c, err := redigo.Dial("tcp", addr, | c, err := redigo.Dial("tcp", addr, | ||||
redigo.DialPassword(redisPassword), | |||||
redigo.DialConnectTimeout(redisDialTTL), | redigo.DialConnectTimeout(redisDialTTL), | ||||
redigo.DialReadTimeout(redisReadTTL), | redigo.DialReadTimeout(redisReadTTL), | ||||
redigo.DialWriteTimeout(redisWriteTTL), | redigo.DialWriteTimeout(redisWriteTTL), | ||||
@@ -5,6 +5,10 @@ local: true | |||||
# 缓存 | # 缓存 | ||||
redis_addr: '120.24.28.6:32572' | redis_addr: '120.24.28.6:32572' | ||||
redis_addr_second: | |||||
addr: '120.24.28.6:32572' | |||||
pwd: '' | |||||
# 数据库 | # 数据库 | ||||
db: | db: | ||||
host: '119.23.182.117:3306' | host: '119.23.182.117:3306' | ||||