Documentation ¶
Index ¶
- Constants
- func DereferenceInterface(v interface{}) interface{}
- func DereferenceType(t reflect.Type) reflect.Type
- func DereferenceValue(v reflect.Value) reflect.Value
- func Eval(s *Structs, db *gorm.DB, f *structs.Field, exp string) error
- func FormatQryField(field *structs.Field) string
- func GetSub(s string, sub string) string
- func Getter(s *Structs, param map[string]interface{}, db *gorm.DB, c Context) error
- func HasRegister(name string) bool
- func RegisterFunc(name string, func1 govaluate.ExpressionFunction)
- func RegisterType(v interface{})
- func SetMode(value string)
- func Setter(s *Structs, param map[string]interface{}, db *gorm.DB, c Context) error
- func ToCamel(s string) string
- type API
- type CRUDInterface
- type Context
- type CrudResult
- type FieldTypeAndKind
- type KK
- func (kk *KK) And(q *QueryParam) *KK
- func (kk *KK) GormQueryExpr(expr interface{}) interface{}
- func (kk *KK) Join(model interface{}, on *OnJoin) *KK
- func (kk *KK) LeftJoin(model interface{}, on *OnJoin) *KK
- func (kk *KK) Model(value interface{}) *KK
- func (kk *KK) Or(q *QueryParam) *KK
- func (kk *KK) Order(value interface{}, reorder ...bool) *KK
- func (kk *KK) Page(page *Page) *KK
- func (kk *KK) Rds(args ...interface{}) *KK
- func (kk *KK) RightJoin(model interface{}, on *OnJoin) *KK
- func (kk *KK) Select(value interface{}) *KK
- func (kk *KK) Set(dst, given interface{}) *KK
- func (kk *KK) Verify(success bool, err string) *KK
- func (kk *KK) Where(q *QueryParam) *KK
- type LocalCrud
- type OnJoin
- type Page
- type QueryParam
- func (q *QueryParam) AND(model interface{}, field string, values ...interface{}) *QueryParam
- func (q *QueryParam) And(field string, values ...interface{}) *QueryParam
- func (q *QueryParam) OR(model interface{}, field string, values ...interface{}) *QueryParam
- func (q *QueryParam) Or(field string, values ...interface{}) *QueryParam
- type RPC
- type RPCCrud
- type Resource
- type Result
- type SearchCondition
- type StructFieldInfo
- type Structs
- func (s *Structs) CallMethod(name string, values ...reflect.Value) []reflect.Value
- func (s *Structs) Copy(src *Structs)
- func (s *Structs) GetRelationsWithModel(fieldname string, modelName string) (fi StructFieldInfo, err error)
- func (s *Structs) New() *Structs
- func (s *Structs) ParseFormValues(values url.Values) error
- func (s *Structs) Raw() interface{}
- func (s *Structs) SetFieldValue(f *structs.Field, value interface{}) error
- func (s *Structs) SetValue(values map[string]interface{}) error
- type SuccessCallback
- type TimeAsString
Constants ¶
const ( // DebugMode indicates kitty mode is debug. DebugMode = "debug" // ReleaseMode indicates kitty mode is release. ReleaseMode = "release" // TestMode indicates kitty mode is test. TestMode = "test" )
const EnvKittyMode = "KITTY_MODE"
EnvKittyMode indicates environment name for kitty mode.
Variables ¶
This section is empty.
Functions ¶
func DereferenceInterface ¶
func DereferenceInterface(v interface{}) interface{}
DereferenceInterface ...
func DereferenceType ¶
DereferenceType dereference, get the underlying non-pointer type.
func DereferenceValue ¶
DereferenceValue dereference and unpack interface, get the underlying non-pointer and non-interface value.
func RegisterFunc ¶
func RegisterFunc(name string, func1 govaluate.ExpressionFunction)
RegisterFunc ...
Types ¶
type API ¶
type API struct { Form url.Values Crud CRUDInterface Ctx Context Params map[string]interface{} }
API for web api
type CRUDInterface ¶
type CRUDInterface interface {
Do(*SearchCondition, string, Context) (interface{}, error)
}
CRUDInterface ...
type CrudResult ¶
type CrudResult struct { Code int `json:"code"` Data interface{} `json:"data,omitempty"` Count *int `json:"count,omitempty"` Message string `json:"message,omitempty"` Ref int64 `json:"ref,omitempty"` }
CrudResult 结果
type FieldTypeAndKind ¶
type FieldTypeAndKind struct { ModelName string //模型名称 KindOfField reflect.Kind //类型 struct TypeOfField reflect.Type //类型 // contains filtered or unexported fields }
FieldTypeAndKind 字段类型,模型名称
type KK ¶
type KK struct { Error error // contains filtered or unexported fields }
func (*KK) And ¶
func (kk *KK) And(q *QueryParam) *KK
func (*KK) GormQueryExpr ¶
func (kk *KK) GormQueryExpr(expr interface{}) interface{}
func (*KK) Or ¶
func (kk *KK) Or(q *QueryParam) *KK
func (*KK) Rds ¶
kk.Model().Select().Rds(&field,"id=?",user.id) kk.Select("Count(*)").Rds(&field) kk.Select("Sum(money)").Rds(&field) kk.Page().Rds(&field,kk.GormQueryExpr())
func (*KK) Where ¶
func (kk *KK) Where(q *QueryParam) *KK
type LocalCrud ¶
type LocalCrud struct { Model string // RPC 最终会调用此,所以只能用model作为参数。 Strs *Structs DB *gorm.DB Callbk SuccessCallback RPC RPC }
LocalCrud 本地操作
type OnJoin ¶
type OnJoin struct {
// contains filtered or unexported fields
}
func (*OnJoin) And ¶
func (on *OnJoin) And(q *QueryParam) *OnJoin
type Page ¶
type Page struct { Page uint32 `json:"page"` Limit uint32 `json:"limit"` PageMax uint32 `json:"page_max"` Total uint32 `json:"total"` }
Page 分页
type QueryParam ¶
type QueryParam struct {
// contains filtered or unexported fields
}
func Param ¶
func Param(model interface{}, field string, values ...interface{}) *QueryParam
func (*QueryParam) AND ¶
func (q *QueryParam) AND(model interface{}, field string, values ...interface{}) *QueryParam
func (*QueryParam) And ¶
func (q *QueryParam) And(field string, values ...interface{}) *QueryParam
func (*QueryParam) OR ¶
func (q *QueryParam) OR(model interface{}, field string, values ...interface{}) *QueryParam
func (*QueryParam) Or ¶
func (q *QueryParam) Or(field string, values ...interface{}) *QueryParam
type RPC ¶
type RPC interface { Call(*SearchCondition, string, Context) (interface{}, error) WebCall(*Structs, *SearchCondition, Context) error }
RPC rpc call
type Result ¶
type Result struct { CrudResult NameAs map[string][]string `json:"-"` Cfg jsoniter.API }
Result 。
type SearchCondition ¶
type SearchCondition struct { FormValues map[string][]string `json:"form_values,omitempty"` Page *Page `json:"page,omitempty"` ReturnCount int `json:"return_count,omitempty"` Params map[string]interface{} `json:"params,omitempty"` }
SearchCondition ...
type StructFieldInfo ¶
type StructFieldInfo struct { TypeKind FieldTypeAndKind ForeignKey string //外键 AssociationForeignkey string //关联外键 Relationship string //belongs_to has_one has_many }
StructFieldInfo 结构体信息
type Structs ¶
Structs .
func (*Structs) CallMethod ¶
CallMethod .
func (*Structs) GetRelationsWithModel ¶
func (s *Structs) GetRelationsWithModel(fieldname string, modelName string) (fi StructFieldInfo, err error)
GetRelationsWithModel fieldname (elem) must struct -> email = user
func (*Structs) ParseFormValues ¶
ParseFormValues form_value -> struct
func (*Structs) SetFieldValue ¶
SetFieldValue ...
type SuccessCallback ¶
SuccessCallback 执行成功后,回调。返回error后,回滚事务
type TimeAsString ¶
type TimeAsString struct {
// contains filtered or unexported fields
}
TimeAsString format time.Time as string
func (*TimeAsString) Decode ¶
func (codec *TimeAsString) Decode(ptr unsafe.Pointer, iter *jsoniter.Iterator)
Decode string to time.Time