query_parser

package
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeOR      = "OR"
	TypeAND     = "AND"
	TypeBetween = "BETWEEN"
)

Variables

This section is empty.

Functions

func Check

func Check(qItems []QueryItem, funcMap map[string]func(item QueryItem) (bool, string)) (bool, string)

Types

type QueryItem

type QueryItem struct {
	Key    string
	Values []string
	Type   string
}

func ParseString

func ParseString(s string, allowKeyItem ...string) []QueryItem

ParseString 将查询字符串解析为 []QueryItem

首先使用 ~ 进行分割 产生四组 query string 然后使用 . 进行分割 将 query string 转化成 query slice, 此时 key = query[0], 如果 query[len(query) - 1] 是 Type 关键字 (OR, AND, BETWEEN) 则赋值为 Type 否则 默认使用 OR 最后使用 + 分割 values, 注意如果 Type = BETWEEN 则 len(values) == 2 否则记为无效, 同时由于 + 是 http query 的保留关键词,用于替换 空格 的场景, 需要上层自行处理

func (*QueryItem) GetBetweenValues

func (q *QueryItem) GetBetweenValues() []string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL