refactor: db/redis/mongo连接代码包独立

This commit is contained in:
meilin.huang
2023-10-27 17:41:45 +08:00
parent a1303b52eb
commit 12f63ef3dd
45 changed files with 1112 additions and 950 deletions

View File

@@ -10,7 +10,7 @@ import (
)
func (r *Redis) GetListValue(rc *req.Ctx) {
ri, key := r.checkKeyAndGetRedisIns(rc)
ri, key := r.checkKeyAndGetRedisConn(rc)
ctx := context.TODO()
cmdable := ri.GetCmdable()
@@ -34,7 +34,7 @@ func (r *Redis) Lrem(rc *req.Ctx) {
option := new(form.LRemOption)
ginx.BindJsonAndValid(g, option)
cmd := r.getRedisIns(rc).GetCmdable()
cmd := r.getRedisConn(rc).GetCmdable()
res, err := cmd.LRem(context.TODO(), option.Key, int64(option.Count), option.Member).Result()
biz.ErrIsNilAppendErr(err, "lrem失败: %s")
rc.ResData = res
@@ -45,7 +45,7 @@ func (r *Redis) SaveListValue(rc *req.Ctx) {
listValue := new(form.ListValue)
ginx.BindJsonAndValid(g, listValue)
cmd := r.getRedisIns(rc).GetCmdable()
cmd := r.getRedisConn(rc).GetCmdable()
key := listValue.Key
ctx := context.TODO()
@@ -59,7 +59,7 @@ func (r *Redis) SetListValue(rc *req.Ctx) {
listSetValue := new(form.ListSetValue)
ginx.BindJsonAndValid(g, listSetValue)
ri := r.getRedisIns(rc)
ri := r.getRedisConn(rc)
_, err := ri.GetCmdable().LSet(context.TODO(), listSetValue.Key, listSetValue.Index, listSetValue.Value).Result()
biz.ErrIsNilAppendErr(err, "list set失败: %s")