res_field.go/res_field_option.go(字段定义)、res_query_field.go/res_query_field_option.go(查询字段)、res_change_row.go(变更行)、res_mask_field.go(字段脱敏标记)及对应测试文件,配合此前已提交的 resource.go/res_interceptor.go 组成完整的 resx 资源实现包。
33 lines
772 B
Go
33 lines
772 B
Go
package resx
|
|
|
|
// QueryFieldOption 定义查询字段的选项函数类型。
|
|
type QueryFieldOption func(*QueryField)
|
|
|
|
// WithAlias 设置查询字段的别名。
|
|
func WithAlias(alias string) QueryFieldOption {
|
|
return func(qf *QueryField) {
|
|
qf.alias = alias
|
|
}
|
|
}
|
|
|
|
// WithIsExpr 设置查询字段是否为表达式。
|
|
func WithIsExpr(isExpr bool) QueryFieldOption {
|
|
return func(qf *QueryField) {
|
|
qf.isExpr = isExpr
|
|
}
|
|
}
|
|
|
|
// WithOmitEmpty 设置查询字段是否在为空时忽略。
|
|
func WithOmitEmpty(isOmitempty bool) QueryFieldOption {
|
|
return func(qf *QueryField) {
|
|
qf.isOmitempty = isOmitempty
|
|
}
|
|
}
|
|
|
|
// WithIgnore 设置查询字段是否被忽略。
|
|
func WithIgnore(ignored bool) QueryFieldOption {
|
|
return func(qf *QueryField) {
|
|
qf.ignored = ignored
|
|
}
|
|
}
|