123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347 |
- // 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 dao
- import (
- "context"
- "gorm.io/gorm"
- "gorm.io/gorm/clause"
- "gorm.io/gorm/schema"
- "gorm.io/gen"
- "gorm.io/gen/field"
- "gorm.io/plugin/dbresolver"
- "git.rtzhtech.cn/iss/public-lib/model"
- )
- func newMapInfo(db *gorm.DB) mapInfo {
- _mapInfo := mapInfo{}
- _mapInfo.mapInfoDo.UseDB(db)
- _mapInfo.mapInfoDo.UseModel(&model.MapInfo{})
- tableName := _mapInfo.mapInfoDo.TableName()
- _mapInfo.ALL = field.NewField(tableName, "*")
- _mapInfo.ID = field.NewInt32(tableName, "id")
- _mapInfo.Stageid = field.NewString(tableName, "stageid")
- _mapInfo.Index = field.NewInt32(tableName, "index")
- _mapInfo.Maptype = field.NewInt32(tableName, "maptype")
- _mapInfo.Stationid = field.NewInt64(tableName, "stationid")
- _mapInfo.Appid = field.NewInt64(tableName, "appid")
- _mapInfo.CreateAt = field.NewTime(tableName, "create_at")
- _mapInfo.UpdateAt = field.NewTime(tableName, "update_at")
- _mapInfo.fillFieldMap()
- _mapInfo.Base = newBase(tableName, db)
- return _mapInfo
- }
- type mapInfo struct {
- mapInfoDo
- ALL field.Field
- ID field.Int32
- Stageid field.String
- Index field.Int32
- Maptype field.Int32
- Stationid field.Int64
- Appid field.Int64
- CreateAt field.Time
- UpdateAt field.Time
- fieldMap map[string]field.Expr
- }
- func (m mapInfo) Table(newTableName string) *mapInfo {
- m.mapInfoDo.UseTable(newTableName)
- return m.updateTableName(newTableName)
- }
- func (m mapInfo) As(alias string) *mapInfo {
- m.mapInfoDo.DO = *(m.mapInfoDo.As(alias).(*gen.DO))
- return m.updateTableName(alias)
- }
- func (m *mapInfo) updateTableName(table string) *mapInfo {
- m.ALL = field.NewField(table, "*")
- m.ID = field.NewInt32(table, "id")
- m.Stageid = field.NewString(table, "stageid")
- m.Index = field.NewInt32(table, "index")
- m.Maptype = field.NewInt32(table, "maptype")
- m.Stationid = field.NewInt64(table, "stationid")
- m.Appid = field.NewInt64(table, "appid")
- m.CreateAt = field.NewTime(table, "create_at")
- m.UpdateAt = field.NewTime(table, "update_at")
- m.fillFieldMap()
- return m
- }
- func (m *mapInfo) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
- _f, ok := m.fieldMap[fieldName]
- if !ok || _f == nil {
- return nil, false
- }
- _oe, ok := _f.(field.OrderExpr)
- return _oe, ok
- }
- func (m *mapInfo) fillFieldMap() {
- m.fieldMap = make(map[string]field.Expr, 8)
- m.fieldMap["id"] = m.ID
- m.fieldMap["stageid"] = m.Stageid
- m.fieldMap["index"] = m.Index
- m.fieldMap["maptype"] = m.Maptype
- m.fieldMap["stationid"] = m.Stationid
- m.fieldMap["appid"] = m.Appid
- m.fieldMap["create_at"] = m.CreateAt
- m.fieldMap["update_at"] = m.UpdateAt
- }
- func (m mapInfo) clone(db *gorm.DB) mapInfo {
- m.mapInfoDo.ReplaceDB(db)
- return m
- }
- type mapInfoDo struct {
- gen.DO
- Base *Base
- }
- func (m mapInfoDo) Debug() *mapInfoDo {
- return m.withDO(m.DO.Debug())
- }
- func (m mapInfoDo) WithContext(ctx context.Context) *mapInfoDo {
- return m.withDO(m.DO.WithContext(ctx))
- }
- func (m mapInfoDo) ReadDB() *mapInfoDo {
- return m.Clauses(dbresolver.Read)
- }
- func (m mapInfoDo) WriteDB() *mapInfoDo {
- return m.Clauses(dbresolver.Write)
- }
- func (m mapInfoDo) Clauses(conds ...clause.Expression) *mapInfoDo {
- return m.withDO(m.DO.Clauses(conds...))
- }
- func (m mapInfoDo) Returning(value interface{}, columns ...string) *mapInfoDo {
- return m.withDO(m.DO.Returning(value, columns...))
- }
- func (m mapInfoDo) Not(conds ...gen.Condition) *mapInfoDo {
- return m.withDO(m.DO.Not(conds...))
- }
- func (m mapInfoDo) Or(conds ...gen.Condition) *mapInfoDo {
- return m.withDO(m.DO.Or(conds...))
- }
- func (m mapInfoDo) Select(conds ...field.Expr) *mapInfoDo {
- return m.withDO(m.DO.Select(conds...))
- }
- func (m mapInfoDo) Where(conds ...gen.Condition) *mapInfoDo {
- return m.withDO(m.DO.Where(conds...))
- }
- func (m mapInfoDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *mapInfoDo {
- return m.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
- }
- func (m mapInfoDo) Order(conds ...field.Expr) *mapInfoDo {
- return m.withDO(m.DO.Order(conds...))
- }
- func (m mapInfoDo) Distinct(cols ...field.Expr) *mapInfoDo {
- return m.withDO(m.DO.Distinct(cols...))
- }
- func (m mapInfoDo) Omit(cols ...field.Expr) *mapInfoDo {
- return m.withDO(m.DO.Omit(cols...))
- }
- func (m mapInfoDo) Join(table schema.Tabler, on ...field.Expr) *mapInfoDo {
- return m.withDO(m.DO.Join(table, on...))
- }
- func (m mapInfoDo) LeftJoin(table schema.Tabler, on ...field.Expr) *mapInfoDo {
- return m.withDO(m.DO.LeftJoin(table, on...))
- }
- func (m mapInfoDo) RightJoin(table schema.Tabler, on ...field.Expr) *mapInfoDo {
- return m.withDO(m.DO.RightJoin(table, on...))
- }
- func (m mapInfoDo) Group(cols ...field.Expr) *mapInfoDo {
- return m.withDO(m.DO.Group(cols...))
- }
- func (m mapInfoDo) Having(conds ...gen.Condition) *mapInfoDo {
- return m.withDO(m.DO.Having(conds...))
- }
- func (m mapInfoDo) Limit(limit int) *mapInfoDo {
- return m.withDO(m.DO.Limit(limit))
- }
- func (m mapInfoDo) Offset(offset int) *mapInfoDo {
- return m.withDO(m.DO.Offset(offset))
- }
- func (m mapInfoDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *mapInfoDo {
- return m.withDO(m.DO.Scopes(funcs...))
- }
- func (m mapInfoDo) Unscoped() *mapInfoDo {
- return m.withDO(m.DO.Unscoped())
- }
- func (m mapInfoDo) Create(values ...*model.MapInfo) error {
- if len(values) == 0 {
- return nil
- }
- return m.DO.Create(values)
- }
- func (m mapInfoDo) CreateInBatches(values []*model.MapInfo, batchSize int) error {
- return m.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 (m mapInfoDo) Save(values ...*model.MapInfo) error {
- if len(values) == 0 {
- return nil
- }
- return m.DO.Save(values)
- }
- func (m mapInfoDo) First() (*model.MapInfo, error) {
- if result, err := m.DO.First(); err != nil {
- return nil, err
- } else {
- return result.(*model.MapInfo), nil
- }
- }
- func (m mapInfoDo) Take() (*model.MapInfo, error) {
- if result, err := m.DO.Take(); err != nil {
- return nil, err
- } else {
- return result.(*model.MapInfo), nil
- }
- }
- func (m mapInfoDo) Last() (*model.MapInfo, error) {
- if result, err := m.DO.Last(); err != nil {
- return nil, err
- } else {
- return result.(*model.MapInfo), nil
- }
- }
- func (m mapInfoDo) Find() ([]*model.MapInfo, error) {
- result, err := m.DO.Find()
- return result.([]*model.MapInfo), err
- }
- func (m mapInfoDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.MapInfo, err error) {
- buf := make([]*model.MapInfo, 0, batchSize)
- err = m.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 (m mapInfoDo) FindInBatches(result *[]*model.MapInfo, batchSize int, fc func(tx gen.Dao, batch int) error) error {
- return m.DO.FindInBatches(result, batchSize, fc)
- }
- func (m mapInfoDo) Attrs(attrs ...field.AssignExpr) *mapInfoDo {
- return m.withDO(m.DO.Attrs(attrs...))
- }
- func (m mapInfoDo) Assign(attrs ...field.AssignExpr) *mapInfoDo {
- return m.withDO(m.DO.Assign(attrs...))
- }
- func (m mapInfoDo) Joins(fields ...field.RelationField) *mapInfoDo {
- for _, _f := range fields {
- m = *m.withDO(m.DO.Joins(_f))
- }
- return &m
- }
- func (m mapInfoDo) Preload(fields ...field.RelationField) *mapInfoDo {
- for _, _f := range fields {
- m = *m.withDO(m.DO.Preload(_f))
- }
- return &m
- }
- func (m mapInfoDo) FirstOrInit() (*model.MapInfo, error) {
- if result, err := m.DO.FirstOrInit(); err != nil {
- return nil, err
- } else {
- return result.(*model.MapInfo), nil
- }
- }
- func (m mapInfoDo) FirstOrCreate() (*model.MapInfo, error) {
- if result, err := m.DO.FirstOrCreate(); err != nil {
- return nil, err
- } else {
- return result.(*model.MapInfo), nil
- }
- }
- func (m mapInfoDo) FindByPage(offset int, limit int) (result []*model.MapInfo, count int64, err error) {
- result, err = m.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 = m.Offset(-1).Limit(-1).Count()
- return
- }
- func (m mapInfoDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
- count, err = m.Count()
- if err != nil {
- return
- }
- err = m.Offset(offset).Limit(limit).Scan(result)
- return
- }
- func (m mapInfoDo) Scan(result interface{}) (err error) {
- return m.DO.Scan(result)
- }
- func (m mapInfoDo) Delete(models ...*model.MapInfo) (result gen.ResultInfo, err error) {
- return m.DO.Delete(models)
- }
- func (m *mapInfoDo) withDO(do gen.Dao) *mapInfoDo {
- m.DO = *do.(*gen.DO)
- return m
- }
|