// 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 repo import ( "context" "gorm.io/gorm" "gorm.io/gorm/clause" "gorm.io/gorm/schema" "gorm.io/gen" "gorm.io/gen/field" "gorm.io/plugin/dbresolver" "gitea.ddegame.cn/open/servicebase/pkg/model" ) func newDataAttach(db *gorm.DB, opts ...gen.DOOption) dataAttach { _dataAttach := dataAttach{} _dataAttach.dataAttachDo.UseDB(db, opts...) _dataAttach.dataAttachDo.UseModel(&model.DataAttach{}) tableName := _dataAttach.dataAttachDo.TableName() _dataAttach.ALL = field.NewAsterisk(tableName) _dataAttach.ID = field.NewString(tableName, "id") _dataAttach.TenantID = field.NewString(tableName, "tenant_id") _dataAttach.PartUploadID = field.NewString(tableName, "part_upload_id") _dataAttach.TotalChunks = field.NewInt32(tableName, "total_chunks") _dataAttach.PartSize = field.NewInt32(tableName, "part_size") _dataAttach.Md5 = field.NewString(tableName, "md5") _dataAttach.DataType = field.NewString(tableName, "data_type") _dataAttach.DataID = field.NewString(tableName, "data_id") _dataAttach.CommonType = field.NewString(tableName, "common_type") _dataAttach.FileType = field.NewString(tableName, "file_type") _dataAttach.FileSize = field.NewInt32(tableName, "file_size") _dataAttach.FileName = field.NewString(tableName, "file_name") _dataAttach.FilePath = field.NewString(tableName, "file_path") _dataAttach.FileThumbPath = field.NewString(tableName, "file_thumb_path") _dataAttach.FileThumbType = field.NewString(tableName, "file_thumb_type") _dataAttach.UploadState = field.NewInt32(tableName, "upload_state") _dataAttach.DeleteAt = field.NewField(tableName, "delete_at") _dataAttach.CreateAt = field.NewTime(tableName, "create_at") _dataAttach.CreateBy = field.NewString(tableName, "create_by") _dataAttach.UpdateAt = field.NewTime(tableName, "update_at") _dataAttach.UpdateBy = field.NewString(tableName, "update_by") _dataAttach.fillFieldMap() return _dataAttach } // dataAttach 通用附件 type dataAttach struct { dataAttachDo dataAttachDo ALL field.Asterisk ID field.String // 业务ID TenantID field.String // 企业ID PartUploadID field.String // 分片上传upload id TotalChunks field.Int32 // 分片总数 PartSize field.Int32 // 分片大小-单位M Md5 field.String // 文件md5 DataType field.String // 数据类型:SATELLITE=卫星图,其他请使用时完善定义 DataID field.String // 数据ID CommonType field.String // 通用类型:IMAGE = 图片(jfif、png、jpg等),DOC = 文档(excel、docs、ppt、pdf等),BINARY = 二进制文件(exe等) FileType field.String // 文件类型 FileSize field.Int32 // 文件大小 FileName field.String // 文件名称 FilePath field.String // 文件路径 FileThumbPath field.String // 缩略文件路径 FileThumbType field.String // 缩略图文件类型 UploadState field.Int32 // 0未上传,1上传 DeleteAt field.Field // del标志 CreateAt field.Time // 创建时间 CreateBy field.String // 创建人 UpdateAt field.Time // 更新时间 UpdateBy field.String // 更新人 fieldMap map[string]field.Expr } func (d dataAttach) Table(newTableName string) *dataAttach { d.dataAttachDo.UseTable(newTableName) return d.updateTableName(newTableName) } func (d dataAttach) As(alias string) *dataAttach { d.dataAttachDo.DO = *(d.dataAttachDo.As(alias).(*gen.DO)) return d.updateTableName(alias) } func (d *dataAttach) updateTableName(table string) *dataAttach { d.ALL = field.NewAsterisk(table) d.ID = field.NewString(table, "id") d.TenantID = field.NewString(table, "tenant_id") d.PartUploadID = field.NewString(table, "part_upload_id") d.TotalChunks = field.NewInt32(table, "total_chunks") d.PartSize = field.NewInt32(table, "part_size") d.Md5 = field.NewString(table, "md5") d.DataType = field.NewString(table, "data_type") d.DataID = field.NewString(table, "data_id") d.CommonType = field.NewString(table, "common_type") d.FileType = field.NewString(table, "file_type") d.FileSize = field.NewInt32(table, "file_size") d.FileName = field.NewString(table, "file_name") d.FilePath = field.NewString(table, "file_path") d.FileThumbPath = field.NewString(table, "file_thumb_path") d.FileThumbType = field.NewString(table, "file_thumb_type") d.UploadState = field.NewInt32(table, "upload_state") d.DeleteAt = field.NewField(table, "delete_at") d.CreateAt = field.NewTime(table, "create_at") d.CreateBy = field.NewString(table, "create_by") d.UpdateAt = field.NewTime(table, "update_at") d.UpdateBy = field.NewString(table, "update_by") d.fillFieldMap() return d } func (d *dataAttach) WithContext(ctx context.Context) IDataAttachDo { return d.dataAttachDo.WithContext(ctx) } func (d dataAttach) TableName() string { return d.dataAttachDo.TableName() } func (d dataAttach) Alias() string { return d.dataAttachDo.Alias() } func (d dataAttach) Columns(cols ...field.Expr) gen.Columns { return d.dataAttachDo.Columns(cols...) } func (d *dataAttach) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := d.fieldMap[fieldName] if !ok || _f == nil { return nil, false } _oe, ok := _f.(field.OrderExpr) return _oe, ok } func (d *dataAttach) fillFieldMap() { d.fieldMap = make(map[string]field.Expr, 21) d.fieldMap["id"] = d.ID d.fieldMap["tenant_id"] = d.TenantID d.fieldMap["part_upload_id"] = d.PartUploadID d.fieldMap["total_chunks"] = d.TotalChunks d.fieldMap["part_size"] = d.PartSize d.fieldMap["md5"] = d.Md5 d.fieldMap["data_type"] = d.DataType d.fieldMap["data_id"] = d.DataID d.fieldMap["common_type"] = d.CommonType d.fieldMap["file_type"] = d.FileType d.fieldMap["file_size"] = d.FileSize d.fieldMap["file_name"] = d.FileName d.fieldMap["file_path"] = d.FilePath d.fieldMap["file_thumb_path"] = d.FileThumbPath d.fieldMap["file_thumb_type"] = d.FileThumbType d.fieldMap["upload_state"] = d.UploadState d.fieldMap["delete_at"] = d.DeleteAt d.fieldMap["create_at"] = d.CreateAt d.fieldMap["create_by"] = d.CreateBy d.fieldMap["update_at"] = d.UpdateAt d.fieldMap["update_by"] = d.UpdateBy } func (d dataAttach) clone(db *gorm.DB) dataAttach { d.dataAttachDo.ReplaceConnPool(db.Statement.ConnPool) return d } func (d dataAttach) replaceDB(db *gorm.DB) dataAttach { d.dataAttachDo.ReplaceDB(db) return d } type dataAttachDo struct{ gen.DO } type IDataAttachDo interface { gen.SubQuery Debug() IDataAttachDo WithContext(ctx context.Context) IDataAttachDo WithResult(fc func(tx gen.Dao)) gen.ResultInfo ReplaceDB(db *gorm.DB) ReadDB() IDataAttachDo WriteDB() IDataAttachDo As(alias string) gen.Dao Session(config *gorm.Session) IDataAttachDo Columns(cols ...field.Expr) gen.Columns Clauses(conds ...clause.Expression) IDataAttachDo Not(conds ...gen.Condition) IDataAttachDo Or(conds ...gen.Condition) IDataAttachDo Select(conds ...field.Expr) IDataAttachDo Where(conds ...gen.Condition) IDataAttachDo Order(conds ...field.Expr) IDataAttachDo Distinct(cols ...field.Expr) IDataAttachDo Omit(cols ...field.Expr) IDataAttachDo Join(table schema.Tabler, on ...field.Expr) IDataAttachDo LeftJoin(table schema.Tabler, on ...field.Expr) IDataAttachDo RightJoin(table schema.Tabler, on ...field.Expr) IDataAttachDo Group(cols ...field.Expr) IDataAttachDo Having(conds ...gen.Condition) IDataAttachDo Limit(limit int) IDataAttachDo Offset(offset int) IDataAttachDo Count() (count int64, err error) Scopes(funcs ...func(gen.Dao) gen.Dao) IDataAttachDo Unscoped() IDataAttachDo Create(values ...*model.DataAttach) error CreateInBatches(values []*model.DataAttach, batchSize int) error Save(values ...*model.DataAttach) error First() (*model.DataAttach, error) Take() (*model.DataAttach, error) Last() (*model.DataAttach, error) Find() ([]*model.DataAttach, error) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.DataAttach, err error) FindInBatches(result *[]*model.DataAttach, batchSize int, fc func(tx gen.Dao, batch int) error) error Pluck(column field.Expr, dest interface{}) error Delete(...*model.DataAttach) (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) IDataAttachDo Assign(attrs ...field.AssignExpr) IDataAttachDo Joins(fields ...field.RelationField) IDataAttachDo Preload(fields ...field.RelationField) IDataAttachDo FirstOrInit() (*model.DataAttach, error) FirstOrCreate() (*model.DataAttach, error) FindByPage(offset int, limit int) (result []*model.DataAttach, 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) IDataAttachDo UnderlyingDB() *gorm.DB schema.Tabler } func (d dataAttachDo) Debug() IDataAttachDo { return d.withDO(d.DO.Debug()) } func (d dataAttachDo) WithContext(ctx context.Context) IDataAttachDo { return d.withDO(d.DO.WithContext(ctx)) } func (d dataAttachDo) ReadDB() IDataAttachDo { return d.Clauses(dbresolver.Read) } func (d dataAttachDo) WriteDB() IDataAttachDo { return d.Clauses(dbresolver.Write) } func (d dataAttachDo) Session(config *gorm.Session) IDataAttachDo { return d.withDO(d.DO.Session(config)) } func (d dataAttachDo) Clauses(conds ...clause.Expression) IDataAttachDo { return d.withDO(d.DO.Clauses(conds...)) } func (d dataAttachDo) Returning(value interface{}, columns ...string) IDataAttachDo { return d.withDO(d.DO.Returning(value, columns...)) } func (d dataAttachDo) Not(conds ...gen.Condition) IDataAttachDo { return d.withDO(d.DO.Not(conds...)) } func (d dataAttachDo) Or(conds ...gen.Condition) IDataAttachDo { return d.withDO(d.DO.Or(conds...)) } func (d dataAttachDo) Select(conds ...field.Expr) IDataAttachDo { return d.withDO(d.DO.Select(conds...)) } func (d dataAttachDo) Where(conds ...gen.Condition) IDataAttachDo { return d.withDO(d.DO.Where(conds...)) } func (d dataAttachDo) Order(conds ...field.Expr) IDataAttachDo { return d.withDO(d.DO.Order(conds...)) } func (d dataAttachDo) Distinct(cols ...field.Expr) IDataAttachDo { return d.withDO(d.DO.Distinct(cols...)) } func (d dataAttachDo) Omit(cols ...field.Expr) IDataAttachDo { return d.withDO(d.DO.Omit(cols...)) } func (d dataAttachDo) Join(table schema.Tabler, on ...field.Expr) IDataAttachDo { return d.withDO(d.DO.Join(table, on...)) } func (d dataAttachDo) LeftJoin(table schema.Tabler, on ...field.Expr) IDataAttachDo { return d.withDO(d.DO.LeftJoin(table, on...)) } func (d dataAttachDo) RightJoin(table schema.Tabler, on ...field.Expr) IDataAttachDo { return d.withDO(d.DO.RightJoin(table, on...)) } func (d dataAttachDo) Group(cols ...field.Expr) IDataAttachDo { return d.withDO(d.DO.Group(cols...)) } func (d dataAttachDo) Having(conds ...gen.Condition) IDataAttachDo { return d.withDO(d.DO.Having(conds...)) } func (d dataAttachDo) Limit(limit int) IDataAttachDo { return d.withDO(d.DO.Limit(limit)) } func (d dataAttachDo) Offset(offset int) IDataAttachDo { return d.withDO(d.DO.Offset(offset)) } func (d dataAttachDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IDataAttachDo { return d.withDO(d.DO.Scopes(funcs...)) } func (d dataAttachDo) Unscoped() IDataAttachDo { return d.withDO(d.DO.Unscoped()) } func (d dataAttachDo) Create(values ...*model.DataAttach) error { if len(values) == 0 { return nil } return d.DO.Create(values) } func (d dataAttachDo) CreateInBatches(values []*model.DataAttach, batchSize int) error { return d.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 (d dataAttachDo) Save(values ...*model.DataAttach) error { if len(values) == 0 { return nil } return d.DO.Save(values) } func (d dataAttachDo) First() (*model.DataAttach, error) { if result, err := d.DO.First(); err != nil { return nil, err } else { return result.(*model.DataAttach), nil } } func (d dataAttachDo) Take() (*model.DataAttach, error) { if result, err := d.DO.Take(); err != nil { return nil, err } else { return result.(*model.DataAttach), nil } } func (d dataAttachDo) Last() (*model.DataAttach, error) { if result, err := d.DO.Last(); err != nil { return nil, err } else { return result.(*model.DataAttach), nil } } func (d dataAttachDo) Find() ([]*model.DataAttach, error) { result, err := d.DO.Find() return result.([]*model.DataAttach), err } func (d dataAttachDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.DataAttach, err error) { buf := make([]*model.DataAttach, 0, batchSize) err = d.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 (d dataAttachDo) FindInBatches(result *[]*model.DataAttach, batchSize int, fc func(tx gen.Dao, batch int) error) error { return d.DO.FindInBatches(result, batchSize, fc) } func (d dataAttachDo) Attrs(attrs ...field.AssignExpr) IDataAttachDo { return d.withDO(d.DO.Attrs(attrs...)) } func (d dataAttachDo) Assign(attrs ...field.AssignExpr) IDataAttachDo { return d.withDO(d.DO.Assign(attrs...)) } func (d dataAttachDo) Joins(fields ...field.RelationField) IDataAttachDo { for _, _f := range fields { d = *d.withDO(d.DO.Joins(_f)) } return &d } func (d dataAttachDo) Preload(fields ...field.RelationField) IDataAttachDo { for _, _f := range fields { d = *d.withDO(d.DO.Preload(_f)) } return &d } func (d dataAttachDo) FirstOrInit() (*model.DataAttach, error) { if result, err := d.DO.FirstOrInit(); err != nil { return nil, err } else { return result.(*model.DataAttach), nil } } func (d dataAttachDo) FirstOrCreate() (*model.DataAttach, error) { if result, err := d.DO.FirstOrCreate(); err != nil { return nil, err } else { return result.(*model.DataAttach), nil } } func (d dataAttachDo) FindByPage(offset int, limit int) (result []*model.DataAttach, count int64, err error) { result, err = d.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 = d.Offset(-1).Limit(-1).Count() return } func (d dataAttachDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { count, err = d.Count() if err != nil { return } err = d.Offset(offset).Limit(limit).Scan(result) return } func (d dataAttachDo) Scan(result interface{}) (err error) { return d.DO.Scan(result) } func (d dataAttachDo) Delete(models ...*model.DataAttach) (result gen.ResultInfo, err error) { return d.DO.Delete(models) } func (d *dataAttachDo) withDO(do gen.Dao) *dataAttachDo { d.DO = *do.(*gen.DO) return d }