Commit 21a02a49 authored by 陈子龙's avatar 陈子龙

Merge branch 'dev-czl' into dev

parents 7a120f6b 996781d8
......@@ -108,6 +108,11 @@ func (r Redis) Exist(key string) (int64, error) {
return r.Conn.Exists(strings.ToUpper(key)).Result()
}
func (r Redis) HExists(key, field string) (bool, error) {
key = fmt.Sprintf("%s-%s", strings.ToUpper(r.Prefix), strings.ToUpper(key))
return r.Conn.HExists(strings.ToUpper(key), strings.ToUpper(field)).Result()
}
func (r Redis) Keys(pattern string) ([]string, error) {
pattern = fmt.Sprintf("%s-%s", strings.ToUpper(r.Prefix), strings.ToUpper(pattern))
return r.Conn.Keys(strings.ToUpper(pattern)).Result()
......
......@@ -142,12 +142,23 @@ func (t *TaskHistorySvc) TaskExecLog(id int) (taskExecLogRes response.TaskExecLo
err = resp.RedisConnectError.ErrorDetail(err1)
return
}
value, err2 := redis.HGet(conf.AutoExecHistory, cast.ToString(id))
//判断key值是否存在
b1, err2 := redis.HExists(conf.AutoExecHistory, cast.ToString(id))
if err2 != nil {
conf.Logger.Error("redis HGet err", zap.Error(err2))
conf.Logger.Error("redis HExists err", zap.Error(err2))
err = resp.RedisExecError.ErrorDetail(err2)
}
if !b1 {
return
}
//获取key
value, err3 := redis.HGet(conf.AutoExecHistory, cast.ToString(id))
if err3 != nil {
conf.Logger.Error("redis HGet err", zap.Error(err3))
err = resp.RedisExecError.ErrorDetail(err3)
return
}
//解析key
var execCache ExecCache
err = json.Unmarshal([]byte(value), &execCache)
if err != nil {
......@@ -155,6 +166,7 @@ func (t *TaskHistorySvc) TaskExecLog(id int) (taskExecLogRes response.TaskExecLo
err = resp.FAIL.WithError(err)
return
}
conf.Logger.Info("redis HGet Log", zap.String("log", execCache.ExecLog))
taskExecLogRes.ExecLog = execCache.ExecLog
taskExecLogRes.ExecEndTime = execCache.ExecEndTime
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment