409 lines
13 KiB
Go
409 lines
13 KiB
Go
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
|
|
package query
|
|
|
|
import (
|
|
"context"
|
|
|
|
"gorm.io/gorm"
|
|
"gorm.io/gorm/clause"
|
|
"gorm.io/gorm/schema"
|
|
|
|
"gorm.io/gen"
|
|
"gorm.io/gen/field"
|
|
|
|
"gorm.io/plugin/dbresolver"
|
|
|
|
"schisandra-album-cloud-microservices/app/auth/model/mysql/model"
|
|
)
|
|
|
|
func newScaStorageAlbum(db *gorm.DB, opts ...gen.DOOption) scaStorageAlbum {
|
|
_scaStorageAlbum := scaStorageAlbum{}
|
|
|
|
_scaStorageAlbum.scaStorageAlbumDo.UseDB(db, opts...)
|
|
_scaStorageAlbum.scaStorageAlbumDo.UseModel(&model.ScaStorageAlbum{})
|
|
|
|
tableName := _scaStorageAlbum.scaStorageAlbumDo.TableName()
|
|
_scaStorageAlbum.ALL = field.NewAsterisk(tableName)
|
|
_scaStorageAlbum.ID = field.NewInt64(tableName, "id")
|
|
_scaStorageAlbum.UserID = field.NewString(tableName, "user_id")
|
|
_scaStorageAlbum.AlbumName = field.NewString(tableName, "album_name")
|
|
_scaStorageAlbum.AlbumType = field.NewString(tableName, "album_type")
|
|
_scaStorageAlbum.CoverImage = field.NewString(tableName, "cover_image")
|
|
_scaStorageAlbum.CreatedAt = field.NewTime(tableName, "created_at")
|
|
_scaStorageAlbum.UpdatedAt = field.NewTime(tableName, "updated_at")
|
|
_scaStorageAlbum.DeletedAt = field.NewField(tableName, "deleted_at")
|
|
|
|
_scaStorageAlbum.fillFieldMap()
|
|
|
|
return _scaStorageAlbum
|
|
}
|
|
|
|
type scaStorageAlbum struct {
|
|
scaStorageAlbumDo
|
|
|
|
ALL field.Asterisk
|
|
ID field.Int64 // 主键
|
|
UserID field.String // 用户ID
|
|
AlbumName field.String // 相册名称
|
|
AlbumType field.String // 相册类型
|
|
CoverImage field.String // 封面图片
|
|
CreatedAt field.Time // 创建时间
|
|
UpdatedAt field.Time // 更新时间
|
|
DeletedAt field.Field // 删除时间
|
|
|
|
fieldMap map[string]field.Expr
|
|
}
|
|
|
|
func (s scaStorageAlbum) Table(newTableName string) *scaStorageAlbum {
|
|
s.scaStorageAlbumDo.UseTable(newTableName)
|
|
return s.updateTableName(newTableName)
|
|
}
|
|
|
|
func (s scaStorageAlbum) As(alias string) *scaStorageAlbum {
|
|
s.scaStorageAlbumDo.DO = *(s.scaStorageAlbumDo.As(alias).(*gen.DO))
|
|
return s.updateTableName(alias)
|
|
}
|
|
|
|
func (s *scaStorageAlbum) updateTableName(table string) *scaStorageAlbum {
|
|
s.ALL = field.NewAsterisk(table)
|
|
s.ID = field.NewInt64(table, "id")
|
|
s.UserID = field.NewString(table, "user_id")
|
|
s.AlbumName = field.NewString(table, "album_name")
|
|
s.AlbumType = field.NewString(table, "album_type")
|
|
s.CoverImage = field.NewString(table, "cover_image")
|
|
s.CreatedAt = field.NewTime(table, "created_at")
|
|
s.UpdatedAt = field.NewTime(table, "updated_at")
|
|
s.DeletedAt = field.NewField(table, "deleted_at")
|
|
|
|
s.fillFieldMap()
|
|
|
|
return s
|
|
}
|
|
|
|
func (s *scaStorageAlbum) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|
_f, ok := s.fieldMap[fieldName]
|
|
if !ok || _f == nil {
|
|
return nil, false
|
|
}
|
|
_oe, ok := _f.(field.OrderExpr)
|
|
return _oe, ok
|
|
}
|
|
|
|
func (s *scaStorageAlbum) fillFieldMap() {
|
|
s.fieldMap = make(map[string]field.Expr, 8)
|
|
s.fieldMap["id"] = s.ID
|
|
s.fieldMap["user_id"] = s.UserID
|
|
s.fieldMap["album_name"] = s.AlbumName
|
|
s.fieldMap["album_type"] = s.AlbumType
|
|
s.fieldMap["cover_image"] = s.CoverImage
|
|
s.fieldMap["created_at"] = s.CreatedAt
|
|
s.fieldMap["updated_at"] = s.UpdatedAt
|
|
s.fieldMap["deleted_at"] = s.DeletedAt
|
|
}
|
|
|
|
func (s scaStorageAlbum) clone(db *gorm.DB) scaStorageAlbum {
|
|
s.scaStorageAlbumDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
return s
|
|
}
|
|
|
|
func (s scaStorageAlbum) replaceDB(db *gorm.DB) scaStorageAlbum {
|
|
s.scaStorageAlbumDo.ReplaceDB(db)
|
|
return s
|
|
}
|
|
|
|
type scaStorageAlbumDo struct{ gen.DO }
|
|
|
|
type IScaStorageAlbumDo interface {
|
|
gen.SubQuery
|
|
Debug() IScaStorageAlbumDo
|
|
WithContext(ctx context.Context) IScaStorageAlbumDo
|
|
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
|
ReplaceDB(db *gorm.DB)
|
|
ReadDB() IScaStorageAlbumDo
|
|
WriteDB() IScaStorageAlbumDo
|
|
As(alias string) gen.Dao
|
|
Session(config *gorm.Session) IScaStorageAlbumDo
|
|
Columns(cols ...field.Expr) gen.Columns
|
|
Clauses(conds ...clause.Expression) IScaStorageAlbumDo
|
|
Not(conds ...gen.Condition) IScaStorageAlbumDo
|
|
Or(conds ...gen.Condition) IScaStorageAlbumDo
|
|
Select(conds ...field.Expr) IScaStorageAlbumDo
|
|
Where(conds ...gen.Condition) IScaStorageAlbumDo
|
|
Order(conds ...field.Expr) IScaStorageAlbumDo
|
|
Distinct(cols ...field.Expr) IScaStorageAlbumDo
|
|
Omit(cols ...field.Expr) IScaStorageAlbumDo
|
|
Join(table schema.Tabler, on ...field.Expr) IScaStorageAlbumDo
|
|
LeftJoin(table schema.Tabler, on ...field.Expr) IScaStorageAlbumDo
|
|
RightJoin(table schema.Tabler, on ...field.Expr) IScaStorageAlbumDo
|
|
Group(cols ...field.Expr) IScaStorageAlbumDo
|
|
Having(conds ...gen.Condition) IScaStorageAlbumDo
|
|
Limit(limit int) IScaStorageAlbumDo
|
|
Offset(offset int) IScaStorageAlbumDo
|
|
Count() (count int64, err error)
|
|
Scopes(funcs ...func(gen.Dao) gen.Dao) IScaStorageAlbumDo
|
|
Unscoped() IScaStorageAlbumDo
|
|
Create(values ...*model.ScaStorageAlbum) error
|
|
CreateInBatches(values []*model.ScaStorageAlbum, batchSize int) error
|
|
Save(values ...*model.ScaStorageAlbum) error
|
|
First() (*model.ScaStorageAlbum, error)
|
|
Take() (*model.ScaStorageAlbum, error)
|
|
Last() (*model.ScaStorageAlbum, error)
|
|
Find() ([]*model.ScaStorageAlbum, error)
|
|
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ScaStorageAlbum, err error)
|
|
FindInBatches(result *[]*model.ScaStorageAlbum, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
|
Pluck(column field.Expr, dest interface{}) error
|
|
Delete(...*model.ScaStorageAlbum) (info gen.ResultInfo, err error)
|
|
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
|
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
|
Updates(value interface{}) (info gen.ResultInfo, err error)
|
|
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
|
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
|
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
|
|
UpdateFrom(q gen.SubQuery) gen.Dao
|
|
Attrs(attrs ...field.AssignExpr) IScaStorageAlbumDo
|
|
Assign(attrs ...field.AssignExpr) IScaStorageAlbumDo
|
|
Joins(fields ...field.RelationField) IScaStorageAlbumDo
|
|
Preload(fields ...field.RelationField) IScaStorageAlbumDo
|
|
FirstOrInit() (*model.ScaStorageAlbum, error)
|
|
FirstOrCreate() (*model.ScaStorageAlbum, error)
|
|
FindByPage(offset int, limit int) (result []*model.ScaStorageAlbum, count int64, err error)
|
|
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
|
Scan(result interface{}) (err error)
|
|
Returning(value interface{}, columns ...string) IScaStorageAlbumDo
|
|
UnderlyingDB() *gorm.DB
|
|
schema.Tabler
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) Debug() IScaStorageAlbumDo {
|
|
return s.withDO(s.DO.Debug())
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) WithContext(ctx context.Context) IScaStorageAlbumDo {
|
|
return s.withDO(s.DO.WithContext(ctx))
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) ReadDB() IScaStorageAlbumDo {
|
|
return s.Clauses(dbresolver.Read)
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) WriteDB() IScaStorageAlbumDo {
|
|
return s.Clauses(dbresolver.Write)
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) Session(config *gorm.Session) IScaStorageAlbumDo {
|
|
return s.withDO(s.DO.Session(config))
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) Clauses(conds ...clause.Expression) IScaStorageAlbumDo {
|
|
return s.withDO(s.DO.Clauses(conds...))
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) Returning(value interface{}, columns ...string) IScaStorageAlbumDo {
|
|
return s.withDO(s.DO.Returning(value, columns...))
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) Not(conds ...gen.Condition) IScaStorageAlbumDo {
|
|
return s.withDO(s.DO.Not(conds...))
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) Or(conds ...gen.Condition) IScaStorageAlbumDo {
|
|
return s.withDO(s.DO.Or(conds...))
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) Select(conds ...field.Expr) IScaStorageAlbumDo {
|
|
return s.withDO(s.DO.Select(conds...))
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) Where(conds ...gen.Condition) IScaStorageAlbumDo {
|
|
return s.withDO(s.DO.Where(conds...))
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) Order(conds ...field.Expr) IScaStorageAlbumDo {
|
|
return s.withDO(s.DO.Order(conds...))
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) Distinct(cols ...field.Expr) IScaStorageAlbumDo {
|
|
return s.withDO(s.DO.Distinct(cols...))
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) Omit(cols ...field.Expr) IScaStorageAlbumDo {
|
|
return s.withDO(s.DO.Omit(cols...))
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) Join(table schema.Tabler, on ...field.Expr) IScaStorageAlbumDo {
|
|
return s.withDO(s.DO.Join(table, on...))
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) LeftJoin(table schema.Tabler, on ...field.Expr) IScaStorageAlbumDo {
|
|
return s.withDO(s.DO.LeftJoin(table, on...))
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) RightJoin(table schema.Tabler, on ...field.Expr) IScaStorageAlbumDo {
|
|
return s.withDO(s.DO.RightJoin(table, on...))
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) Group(cols ...field.Expr) IScaStorageAlbumDo {
|
|
return s.withDO(s.DO.Group(cols...))
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) Having(conds ...gen.Condition) IScaStorageAlbumDo {
|
|
return s.withDO(s.DO.Having(conds...))
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) Limit(limit int) IScaStorageAlbumDo {
|
|
return s.withDO(s.DO.Limit(limit))
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) Offset(offset int) IScaStorageAlbumDo {
|
|
return s.withDO(s.DO.Offset(offset))
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IScaStorageAlbumDo {
|
|
return s.withDO(s.DO.Scopes(funcs...))
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) Unscoped() IScaStorageAlbumDo {
|
|
return s.withDO(s.DO.Unscoped())
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) Create(values ...*model.ScaStorageAlbum) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return s.DO.Create(values)
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) CreateInBatches(values []*model.ScaStorageAlbum, batchSize int) error {
|
|
return s.DO.CreateInBatches(values, batchSize)
|
|
}
|
|
|
|
// Save : !!! underlying implementation is different with GORM
|
|
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
|
func (s scaStorageAlbumDo) Save(values ...*model.ScaStorageAlbum) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return s.DO.Save(values)
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) First() (*model.ScaStorageAlbum, error) {
|
|
if result, err := s.DO.First(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.ScaStorageAlbum), nil
|
|
}
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) Take() (*model.ScaStorageAlbum, error) {
|
|
if result, err := s.DO.Take(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.ScaStorageAlbum), nil
|
|
}
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) Last() (*model.ScaStorageAlbum, error) {
|
|
if result, err := s.DO.Last(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.ScaStorageAlbum), nil
|
|
}
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) Find() ([]*model.ScaStorageAlbum, error) {
|
|
result, err := s.DO.Find()
|
|
return result.([]*model.ScaStorageAlbum), err
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ScaStorageAlbum, err error) {
|
|
buf := make([]*model.ScaStorageAlbum, 0, batchSize)
|
|
err = s.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
|
defer func() { results = append(results, buf...) }()
|
|
return fc(tx, batch)
|
|
})
|
|
return results, err
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) FindInBatches(result *[]*model.ScaStorageAlbum, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
return s.DO.FindInBatches(result, batchSize, fc)
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) Attrs(attrs ...field.AssignExpr) IScaStorageAlbumDo {
|
|
return s.withDO(s.DO.Attrs(attrs...))
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) Assign(attrs ...field.AssignExpr) IScaStorageAlbumDo {
|
|
return s.withDO(s.DO.Assign(attrs...))
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) Joins(fields ...field.RelationField) IScaStorageAlbumDo {
|
|
for _, _f := range fields {
|
|
s = *s.withDO(s.DO.Joins(_f))
|
|
}
|
|
return &s
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) Preload(fields ...field.RelationField) IScaStorageAlbumDo {
|
|
for _, _f := range fields {
|
|
s = *s.withDO(s.DO.Preload(_f))
|
|
}
|
|
return &s
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) FirstOrInit() (*model.ScaStorageAlbum, error) {
|
|
if result, err := s.DO.FirstOrInit(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.ScaStorageAlbum), nil
|
|
}
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) FirstOrCreate() (*model.ScaStorageAlbum, error) {
|
|
if result, err := s.DO.FirstOrCreate(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.ScaStorageAlbum), nil
|
|
}
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) FindByPage(offset int, limit int) (result []*model.ScaStorageAlbum, count int64, err error) {
|
|
result, err = s.Offset(offset).Limit(limit).Find()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
if size := len(result); 0 < limit && 0 < size && size < limit {
|
|
count = int64(size + offset)
|
|
return
|
|
}
|
|
|
|
count, err = s.Offset(-1).Limit(-1).Count()
|
|
return
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
|
count, err = s.Count()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
err = s.Offset(offset).Limit(limit).Scan(result)
|
|
return
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) Scan(result interface{}) (err error) {
|
|
return s.DO.Scan(result)
|
|
}
|
|
|
|
func (s scaStorageAlbumDo) Delete(models ...*model.ScaStorageAlbum) (result gen.ResultInfo, err error) {
|
|
return s.DO.Delete(models)
|
|
}
|
|
|
|
func (s *scaStorageAlbumDo) withDO(do gen.Dao) *scaStorageAlbumDo {
|
|
s.DO = *do.(*gen.DO)
|
|
return s
|
|
}
|