Documentation ¶
Index ¶
- Variables
- func AbortIfError(c *gin.Context, err error) bool
- func AbortWithError(c *gin.Context, err error)
- func CheckModelPermissions(c *gin.Context, modelVal reflect.Value, modelSchema *schema.Schema, ...) message.Message
- func CheckQueryRelation(relName string, query *gorm.DB) []string
- func CheckRelatedModel(db *gorm.DB, model any, label string, field string, where string, ...) []string
- func CheckRelations(c *gin.Context, db *gorm.DB, id interface{}, relations ...Relation) message.Message
- func CheckUnique(c *gin.Context, db *gorm.DB, model interface{}, primary string, ...) message.Message
- func Count(count *int64) func(*gorm.DB) *gorm.DB
- func CreateModel(c *gin.Context, info *ModelInfo, slice bool) (reflect.Type, message.Message)
- func CreateToDb(c *gin.Context, db *gorm.DB, model interface{}, args ...string)
- func DeleteFile(pathFunc, nameFunc func(*gin.Context) string) func(*gin.Context)
- func DeleteFromDb(c *gin.Context, models []any)
- func DeleteModels(db *gorm.DB, models interface{}) (err error)
- func DeleteRelations(c *gin.Context, db *gorm.DB, modelVal reflect.Value, ...) error
- func DynamicQuery(c *gin.Context, info *ModelInfo, conditions *params.Conditions) func(*gorm.DB) *gorm.DB
- func ErrorsToMsg(c *gin.Context, errors []string) message.Message
- func ExposeSQLErr(c *gin.Context, err error) error
- func FieldToString(c *gin.Context, field *schema.Field) string
- func FileSystem(ctrl AddRouter, apiPath string, filePath func(c *gin.Context) string, ...)
- func FirstLower(str string) string
- func Folder(pathFunc func(*gin.Context) string) func(*gin.Context)
- func GetFile(pathFunc, nameFunc func(*gin.Context) string) func(*gin.Context)
- func GetLimit(pagStart, pagEnd string) int
- func GetMapKeys(mapToFlatten map[string]interface{}) []string
- func GetModelInfo(c *gin.Context, modelSchema *schema.Schema, selects string, ...) message.Message
- func GetOffset(pagStart string) int
- func GetPathParams(c *gin.Context, model interface{}, fields []string, destination interface{})
- func GetPrimary(model interface{}) (int, error)
- func GetPrimaryFields(modelType reflect.Type) []string
- func GetPrimaryName(model interface{}) (string, error)
- func GetRelations(c *gin.Context) []string
- func HandleComputedFields(c *gin.Context, computedFields map[string]string, data reflect.Value)
- func HandleGet(c *gin.Context, db *gorm.DB, primaries map[string]interface{}, model any)
- func JoinRelations(c *gin.Context, d *gorm.DB, config QueryMapConfig, modelInfo *ModelInfo, ...)
- func LoadAndValidateMap(c *gin.Context, jsonData []byte, jsonMap map[string]interface{}, ...)
- func LoadAndValidateMaps(c *gin.Context, jsonData []byte, jsonMaps *[]map[string]interface{}, ...)
- func LoadForeignKeys(db *gorm.DB, modelVal reflect.Value, modelSchema *schema.Schema)
- func LoadModel(c *gin.Context, jsonData []byte, model interface{})
- func ModelToTableNames(stmt *string, modelSchema *schema.Schema) []string
- func Paginate(pagStart, pagEnd string) func(*gorm.DB) *gorm.DB
- func ParseOrder(c *gin.Context, order string, info *ModelInfo) message.Message
- func PathParamsToModels(c *gin.Context, modelType reflect.Type, fields []string, ...)
- func PostFile(pathFunc func(*gin.Context) string) func(*gin.Context)
- func QueryMap(c *gin.Context, db *gorm.DB, args *QueryMapArgs, config QueryMapConfig) error
- func QueryMapRecursive(c *gin.Context, db *gorm.DB, args *QueryMapArgs, config QueryMapConfig, ...) error
- func Recover(c *gin.Context)
- func RecoverIfEnabled(c *gin.Context)
- func Register(container *gin.RouterGroup, toRegister string, r CRUDSController) *gin.RouterGroup
- func RelationsFromModelInfo(mdl *ModelInfo, otherRelations map[string]*params.Conditions) map[string]*params.Conditions
- func RemoveParentPaths(path string) string
- func SentenceCase(fieldName string) string
- func SetPrimary(model interface{}, value int) error
- func ShouldPaginate(pagStart, pagEnd string) bool
- func SnakeToCamelCase(snakeCase string) string
- func StrLen(text *string) int
- func UpdateToDb(c *gin.Context, model interface{}, values any)
- func UpperSnakeCase(str string) string
- func ValidateMap(c *gin.Context, jsonMap map[string]interface{}, modelType reflect.Type) []error
- func ValidateMaps(c *gin.Context, jsonMaps []map[string]interface{}, modelType reflect.Type) error
- func ValidateMapsPrimaries(c *gin.Context, jsonMaps []map[string]interface{}, primaryKeys []string)
- func ValidateModel(c *gin.Context, model interface{})
- func ValidateModels(c *gin.Context, models interface{})
- func ValidateStruct(c *gin.Context, mdl interface{}) error
- func WriteDataWithCount(c *gin.Context, pagStart, pagEnd string, data any, count int64)
- func WriteQueryMapResult(c *gin.Context, args *QueryMapArgs)
- type AbortWithErrorHook
- type AddRouter
- type CRUDSController
- type Controller
- func (r Controller) AddCustomRoutes()
- func (r *Controller) AddRoute(method string, name string, permissionsFunc model.PermissionFunc, ...)
- func (r Controller) AdditionalModels() []reflect.Type
- func (r *Controller) CanImport() bool
- func (r Controller) Delete(c *gin.Context)
- func (r Controller) Get(c *gin.Context)
- func (r Controller) GetEndpoint() string
- func (r Controller) GetEndpointPath() string
- func (r Controller) GetModel() interface{}
- func (r Controller) GetModelType() reflect.Type
- func (r Controller) GetOne(c *gin.Context)
- func (r Controller) GetRelStructure(c *gin.Context)
- func (r Controller) GetRoutes() []Route
- func (r Controller) GetStructure(c *gin.Context)
- func (r Controller) NewModel() interface{}
- func (r Controller) NewSliceOfModel() interface{}
- func (r Controller) Patch(c *gin.Context)
- func (r Controller) PatchMany(c *gin.Context)
- func (r Controller) Post(c *gin.Context)
- func (r *Controller) SetBasePath(basePath string)
- func (r *Controller) SetEndpointIfAbsent(name string)
- type ControllerHooks
- type DynamicModel
- type ErrorValidation
- type FieldInfo
- type FileSystemPermissions
- type GetModeler
- type MSSqlError
- type ModelInfo
- type NestedModel
- type OnRecoverHook
- type QueryMapArgs
- type QueryMapConfig
- type Relation
- type RelationInfo
- type Response
- type Route
- type StructInfo
Constants ¶
This section is empty.
Variables ¶
View Source
var ByModel = map[string]CRUDSController{}
View Source
var ByName = map[string]CRUDSController{}
View Source
var EnableRecover bool
View Source
var Hooks = ControllerHooks{}
Functions ¶
func AbortWithError ¶
func CheckModelPermissions ¶
func CheckRelatedModel ¶
func CheckRelations ¶
func CheckRelations(c *gin.Context, db *gorm.DB, id interface{}, relations ...Relation) message.Message
CheckRelations checks if the resource can be deleted. This method verifies whether the resource to be deleted has been used in any other user-provided relationships. If the resource is in use, it returns the controllers that use the resource; otherwise, it returns nothing in case of success.
func CheckUnique ¶
func CheckUnique(c *gin.Context, db *gorm.DB, model interface{}, primary string, fields []string) message.Message
CheckUnique performs a uniqueness check on a specific resource.
func CreateModel ¶
func DeleteFromDb ¶
func DeleteModels ¶
func DeleteRelations ¶
func DynamicQuery ¶
func FileSystem ¶
func FirstLower ¶
func GetMapKeys ¶
func GetModelInfo ¶
func GetPathParams ¶
func GetPrimary ¶
func GetPrimaryFields ¶
func GetPrimaryName ¶
func GetRelations ¶
func HandleComputedFields ¶
func JoinRelations ¶
func JoinRelations(c *gin.Context, d *gorm.DB, config QueryMapConfig, modelInfo *ModelInfo, relations map[string]*params.Conditions)
func LoadAndValidateMap ¶
func LoadAndValidateMaps ¶
func LoadForeignKeys ¶
func PathParamsToModels ¶
func QueryMap ¶
func QueryMap(c *gin.Context, db *gorm.DB, args *QueryMapArgs, config QueryMapConfig) error
func QueryMapRecursive ¶
func QueryMapRecursive(c *gin.Context, db *gorm.DB, args *QueryMapArgs, config QueryMapConfig, info *ModelInfo, conds *params.Conditions, result *[]map[string]any) error
func RecoverIfEnabled ¶
func Register ¶
func Register(container *gin.RouterGroup, toRegister string, r CRUDSController) *gin.RouterGroup
func RelationsFromModelInfo ¶
func RelationsFromModelInfo(mdl *ModelInfo, otherRelations map[string]*params.Conditions) map[string]*params.Conditions
func RemoveParentPaths ¶
func SentenceCase ¶
func SetPrimary ¶
func ShouldPaginate ¶
func SnakeToCamelCase ¶
func UpdateToDb ¶
func UpperSnakeCase ¶
func ValidateMap ¶
func ValidateMaps ¶
func ValidateMapsPrimaries ¶
func ValidateModel ¶
func ValidateModels ¶
func ValidateStruct ¶
func WriteDataWithCount ¶
func WriteQueryMapResult ¶
func WriteQueryMapResult(c *gin.Context, args *QueryMapArgs)
Types ¶
type AbortWithErrorHook ¶
type AddRouter ¶
type AddRouter interface {
AddRoute(method string, name string, permissionsFunc model.PermissionFunc, handlersFunc ...gin.HandlerFunc)
}
type CRUDSController ¶
type CRUDSController interface { AddRouter GetModeler NewModel() any NewSliceOfModel() any GetModelType() reflect.Type SetBasePath(basePath string) SetEndpointIfAbsent(name string) GetEndpoint() string GetEndpointPath() string Get(c *gin.Context) GetOne(c *gin.Context) GetStructure(c *gin.Context) GetRelStructure(c *gin.Context) Post(c *gin.Context) Patch(c *gin.Context) PatchMany(c *gin.Context) Delete(c *gin.Context) CanImport() bool AddCustomRoutes() AdditionalModels() []reflect.Type GetRoutes() []Route }
func FindControllerByModel ¶
func FindControllerByModel(modelType reflect.Type) CRUDSController
type Controller ¶
func (Controller) AddCustomRoutes ¶
func (r Controller) AddCustomRoutes()
func (*Controller) AddRoute ¶
func (r *Controller) AddRoute(method string, name string, permissionsFunc model.PermissionFunc, handlersFunc ...gin.HandlerFunc)
func (Controller) AdditionalModels ¶
func (r Controller) AdditionalModels() []reflect.Type
func (*Controller) CanImport ¶
func (r *Controller) CanImport() bool
func (Controller) Delete ¶
func (r Controller) Delete(c *gin.Context)
func (Controller) Get ¶
func (r Controller) Get(c *gin.Context)
func (Controller) GetEndpoint ¶
func (r Controller) GetEndpoint() string
func (Controller) GetEndpointPath ¶
func (r Controller) GetEndpointPath() string
func (Controller) GetModel ¶
func (r Controller) GetModel() interface{}
func (Controller) GetModelType ¶
func (r Controller) GetModelType() reflect.Type
func (Controller) GetOne ¶
func (r Controller) GetOne(c *gin.Context)
func (Controller) GetRelStructure ¶
func (r Controller) GetRelStructure(c *gin.Context)
func (Controller) GetRoutes ¶
func (r Controller) GetRoutes() []Route
func (Controller) GetStructure ¶
func (r Controller) GetStructure(c *gin.Context)
func (Controller) NewModel ¶
func (r Controller) NewModel() interface{}
func (Controller) NewSliceOfModel ¶
func (r Controller) NewSliceOfModel() interface{}
func (Controller) Patch ¶
func (r Controller) Patch(c *gin.Context)
func (Controller) PatchMany ¶
func (r Controller) PatchMany(c *gin.Context)
func (Controller) Post ¶
func (r Controller) Post(c *gin.Context)
func (*Controller) SetBasePath ¶
func (r *Controller) SetBasePath(basePath string)
func (*Controller) SetEndpointIfAbsent ¶
func (r *Controller) SetEndpointIfAbsent(name string)
type ControllerHooks ¶
type ControllerHooks struct { AbortWithError AbortWithErrorHook OnRecover OnRecoverHook }
type DynamicModel ¶
type DynamicModel struct { Dest interface{} Relations *map[string]NestedModel }
type ErrorValidation ¶
type FieldInfo ¶
type FieldInfo struct { Field string `json:"field"` Label string `json:"label"` Descriptive string `json:"descriptive"` Type string `json:"type"` Primary bool `json:"primary"` Required bool `json:"required"` UpdateKey bool `json:"updateKey"` Deprecated bool `json:"deprecated"` MaxLength int `json:"maxLength"` RequiredWithout string `json:"requiredWithout"` RequiredWith string `json:"requiredWith"` Updatable bool `json:"updatable"` Creatable bool `json:"creatable"` Query bool `json:"query"` }
type FileSystemPermissions ¶
type FileSystemPermissions struct { Get model.PermissionFunc Post model.PermissionFunc GetFile model.PermissionFunc Delete model.PermissionFunc }
func DefaultFileSystemPermissions ¶
func DefaultFileSystemPermissions(ctrl GetModeler) FileSystemPermissions
type GetModeler ¶
type GetModeler interface {
GetModel() any
}
type MSSqlError ¶
type ModelInfo ¶
type ModelInfo struct { Select []string SelectArgs []any Fields []reflect.StructField Schema *schema.Schema Table string Order string Relations map[string]*params.Conditions Nested map[string]NestedModel Aggregate bool Distinct bool }
type NestedModel ¶
func (NestedModel) NextNested ¶
func (n NestedModel) NextNested() map[string]NestedModel
type OnRecoverHook ¶
type QueryMapArgs ¶
type QueryMapConfig ¶
type RelationInfo ¶
type RelationInfo struct { Field string `json:"field"` Label string `json:"label"` ForeignKey string `json:"foreignKey"` References string `json:"references"` Type string `json:"type"` Endpoint string `json:"endpoint"` Struct *StructInfo `json:"struct"` Updatable bool `json:"updatable"` Creatable bool `json:"creatable"` }
func GetRelationInfo ¶
func GetRelationInfo(c *gin.Context, rel *schema.Relationship, relations [][]string) RelationInfo
type Route ¶
type Route struct { Method string Name string PermissionsFunc model.PermissionFunc HandlerFuncs []gin.HandlerFunc }
type StructInfo ¶
type StructInfo struct { Fields []FieldInfo `json:"fields"` Relations []RelationInfo `json:"relations"` UpdateConditions []model.UpdateConditions `json:"updateConditions"` }
func GetStructInfo ¶
Click to show internal directories.
Click to hide internal directories.