// 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" "go_backend/internal/model" ) func newCamera(db *gorm.DB, opts ...gen.DOOption) camera { _camera := camera{} _camera.cameraDo.UseDB(db, opts...) _camera.cameraDo.UseModel(&model.Camera{}) tableName := _camera.cameraDo.TableName() _camera.ALL = field.NewAsterisk(tableName) _camera.ID = field.NewInt32(tableName, "id") _camera.CameraID = field.NewString(tableName, "camera_id") _camera.DisplayName = field.NewString(tableName, "display_name") _camera.ParentCategoryID = field.NewInt32(tableName, "parent_category_id") _camera.ViewPriority = field.NewInt32(tableName, "view_priority") _camera.Status = field.NewString(tableName, "status") _camera.Type = field.NewString(tableName, "type") _camera.IPAddress = field.NewString(tableName, "ip_address") _camera.Latitude = field.NewString(tableName, "latitude") _camera.Longitude = field.NewString(tableName, "longitude") _camera.IsDeleted = field.NewBool(tableName, "is_deleted") _camera.CreateTime = field.NewString(tableName, "create_time") _camera.DeletedTime = field.NewString(tableName, "deleted_time") _camera.UpdateTime = field.NewString(tableName, "update_time") _camera.fillFieldMap() return _camera } type camera struct { cameraDo cameraDo ALL field.Asterisk ID field.Int32 CameraID field.String // 摄像头的id DisplayName field.String // 展示使用的名字 ParentCategoryID field.Int32 // 上一级的类别 ViewPriority field.Int32 Status field.String // 摄像头目前状态 Type field.String // 类别 IPAddress field.String // ip地址 Latitude field.String // 纬度 Longitude field.String // 经度 IsDeleted field.Bool CreateTime field.String DeletedTime field.String UpdateTime field.String fieldMap map[string]field.Expr } func (c camera) Table(newTableName string) *camera { c.cameraDo.UseTable(newTableName) return c.updateTableName(newTableName) } func (c camera) As(alias string) *camera { c.cameraDo.DO = *(c.cameraDo.As(alias).(*gen.DO)) return c.updateTableName(alias) } func (c *camera) updateTableName(table string) *camera { c.ALL = field.NewAsterisk(table) c.ID = field.NewInt32(table, "id") c.CameraID = field.NewString(table, "camera_id") c.DisplayName = field.NewString(table, "display_name") c.ParentCategoryID = field.NewInt32(table, "parent_category_id") c.ViewPriority = field.NewInt32(table, "view_priority") c.Status = field.NewString(table, "status") c.Type = field.NewString(table, "type") c.IPAddress = field.NewString(table, "ip_address") c.Latitude = field.NewString(table, "latitude") c.Longitude = field.NewString(table, "longitude") c.IsDeleted = field.NewBool(table, "is_deleted") c.CreateTime = field.NewString(table, "create_time") c.DeletedTime = field.NewString(table, "deleted_time") c.UpdateTime = field.NewString(table, "update_time") c.fillFieldMap() return c } func (c *camera) WithContext(ctx context.Context) *cameraDo { return c.cameraDo.WithContext(ctx) } func (c camera) TableName() string { return c.cameraDo.TableName() } func (c camera) Alias() string { return c.cameraDo.Alias() } func (c camera) Columns(cols ...field.Expr) gen.Columns { return c.cameraDo.Columns(cols...) } func (c *camera) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := c.fieldMap[fieldName] if !ok || _f == nil { return nil, false } _oe, ok := _f.(field.OrderExpr) return _oe, ok } func (c *camera) fillFieldMap() { c.fieldMap = make(map[string]field.Expr, 14) c.fieldMap["id"] = c.ID c.fieldMap["camera_id"] = c.CameraID c.fieldMap["display_name"] = c.DisplayName c.fieldMap["parent_category_id"] = c.ParentCategoryID c.fieldMap["view_priority"] = c.ViewPriority c.fieldMap["status"] = c.Status c.fieldMap["type"] = c.Type c.fieldMap["ip_address"] = c.IPAddress c.fieldMap["latitude"] = c.Latitude c.fieldMap["longitude"] = c.Longitude c.fieldMap["is_deleted"] = c.IsDeleted c.fieldMap["create_time"] = c.CreateTime c.fieldMap["deleted_time"] = c.DeletedTime c.fieldMap["update_time"] = c.UpdateTime } func (c camera) clone(db *gorm.DB) camera { c.cameraDo.ReplaceConnPool(db.Statement.ConnPool) return c } func (c camera) replaceDB(db *gorm.DB) camera { c.cameraDo.ReplaceDB(db) return c } type cameraDo struct{ gen.DO } func (c cameraDo) Debug() *cameraDo { return c.withDO(c.DO.Debug()) } func (c cameraDo) WithContext(ctx context.Context) *cameraDo { return c.withDO(c.DO.WithContext(ctx)) } func (c cameraDo) ReadDB() *cameraDo { return c.Clauses(dbresolver.Read) } func (c cameraDo) WriteDB() *cameraDo { return c.Clauses(dbresolver.Write) } func (c cameraDo) Session(config *gorm.Session) *cameraDo { return c.withDO(c.DO.Session(config)) } func (c cameraDo) Clauses(conds ...clause.Expression) *cameraDo { return c.withDO(c.DO.Clauses(conds...)) } func (c cameraDo) Returning(value interface{}, columns ...string) *cameraDo { return c.withDO(c.DO.Returning(value, columns...)) } func (c cameraDo) Not(conds ...gen.Condition) *cameraDo { return c.withDO(c.DO.Not(conds...)) } func (c cameraDo) Or(conds ...gen.Condition) *cameraDo { return c.withDO(c.DO.Or(conds...)) } func (c cameraDo) Select(conds ...field.Expr) *cameraDo { return c.withDO(c.DO.Select(conds...)) } func (c cameraDo) Where(conds ...gen.Condition) *cameraDo { return c.withDO(c.DO.Where(conds...)) } func (c cameraDo) Order(conds ...field.Expr) *cameraDo { return c.withDO(c.DO.Order(conds...)) } func (c cameraDo) Distinct(cols ...field.Expr) *cameraDo { return c.withDO(c.DO.Distinct(cols...)) } func (c cameraDo) Omit(cols ...field.Expr) *cameraDo { return c.withDO(c.DO.Omit(cols...)) } func (c cameraDo) Join(table schema.Tabler, on ...field.Expr) *cameraDo { return c.withDO(c.DO.Join(table, on...)) } func (c cameraDo) LeftJoin(table schema.Tabler, on ...field.Expr) *cameraDo { return c.withDO(c.DO.LeftJoin(table, on...)) } func (c cameraDo) RightJoin(table schema.Tabler, on ...field.Expr) *cameraDo { return c.withDO(c.DO.RightJoin(table, on...)) } func (c cameraDo) Group(cols ...field.Expr) *cameraDo { return c.withDO(c.DO.Group(cols...)) } func (c cameraDo) Having(conds ...gen.Condition) *cameraDo { return c.withDO(c.DO.Having(conds...)) } func (c cameraDo) Limit(limit int) *cameraDo { return c.withDO(c.DO.Limit(limit)) } func (c cameraDo) Offset(offset int) *cameraDo { return c.withDO(c.DO.Offset(offset)) } func (c cameraDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *cameraDo { return c.withDO(c.DO.Scopes(funcs...)) } func (c cameraDo) Unscoped() *cameraDo { return c.withDO(c.DO.Unscoped()) } func (c cameraDo) Create(values ...*model.Camera) error { if len(values) == 0 { return nil } return c.DO.Create(values) } func (c cameraDo) CreateInBatches(values []*model.Camera, batchSize int) error { return c.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 (c cameraDo) Save(values ...*model.Camera) error { if len(values) == 0 { return nil } return c.DO.Save(values) } func (c cameraDo) First() (*model.Camera, error) { if result, err := c.DO.First(); err != nil { return nil, err } else { return result.(*model.Camera), nil } } func (c cameraDo) Take() (*model.Camera, error) { if result, err := c.DO.Take(); err != nil { return nil, err } else { return result.(*model.Camera), nil } } func (c cameraDo) Last() (*model.Camera, error) { if result, err := c.DO.Last(); err != nil { return nil, err } else { return result.(*model.Camera), nil } } func (c cameraDo) Find() ([]*model.Camera, error) { result, err := c.DO.Find() return result.([]*model.Camera), err } func (c cameraDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Camera, err error) { buf := make([]*model.Camera, 0, batchSize) err = c.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 (c cameraDo) FindInBatches(result *[]*model.Camera, batchSize int, fc func(tx gen.Dao, batch int) error) error { return c.DO.FindInBatches(result, batchSize, fc) } func (c cameraDo) Attrs(attrs ...field.AssignExpr) *cameraDo { return c.withDO(c.DO.Attrs(attrs...)) } func (c cameraDo) Assign(attrs ...field.AssignExpr) *cameraDo { return c.withDO(c.DO.Assign(attrs...)) } func (c cameraDo) Joins(fields ...field.RelationField) *cameraDo { for _, _f := range fields { c = *c.withDO(c.DO.Joins(_f)) } return &c } func (c cameraDo) Preload(fields ...field.RelationField) *cameraDo { for _, _f := range fields { c = *c.withDO(c.DO.Preload(_f)) } return &c } func (c cameraDo) FirstOrInit() (*model.Camera, error) { if result, err := c.DO.FirstOrInit(); err != nil { return nil, err } else { return result.(*model.Camera), nil } } func (c cameraDo) FirstOrCreate() (*model.Camera, error) { if result, err := c.DO.FirstOrCreate(); err != nil { return nil, err } else { return result.(*model.Camera), nil } } func (c cameraDo) FindByPage(offset int, limit int) (result []*model.Camera, count int64, err error) { result, err = c.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 = c.Offset(-1).Limit(-1).Count() return } func (c cameraDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { count, err = c.Count() if err != nil { return } err = c.Offset(offset).Limit(limit).Scan(result) return } func (c cameraDo) Scan(result interface{}) (err error) { return c.DO.Scan(result) } func (c cameraDo) Delete(models ...*model.Camera) (result gen.ResultInfo, err error) { return c.DO.Delete(models) } func (c *cameraDo) withDO(do gen.Dao) *cameraDo { c.DO = *do.(*gen.DO) return c }