Documentation ¶
Index ¶
- Constants
- func CameCaseToUnderscore(s string) string
- func FmtReqId(reqId string) string
- func GetAcceptLanguage(c *gin.Context) string
- func ResolveSearchQuery(driver string, q any, condition Condition, pTName string)
- type BaseDao
- func (s *BaseDao) Cache() cache.ICache
- func (s *BaseDao) Chunk(db *gorm.DB, size int, callback func(records []map[string]interface{}) error) error
- func (s *BaseDao) Count(model any, count *int64) error
- func (s *BaseDao) CountByMap(where map[string]any, model any, count *int64) error
- func (s *BaseDao) Create(model any) error
- func (s *BaseDao) CreateTx(tx *gorm.DB, model any) error
- func (s *BaseDao) DB() *gorm.DB
- func (s *BaseDao) DelIds(model any, ids any) error
- func (s *BaseDao) DelIdsTx(tx *gorm.DB, model any, ids any) error
- func (s *BaseDao) DelModel(model any) error
- func (s *BaseDao) DelWhereMap(model any, where map[string]any) error
- func (s *BaseDao) DelWhereMapTx(tx *gorm.DB, model any, where map[string]any) error
- func (s *BaseDao) DelWhereTx(tx *gorm.DB, model any) error
- func (s *BaseDao) Get(id any, model any) error
- func (s *BaseDao) GetByMap(where map[string]any, models any) error
- func (s *BaseDao) GetByWhere(where any, models any) error
- func (s *BaseDao) MakeCondition(q Query) func(db *gorm.DB) *gorm.DB
- func (s *BaseDao) Page(where Query, models any, limit, offset int) error
- func (s *BaseDao) Paginate(pageSize, pageIndex int) func(db *gorm.DB) *gorm.DB
- func (s *BaseDao) QPage(where any, data any, total *int64, limit, offset int) error
- func (s *BaseDao) Query(where Query, models any) error
- func (s *BaseDao) QueryPage(where Query, models any, total *int64, limit, offset int) error
- func (s *BaseDao) Save(model any) error
- func (s *BaseDao) SaveTx(tx *gorm.DB, model any) error
- func (s *BaseDao) UpdateById(model any) error
- func (s *BaseDao) UpdateByIdTx(tx *gorm.DB, model any) error
- func (s *BaseDao) UpdateWhere(model any, where any, updates map[string]any) error
- func (s *BaseDao) UpdateWhereModel(where any, updates any) error
- func (s *BaseDao) UpdateWhereModelTx(tx *gorm.DB, where any, updates any) error
- func (s *BaseDao) UpdateWhereTx(tx *gorm.DB, model any, where any, updates map[string]any) error
- type Condition
- type ControlBy
- type GormCondition
- type GormJoin
- type GormPublic
- type Model
- type ModelIntTime
- type ModelTime
- type Option
- type PageResp
- type Query
- type QueryTag
- type ReqBase
- type ReqId
- type ReqIds
- type ReqPage
- type ReqStrId
- type Resp
- type StatusModel
Constants ¶
const ( // FromQueryTag tag标记 FromQueryTag = "query" // Mysql 数据库标识 Mysql = "mysql" // Postgres 数据库标识 Postgres = "pgsql" )
const ( OK = 200 FAILURE = 500 )
Variables ¶
This section is empty.
Functions ¶
func CameCaseToUnderscore ¶ added in v1.0.9
func GetAcceptLanguage ¶
Types ¶
type BaseDao ¶ added in v1.0.3
type BaseDao struct {
DbName string
}
func (*BaseDao) Chunk ¶ added in v1.0.3
func (s *BaseDao) Chunk(db *gorm.DB, size int, callback func(records []map[string]interface{}) error) error
* * chunk 查询
func (*BaseDao) CountByMap ¶ added in v1.0.3
* * 条数查询 * model: 查询条件 * count: 查询条数
func (*BaseDao) DelWhereMap ¶ added in v1.0.3
* 条件删除,模型 where 为map
func (*BaseDao) DelWhereMapTx ¶ added in v1.0.3
func (*BaseDao) DelWhereTx ¶ added in v1.0.3
func (*BaseDao) GetByWhere ¶ added in v1.0.3
* * 条件查询 * where: where 查询条件model * models: 代表查询返回的model数组
func (*BaseDao) MakeCondition ¶ added in v1.0.3
* * 查询条件组装
func (*BaseDao) UpdateById ¶ added in v1.0.3
* 根据模型id更新
func (*BaseDao) UpdateByIdTx ¶ added in v1.0.3
func (*BaseDao) UpdateWhere ¶ added in v1.0.3
* 条件跟新
func (*BaseDao) UpdateWhereModel ¶ added in v1.0.3
* 模型更新
func (*BaseDao) UpdateWhereModelTx ¶ added in v1.0.3
type GormCondition ¶
type GormCondition struct { GormPublic Join []*GormJoin }
func (*GormCondition) SetJoinOn ¶
func (e *GormCondition) SetJoinOn(t, on string) Condition
type GormJoin ¶
type GormJoin struct { Type string JoinOn string GormPublic }
type GormPublic ¶
type GormPublic struct { Where map[string][]interface{} Order []string Or map[string][]interface{} }
func (*GormPublic) SetOr ¶
func (e *GormPublic) SetOr(k string, v []interface{})
func (*GormPublic) SetOrder ¶
func (e *GormPublic) SetOrder(k string)
func (*GormPublic) SetWhere ¶
func (e *GormPublic) SetWhere(k string, v []interface{})
type Model ¶
type Model struct {
Id int `json:"id" gorm:"type:bigint unsigned;primaryKey;autoIncrement;comment:主键编码"` //主键
}
type ModelIntTime ¶
type Query ¶
type Query interface {
TableName() string
}
* 条件查询结构体,结果体非零值字段将查询 * @Param type * eq 等于(默认不填都可以) * like 包含 * gt / gte 大于 / 大于等于 * lt / lte 小于 / 小于等于 * left / ileft :like xxx% * right / iright : like %xxx * in * isnull * order 排序 e.g. order[key]=desc order[key]=asc * "-" 忽略该字段 * @Param table * table 不填默认取 TableName值 * @Param column * column 不填以结构体字段 * eg: * type ExampleQuery struct{ * Name string `json:"name" query:"type:like;column:name;table:exampale"` * Status int `json:"status" query:"type:gt"` * } * func (ExampleQuery) TableName() string { * return "ExampleQuery" * }
type QueryTag ¶
type QueryTag string
const ( EQ QueryTag = "eq" LIKE QueryTag = "like" ILIKE QueryTag = "ilike" LEFT QueryTag = "left" ILEFT QueryTag = "ileft" RIGHT QueryTag = "right" IRIGHT QueryTag = "iright" GT QueryTag = "gt" GTE QueryTag = "gte" LT QueryTag = "lt" LTE QueryTag = "lte" IN QueryTag = "in" ISNULL QueryTag = "isnull" ISNOTNULL QueryTag = "isnotnull" ORDER QueryTag = "order" JOIN QueryTag = "join" )
type ReqPage ¶
type StatusModel ¶
type StatusModel struct {
Status int `json:"status" gorm:"type:tinyint unsigned;comment:状态 1 默认状态 2 成功 3 失败"`
}