Documentation ¶
Index ¶
- Variables
- func MigrateJoinTable(mainModel IModel, col string, followModel IModel)
- func MigrateTable(model IModel)
- func RegisterController(c IController, apis []string, extendRouter func(router *gin.RouterGroup), ...) error
- func SourceFieldsFiltter(db *gorm.DB, filter []string) *gorm.DB
- func SourceSearchWhere(db *gorm.DB, search *BaseSearch) *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 Source
- func (s *Source) GetModel() IModel
- 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 interface{}, isAdd bool) (uint, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( BasePageNum = 1 BasePageSize = 10 BaseListLimit = 1000 )
View Source
var ModelMigrateErr = []string{}
用于搜集迁移失败的数据
Functions ¶
func MigrateJoinTable ¶
数据库中间表迁移
func RegisterController ¶
func RegisterController(c IController, apis []string, extendRouter func(router *gin.RouterGroup), middle ...func(ctx *gin.Context)) error
func SourceSearchWhere ¶
func SourceSearchWhere(db *gorm.DB, search *BaseSearch) *gorm.DB
func ValidStuct ¶
func ValidStuct(stu interface{}) error
*
- 验证结构体内的字段数据是否符合要求
- @Param stu 需要验证的结构体
- @Any errInfo 在结构体的tag中定义的字段
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"` // 大于 Page int `json:"page"` // 当前页 Size int `json:"size"` // 一页多少条数据 Order string `json:"order"` // 排序字段 Sort string `json:"sort"` // 排序方式 }
type 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 Source ¶
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.