Documentation ¶
Index ¶
- Variables
- func RegisterController(group *gin.RouterGroup, c IController, apis []string, ...) error
- func SourceFieldsFiltter(db *gorm.DB, filter []string) *gorm.DB
- func SourceSearchWhere(db *gorm.DB, search *BaseSearch, fileds map[string]string) *gorm.DB
- func ValidStuct(stu interface{}) error
- type BaseModel
- type BasePage
- type BaseSearch
- type Controller
- type IController
- type IModel
- type ISource
- type PageResult
- type QueryFild
- type RouterItem
- type Source
- func (s *Source) GetModel() IModel
- func (s *Source) GetModelName() string
- func (s *Source) SourceDel(ids []uint) (int64, error)
- func (s *Source) SourceInfo(id uint) (interface{}, error)
- func (s *Source) SourceList(search *BaseSearch) (interface{}, error)
- func (s *Source) SourcePage(search *BaseSearch) (interface{}, error)
- func (s *Source) SourceSave(data map[string]any, isAdd bool) (uint, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( BasePageNum = 1 BasePageSize = 10 BaseListLimit = 1000 )
Functions ¶
func RegisterController ¶
func RegisterController(group *gin.RouterGroup, c IController, apis []string, extendRouter map[string]*RouterItem, middle ...func(ctx *gin.Context)) error
func SourceSearchWhere ¶
func ValidStuct ¶
func ValidStuct(stu interface{}) error
*
- 验证结构体内的字段数据是否符合要求
- @Param stu 需要验证的结构体
- @Any errMsg 在结构体的tag中定义的字段
- @Any 包含五种验证:phone、chinese、letter、stand、car
Types ¶
type BaseModel ¶
type BaseModel struct { ID uint `gorm:"primarykey" json:"id"` CreatedAt customType.CustomTime `gorm:"comment:创建时间" json:"createdAt"` UpdatedAt customType.CustomTime `gorm:"comment:更新时间" json:"updatedAt"` DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` }
因为gorm自带的model返回的时间类型格式不规范,所以这里自己重新定义一下
type BaseSearch ¶
type BaseSearch struct { // Equal []*QueryFild `json:"equal"` // 精确查询 // Like []*QueryFild `json:"like"` // 模糊查询 // Less []*QueryFild `json:"less"` // 小于 // Greater []*QueryFild `json:"greater"` // 大于 FiledsParam []*QueryFild `json:"filedsParams"` Page int `json:"page"` // 当前页 Size int `json:"size"` // 一页多少条数据 Order string `json:"order"` // 排序字段 Sort string `json:"sort"` // 排序方式 }
type Controller ¶
func NewController ¶ added in v1.0.5
func NewController(pre string, mod string, source ISource) *Controller
初始化Controller实例
type IController ¶
type PageResult ¶
type PageResult struct { Page *BasePage `json:"page"` List interface{} `json:"list"` }
type QueryFild ¶
type QueryFild struct { Field string `json:"field"` Value interface{} `json:"value"` // 可以是数字、数字切片、字符串 }
请求时传递的参数以及参数值
type RouterItem ¶ added in v1.0.2
type Source ¶
type Source struct { ModelName string Model IModel Database before.IDatabaseConnect FiledTypes map[string]string // 字段类型 FieldOmits []string }
*
- ModelName
- Model
- Database
func (*Source) GetModelName ¶ added in v1.0.14
func (*Source) SourceList ¶
func (s *Source) SourceList(search *BaseSearch) (interface{}, error)
*
- 列表
func (*Source) SourcePage ¶
func (s *Source) SourcePage(search *BaseSearch) (interface{}, error)
*
- 分页
Click to show internal directories.
Click to hide internal directories.