123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351 |
- // 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 newSysStation(db *gorm.DB) sysStation {
- _sysStation := sysStation{}
- _sysStation.sysStationDo.UseDB(db)
- _sysStation.sysStationDo.UseModel(&model.SysStation{})
- tableName := _sysStation.sysStationDo.TableName()
- _sysStation.ALL = field.NewField(tableName, "*")
- _sysStation.ID = field.NewInt32(tableName, "id")
- _sysStation.Stationid = field.NewInt64(tableName, "stationid")
- _sysStation.Name = field.NewString(tableName, "name")
- _sysStation.Address = field.NewString(tableName, "address")
- _sysStation.Province = field.NewString(tableName, "province")
- _sysStation.Region = field.NewString(tableName, "region")
- _sysStation.Stationdesc = field.NewString(tableName, "stationdesc")
- _sysStation.CreateAt = field.NewTime(tableName, "create_at")
- _sysStation.UpdateAt = field.NewTime(tableName, "update_at")
- _sysStation.fillFieldMap()
- _sysStation.Base = newBase(tableName, db)
- return _sysStation
- }
- type sysStation struct {
- sysStationDo
- ALL field.Field
- ID field.Int32
- Stationid field.Int64
- Name field.String
- Address field.String
- Province field.String
- Region field.String
- Stationdesc field.String
- CreateAt field.Time
- UpdateAt field.Time
- fieldMap map[string]field.Expr
- }
- func (s sysStation) Table(newTableName string) *sysStation {
- s.sysStationDo.UseTable(newTableName)
- return s.updateTableName(newTableName)
- }
- func (s sysStation) As(alias string) *sysStation {
- s.sysStationDo.DO = *(s.sysStationDo.As(alias).(*gen.DO))
- return s.updateTableName(alias)
- }
- func (s *sysStation) updateTableName(table string) *sysStation {
- s.ALL = field.NewField(table, "*")
- s.ID = field.NewInt32(table, "id")
- s.Stationid = field.NewInt64(table, "stationid")
- s.Name = field.NewString(table, "name")
- s.Address = field.NewString(table, "address")
- s.Province = field.NewString(table, "province")
- s.Region = field.NewString(table, "region")
- s.Stationdesc = field.NewString(table, "stationdesc")
- s.CreateAt = field.NewTime(table, "create_at")
- s.UpdateAt = field.NewTime(table, "update_at")
- s.fillFieldMap()
- return s
- }
- func (s *sysStation) 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 *sysStation) fillFieldMap() {
- s.fieldMap = make(map[string]field.Expr, 9)
- s.fieldMap["id"] = s.ID
- s.fieldMap["stationid"] = s.Stationid
- s.fieldMap["name"] = s.Name
- s.fieldMap["address"] = s.Address
- s.fieldMap["province"] = s.Province
- s.fieldMap["region"] = s.Region
- s.fieldMap["stationdesc"] = s.Stationdesc
- s.fieldMap["create_at"] = s.CreateAt
- s.fieldMap["update_at"] = s.UpdateAt
- }
- func (s sysStation) clone(db *gorm.DB) sysStation {
- s.sysStationDo.ReplaceDB(db)
- return s
- }
- type sysStationDo struct {
- gen.DO
- Base *Base
- }
- func (s sysStationDo) Debug() *sysStationDo {
- return s.withDO(s.DO.Debug())
- }
- func (s sysStationDo) WithContext(ctx context.Context) *sysStationDo {
- return s.withDO(s.DO.WithContext(ctx))
- }
- func (s sysStationDo) ReadDB() *sysStationDo {
- return s.Clauses(dbresolver.Read)
- }
- func (s sysStationDo) WriteDB() *sysStationDo {
- return s.Clauses(dbresolver.Write)
- }
- func (s sysStationDo) Clauses(conds ...clause.Expression) *sysStationDo {
- return s.withDO(s.DO.Clauses(conds...))
- }
- func (s sysStationDo) Returning(value interface{}, columns ...string) *sysStationDo {
- return s.withDO(s.DO.Returning(value, columns...))
- }
- func (s sysStationDo) Not(conds ...gen.Condition) *sysStationDo {
- return s.withDO(s.DO.Not(conds...))
- }
- func (s sysStationDo) Or(conds ...gen.Condition) *sysStationDo {
- return s.withDO(s.DO.Or(conds...))
- }
- func (s sysStationDo) Select(conds ...field.Expr) *sysStationDo {
- return s.withDO(s.DO.Select(conds...))
- }
- func (s sysStationDo) Where(conds ...gen.Condition) *sysStationDo {
- return s.withDO(s.DO.Where(conds...))
- }
- func (s sysStationDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *sysStationDo {
- return s.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
- }
- func (s sysStationDo) Order(conds ...field.Expr) *sysStationDo {
- return s.withDO(s.DO.Order(conds...))
- }
- func (s sysStationDo) Distinct(cols ...field.Expr) *sysStationDo {
- return s.withDO(s.DO.Distinct(cols...))
- }
- func (s sysStationDo) Omit(cols ...field.Expr) *sysStationDo {
- return s.withDO(s.DO.Omit(cols...))
- }
- func (s sysStationDo) Join(table schema.Tabler, on ...field.Expr) *sysStationDo {
- return s.withDO(s.DO.Join(table, on...))
- }
- func (s sysStationDo) LeftJoin(table schema.Tabler, on ...field.Expr) *sysStationDo {
- return s.withDO(s.DO.LeftJoin(table, on...))
- }
- func (s sysStationDo) RightJoin(table schema.Tabler, on ...field.Expr) *sysStationDo {
- return s.withDO(s.DO.RightJoin(table, on...))
- }
- func (s sysStationDo) Group(cols ...field.Expr) *sysStationDo {
- return s.withDO(s.DO.Group(cols...))
- }
- func (s sysStationDo) Having(conds ...gen.Condition) *sysStationDo {
- return s.withDO(s.DO.Having(conds...))
- }
- func (s sysStationDo) Limit(limit int) *sysStationDo {
- return s.withDO(s.DO.Limit(limit))
- }
- func (s sysStationDo) Offset(offset int) *sysStationDo {
- return s.withDO(s.DO.Offset(offset))
- }
- func (s sysStationDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *sysStationDo {
- return s.withDO(s.DO.Scopes(funcs...))
- }
- func (s sysStationDo) Unscoped() *sysStationDo {
- return s.withDO(s.DO.Unscoped())
- }
- func (s sysStationDo) Create(values ...*model.SysStation) error {
- if len(values) == 0 {
- return nil
- }
- return s.DO.Create(values)
- }
- func (s sysStationDo) CreateInBatches(values []*model.SysStation, 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 sysStationDo) Save(values ...*model.SysStation) error {
- if len(values) == 0 {
- return nil
- }
- return s.DO.Save(values)
- }
- func (s sysStationDo) First() (*model.SysStation, error) {
- if result, err := s.DO.First(); err != nil {
- return nil, err
- } else {
- return result.(*model.SysStation), nil
- }
- }
- func (s sysStationDo) Take() (*model.SysStation, error) {
- if result, err := s.DO.Take(); err != nil {
- return nil, err
- } else {
- return result.(*model.SysStation), nil
- }
- }
- func (s sysStationDo) Last() (*model.SysStation, error) {
- if result, err := s.DO.Last(); err != nil {
- return nil, err
- } else {
- return result.(*model.SysStation), nil
- }
- }
- func (s sysStationDo) Find() ([]*model.SysStation, error) {
- result, err := s.DO.Find()
- return result.([]*model.SysStation), err
- }
- func (s sysStationDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.SysStation, err error) {
- buf := make([]*model.SysStation, 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 sysStationDo) FindInBatches(result *[]*model.SysStation, batchSize int, fc func(tx gen.Dao, batch int) error) error {
- return s.DO.FindInBatches(result, batchSize, fc)
- }
- func (s sysStationDo) Attrs(attrs ...field.AssignExpr) *sysStationDo {
- return s.withDO(s.DO.Attrs(attrs...))
- }
- func (s sysStationDo) Assign(attrs ...field.AssignExpr) *sysStationDo {
- return s.withDO(s.DO.Assign(attrs...))
- }
- func (s sysStationDo) Joins(fields ...field.RelationField) *sysStationDo {
- for _, _f := range fields {
- s = *s.withDO(s.DO.Joins(_f))
- }
- return &s
- }
- func (s sysStationDo) Preload(fields ...field.RelationField) *sysStationDo {
- for _, _f := range fields {
- s = *s.withDO(s.DO.Preload(_f))
- }
- return &s
- }
- func (s sysStationDo) FirstOrInit() (*model.SysStation, error) {
- if result, err := s.DO.FirstOrInit(); err != nil {
- return nil, err
- } else {
- return result.(*model.SysStation), nil
- }
- }
- func (s sysStationDo) FirstOrCreate() (*model.SysStation, error) {
- if result, err := s.DO.FirstOrCreate(); err != nil {
- return nil, err
- } else {
- return result.(*model.SysStation), nil
- }
- }
- func (s sysStationDo) FindByPage(offset int, limit int) (result []*model.SysStation, 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 sysStationDo) 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 sysStationDo) Scan(result interface{}) (err error) {
- return s.DO.Scan(result)
- }
- func (s sysStationDo) Delete(models ...*model.SysStation) (result gen.ResultInfo, err error) {
- return s.DO.Delete(models)
- }
- func (s *sysStationDo) withDO(do gen.Dao) *sysStationDo {
- s.DO = *do.(*gen.DO)
- return s
- }
|