Documentation
¶
Index ¶
- func DefaultLimit(limit int) int
- func JSONToMarkdown(data interface{}) (string, error)
- func RegisterCustomValidations(v *validator.Validate) error
- func ValidateRegex(fl validator.FieldLevel) bool
- type Filter
- type FilterOperator
- type QueryOption
- func WithArchived(archived int64) QueryOption
- func WithCode(code string) QueryOption
- func WithFilters(filters ...Filter) QueryOption
- func WithId(id int64) QueryOption
- func WithMcId(mcId int64) QueryOption
- func WithName(name string) QueryOption
- func WithPhone(phone string) QueryOption
- func WithStatus(status int64) QueryOption
- func WithTitle(title string) QueryOption
- func WithType(t int64) QueryOption
- func WithUserId(uid int64) QueryOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JSONToMarkdown ¶
JSONToMarkdown 把任意对象序列化为 JSON 字符串,并包裹 ```json 标记
func RegisterCustomValidations ¶ added in v0.1.3
RegisterCustomValidations 注册自定义校验规则(customRegex)
func ValidateRegex ¶
func ValidateRegex(fl validator.FieldLevel) bool
ValidateRegex 自定义正则验证函数(标签为"customRegex")
Types ¶
type Filter ¶
type Filter struct {
Field string
Value interface{}
Operator FilterOperator
}
Filter 定义过滤器结构体
type FilterOperator ¶
type FilterOperator string
FilterOperator 定义过滤器操作符类型
const ( OpEqual FilterOperator = "=" OpLike FilterOperator = "LIKE" OpGt FilterOperator = ">" OpLt FilterOperator = "<" OpGte FilterOperator = ">=" OpLte FilterOperator = "<=" OpIn FilterOperator = "IN" OpNotIn FilterOperator = "NOT IN" )
type QueryOption ¶
QueryOption 定义查询选项函数类型
func WithArchived ¶
func WithArchived(archived int64) QueryOption
func WithCode ¶
func WithCode(code string) QueryOption
func WithFilters ¶
func WithFilters(filters ...Filter) QueryOption
WithFilters 支持多种条件查询(包括LIKE).
安全约束:
- Field 必须是简单标识符,否则 fail-closed(WHERE 1 = 0);
- Value 始终参数化;LIKE 的 %/_ 会被转义;
- 未知 Operator 不再静默按 "=" 处理,而是 fail-closed 并通过 *gorm.DB 返回错误.
func WithMcId ¶
func WithMcId(mcId int64) QueryOption
func WithName ¶
func WithName(name string) QueryOption
func WithStatus ¶
func WithStatus(status int64) QueryOption
func WithTitle ¶
func WithTitle(title string) QueryOption
func WithType ¶
func WithType(t int64) QueryOption
func WithUserId ¶
func WithUserId(uid int64) QueryOption
Click to show internal directories.
Click to hide internal directories.