Documentation ¶
Index ¶
- Variables
- func GetSchema(table any, db *gorm.DB) *schema.Schema
- func ToJsonSchema[T any](origin T, omitFields ...string) *jsonschema.Schema
- type ContextValueInject
- type GormModelDelConfig
- type GormModelPutConfig
- type GormQueryParseConfig
- type GormSchemaRest
- func (s *GormSchemaRest[T]) AddQueryContextInject(q ContextValueInject)
- func (s *GormSchemaRest[T]) AddQueryFilterInject(fl *ut.Kov)
- func (s *GormSchemaRest[T]) GetBase() SchemaBase
- func (s *GormSchemaRest[T]) GetSelf() *GormSchemaRest[T]
- func (s *GormSchemaRest[T]) MarshalJSON() ([]byte, error)
- func (s *GormSchemaRest[T]) ParseInject(ctx iris.Context) ([]*ut.Kov, error)
- func (s *GormSchemaRest[T]) Registry(p iris.Party)
- func (s *GormSchemaRest[T]) SetFilterCanPass(...)
- func (s *GormSchemaRest[T]) SetRaw(raw any)
- func (s *GormSchemaRest[T]) SetSchema(mode ISchemaMode, schema *jsonschema.Schema)
- func (s *GormSchemaRest[T]) SetSchemaRaw(mode ISchemaMode, raw any)
- type ISchemaMode
- type ManySchema
- type SchemaAllowMethods
- func (c *SchemaAllowMethods) ChangeDelete(status bool)
- func (c *SchemaAllowMethods) ChangeGetAll(status bool)
- func (c *SchemaAllowMethods) ChangeGetSingle(status bool)
- func (c *SchemaAllowMethods) ChangePost(status bool)
- func (c *SchemaAllowMethods) ChangePut(status bool)
- func (c *SchemaAllowMethods) OnlyGet(status bool)
- type SchemaBase
Constants ¶
This section is empty.
Variables ¶
View Source
var (
// GormIdKey 模型定义中的id字段的json标签名
GormIdKey = "id"
)
Functions ¶
func ToJsonSchema ¶
func ToJsonSchema[T any](origin T, omitFields ...string) *jsonschema.Schema
ToJsonSchema 把一个struct转换为jsonschema 在后台的前端ui-schema中不支持patternProperties 也就是说不支持map[string]any的写法 omitFields 是需要跳过的字段名 是struct的字段名
Types ¶
type ContextValueInject ¶
type GormModelDelConfig ¶
type GormModelPutConfig ¶
type GormModelPutConfig struct { QueryFilter *ut.QueryFull `json:"query_filter,omitempty"` DropKeys []string `json:"drop_keys,omitempty"` // 最后的diff还需要丢弃的key RowId string `json:"row_id,omitempty"` // 字符串也没事 mysql会自动把id转换为int UpdateTime bool `json:"update_time,omitempty"` UpdateForce bool `json:"update_force,omitempty"` // 强行覆盖 BodyMap map[string]any `json:"body_map,omitempty"` }
type GormQueryParseConfig ¶
type GormSchemaRest ¶
type GormSchemaRest[T any] struct { SchemaBase Schemas ManySchema `json:"schemas"` AllowMethods *SchemaAllowMethods `json:"allow_methods"` GetHandlerConfig GormQueryParseConfig PostHandlerConfig ut.ModelCtxMapperPack PutHandlerConfig GormModelPutConfig DeleteHandlerConfig GormModelDelConfig RaiseRawError bool WriteInsert bool `json:"write_insert,omitempty"` // 是否把注入内容写入新增体 PostMustKeys []string `json:"post_must_keys,omitempty"` // 新增时候必须存在的key 以json tag为准 // contains filtered or unexported fields }
func NewGormSchemaRest ¶
func NewGormSchemaRest[T any](raw T, db *gorm.DB) *GormSchemaRest[T]
func (*GormSchemaRest[T]) AddQueryContextInject ¶
func (s *GormSchemaRest[T]) AddQueryContextInject(q ContextValueInject)
func (*GormSchemaRest[T]) AddQueryFilterInject ¶
func (s *GormSchemaRest[T]) AddQueryFilterInject(fl *ut.Kov)
func (*GormSchemaRest[T]) GetBase ¶
func (s *GormSchemaRest[T]) GetBase() SchemaBase
func (*GormSchemaRest[T]) GetSelf ¶
func (s *GormSchemaRest[T]) GetSelf() *GormSchemaRest[T]
func (*GormSchemaRest[T]) MarshalJSON ¶
func (s *GormSchemaRest[T]) MarshalJSON() ([]byte, error)
func (*GormSchemaRest[T]) ParseInject ¶
func (s *GormSchemaRest[T]) ParseInject(ctx iris.Context) ([]*ut.Kov, error)
func (*GormSchemaRest[T]) Registry ¶
func (s *GormSchemaRest[T]) Registry(p iris.Party)
func (*GormSchemaRest[T]) SetFilterCanPass ¶
func (s *GormSchemaRest[T]) SetFilterCanPass(filterCanPass func(ctx iris.Context, self *GormSchemaRest[T], query *ut.QueryFull) error)
func (*GormSchemaRest[T]) SetRaw ¶
func (s *GormSchemaRest[T]) SetRaw(raw any)
func (*GormSchemaRest[T]) SetSchema ¶
func (s *GormSchemaRest[T]) SetSchema(mode ISchemaMode, schema *jsonschema.Schema)
func (*GormSchemaRest[T]) SetSchemaRaw ¶
func (s *GormSchemaRest[T]) SetSchemaRaw(mode ISchemaMode, raw any)
type ISchemaMode ¶
type ISchemaMode int
const ( SchemaModeAdd ISchemaMode = iota SchemaModeEdit SchemaModeTable SchemaModeDelete )
type ManySchema ¶
type ManySchema struct { Table *jsonschema.Schema `json:"table"` Edit *jsonschema.Schema `json:"edit"` Add *jsonschema.Schema `json:"add"` Delete *jsonschema.Schema `json:"delete"` }
type SchemaAllowMethods ¶
type SchemaAllowMethods struct { GetAll bool `json:"get_all"` GetSingle bool `json:"get_single"` Post bool `json:"post"` Put bool `json:"put"` Delete bool `json:"delete"` }
func (*SchemaAllowMethods) ChangeDelete ¶
func (c *SchemaAllowMethods) ChangeDelete(status bool)
func (*SchemaAllowMethods) ChangeGetAll ¶
func (c *SchemaAllowMethods) ChangeGetAll(status bool)
func (*SchemaAllowMethods) ChangeGetSingle ¶
func (c *SchemaAllowMethods) ChangeGetSingle(status bool)
func (*SchemaAllowMethods) ChangePost ¶
func (c *SchemaAllowMethods) ChangePost(status bool)
func (*SchemaAllowMethods) ChangePut ¶
func (c *SchemaAllowMethods) ChangePut(status bool)
func (*SchemaAllowMethods) OnlyGet ¶
func (c *SchemaAllowMethods) OnlyGet(status bool)
type SchemaBase ¶
type SchemaBase struct { Group string `json:"group,omitempty"` // 组名 Priority int `json:"priority,omitempty"` // 在组下显示的优先级 越大越优先 TableName string `json:"table_name,omitempty"` // 表名 虽然没用到 UniqueId string `json:"unique_id,omitempty"` // 唯一ID 默认生成sonyflakeId PathId string `json:"path_id,omitempty"` // 路径ID 默认取party的最后一个路径 RawName string `json:"raw_name,omitempty"` // 原始名称 Alias string `json:"alias,omitempty"` // 别名 中文名 }
Click to show internal directories.
Click to hide internal directories.