feat: redis支持flushdb、菜单资源支持拖拽排序、禁用等

This commit is contained in:
meilin.huang
2023-06-15 19:18:29 +08:00
parent 445cf3716b
commit adc65439e4
26 changed files with 634 additions and 407 deletions

View File

@@ -52,6 +52,7 @@ func (r *Redis) Hset(rc *req.Ctx) {
g := rc.GinCtx
hashValue := new(form.HashValue)
ginx.BindJsonAndValid(g, hashValue)
rc.ReqParam = hashValue
hv := hashValue.Value[0]
res, err := r.getRedisIns(rc).GetCmdable().HSet(context.TODO(), hashValue.Key, hv["field"].(string), hv["value"]).Result()

View File

@@ -148,7 +148,7 @@ func (r *Redis) Scan(rc *req.Ctx) {
func (r *Redis) TtlKey(rc *req.Ctx) {
ri, key := r.checkKeyAndGetRedisIns(rc)
ttl, err := ri.GetCmdable().TTL(context.Background(), key).Result()
biz.ErrIsNil(err, "ttl失败: %s")
biz.ErrIsNilAppendErr(err, "ttl失败: %s")
if ttl == -1 {
rc.ResData = -1
@@ -187,3 +187,10 @@ func (r *Redis) PersistKey(rc *req.Ctx) {
rc.ReqParam = fmt.Sprintf("%s -> 移除key[%s]的过期时间", ri.Info.GetLogDesc(), key)
ri.GetCmdable().Persist(context.Background(), key)
}
// 清空库
func (r *Redis) FlushDb(rc *req.Ctx) {
ri := r.getRedisIns(rc)
rc.ReqParam = fmt.Sprintf("%s -> flushdb", ri.Info.GetLogDesc())
ri.GetCmdable().FlushDB(context.Background())
}

View File

@@ -91,6 +91,14 @@ func InitRedisRouter(router *gin.RouterGroup) {
Handle(rs.PersistKey)
})
flushDbL := req.NewLogInfo("redis-flushdb").WithSave(true)
redis.DELETE(":id/:db/flushdb", func(c *gin.Context) {
req.NewCtxWithGin(c).
WithLog(flushDbL).
WithRequiredPermission(saveDataP).
Handle(rs.FlushDb)
})
// 获取string类型值
redis.GET(":id/:db/string-value", func(c *gin.Context) {
req.NewCtxWithGin(c).Handle(rs.GetStringValue)