94 lines
2.1 KiB
Go
94 lines
2.1 KiB
Go
package req
|
|
|
|
import (
|
|
"reflect"
|
|
|
|
"git.fsdpf.net/go/db"
|
|
"git.fsdpf.net/go/db/schema"
|
|
)
|
|
|
|
type ResDataType string
|
|
type ResAuthDB int
|
|
|
|
const (
|
|
// 关闭权限过滤
|
|
ResAuthOff ResAuthDB = iota
|
|
// 开启权限过滤, 不包括关联资源
|
|
ResAuthOn
|
|
// 开启权限过滤, 包括关联资源
|
|
ResAuthAll
|
|
)
|
|
|
|
const (
|
|
ResString ResDataType = "string"
|
|
ResText ResDataType = "text"
|
|
ResInteger ResDataType = "integer"
|
|
ResSmallInteger ResDataType = "smallInteger"
|
|
ResDecimal ResDataType = "decimal"
|
|
ResBoolean ResDataType = "boolean"
|
|
ResJson ResDataType = "json"
|
|
ResEnum ResDataType = "enum"
|
|
ResTimestamp ResDataType = "timestamp"
|
|
ResDate ResDataType = "date"
|
|
ResDatetime ResDataType = "dateTime"
|
|
)
|
|
|
|
const (
|
|
IsExpr byte = 1 << iota
|
|
IsOmitempty
|
|
Ignored
|
|
)
|
|
|
|
type Resource interface {
|
|
GetUuid() string
|
|
GetName() string
|
|
GetCode() string
|
|
GetPrimarykey() string
|
|
GetFields() []ResField
|
|
GetField(string) (ResField, bool)
|
|
HasField(string) bool
|
|
|
|
BeginTransaction() (*db.Transaction, error)
|
|
|
|
GetTable() db.Expression
|
|
GetDBConn() *db.Connection
|
|
GetDBBuilder() *db.Builder
|
|
GetDBTable(params ...any) *db.Builder
|
|
GetAuthDBTable(u User, params ...any) *db.Builder
|
|
GetStruct(extends ...reflect.StructField) any
|
|
GetSliceStruct(extends ...reflect.StructField) any
|
|
|
|
WithRolesCondition(b *db.Builder, t string, u User) error
|
|
|
|
// 是否虚拟资源
|
|
IsVirtual() bool
|
|
// 是否系统资源
|
|
IsSystem() bool
|
|
}
|
|
|
|
type ResField interface {
|
|
GetName() string
|
|
GetCode() string
|
|
GetCodeResource() string
|
|
GetDataType() ResDataType
|
|
GetQueryDataType() RouteParamType
|
|
GetRawDefault(driver string) db.Expression
|
|
ToStructField(tags ...string) reflect.StructField
|
|
ToValue(any) any
|
|
ToBlueprint(table *schema.Blueprint) *schema.ColumnDefinition
|
|
ToQueryField(t RouteParamType, alias string, options byte) QueryField
|
|
}
|
|
|
|
type QueryField interface {
|
|
ResField
|
|
Type() RouteParamType
|
|
Alias() string
|
|
GetCodeOrAlias() string
|
|
IsExpr() bool
|
|
IsOmitempty() bool
|
|
Ignored() bool
|
|
SetOptions(byte) QueryField
|
|
ToSql() db.Expression
|
|
ToStructField(tags ...string) reflect.StructField
|
|
}
|