fix bug of grid condition process
This commit is contained in:
parent
4ee836c70f
commit
151f7f22c5
|
|
@ -10,23 +10,39 @@ import (
|
|||
"modelRT/diagram"
|
||||
|
||||
"github.com/RediSearch/redisearch-go/redisearch"
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
// RedisSearch define func of redis search by input string
|
||||
func RedisSearch(ctx context.Context, input string) ([]string, error) {
|
||||
var rdb redis.Client
|
||||
rdb := diagram.GetRedisClientInstance()
|
||||
|
||||
if input == "" {
|
||||
// 返回所有 grid 名
|
||||
return getAllGridKeys(ctx, constants.RedisAllGridSetKey)
|
||||
}
|
||||
|
||||
// 处理 input 不为空但是不含有.的情况
|
||||
if strings.Contains(input, ".") == false {
|
||||
gridExist, err := rdb.SIsMember(ctx, constants.RedisAllGridSetKey, input).Result()
|
||||
// TODO 处理err
|
||||
fmt.Println(gridExist, err)
|
||||
|
||||
// TODO 判断input是否为一个完整的层级
|
||||
// 处理 input 不为空、不含有.并且 input 是一个完整的 grid key 的情况
|
||||
if strings.HasSuffix(input, ".") == false && gridExist {
|
||||
return []string{"."}, nil
|
||||
}
|
||||
|
||||
// 处理 input 不为空并且以.结尾的情况
|
||||
if strings.HasSuffix(input, ".") == true {
|
||||
setKey := fmt.Sprintf(constants.RedisSpecGridZoneSetKey, input)
|
||||
return getSpecificZoneKeys(ctx, setKey)
|
||||
}
|
||||
|
||||
// // 处理 input 不为空、不含有.并且 input 是一个完整的 grid key 的情况
|
||||
// if strings.HasSuffix(input, ".") == false && gridExist {
|
||||
// setKey := fmt.Sprintf(constants.RedisSpecGridZoneSetKey, input)
|
||||
// return getSpecificZoneKeys(ctx, setKey)
|
||||
// }
|
||||
|
||||
// TODO 默认每次传递的带有.的前缀字符串一定正确
|
||||
if strings.HasSuffix(input, ".") {
|
||||
// TODO 首先判断.后是否为空字符串,为空则返回上次层级下的所有key
|
||||
|
|
|
|||
Loading…
Reference in New Issue