sys_station.gen.go 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. // Code generated by gorm.io/gen. DO NOT EDIT.
  2. // Code generated by gorm.io/gen. DO NOT EDIT.
  3. // Code generated by gorm.io/gen. DO NOT EDIT.
  4. package dao
  5. import (
  6. "context"
  7. "gorm.io/gorm"
  8. "gorm.io/gorm/clause"
  9. "gorm.io/gorm/schema"
  10. "gorm.io/gen"
  11. "gorm.io/gen/field"
  12. "gorm.io/plugin/dbresolver"
  13. "git.rtzhtech.cn/iss/public-lib/model"
  14. )
  15. func newSysStation(db *gorm.DB) sysStation {
  16. _sysStation := sysStation{}
  17. _sysStation.sysStationDo.UseDB(db)
  18. _sysStation.sysStationDo.UseModel(&model.SysStation{})
  19. tableName := _sysStation.sysStationDo.TableName()
  20. _sysStation.ALL = field.NewField(tableName, "*")
  21. _sysStation.ID = field.NewInt32(tableName, "id")
  22. _sysStation.Stationid = field.NewInt64(tableName, "stationid")
  23. _sysStation.Name = field.NewString(tableName, "name")
  24. _sysStation.Address = field.NewString(tableName, "address")
  25. _sysStation.Province = field.NewString(tableName, "province")
  26. _sysStation.Region = field.NewString(tableName, "region")
  27. _sysStation.Stationdesc = field.NewString(tableName, "stationdesc")
  28. _sysStation.CreateAt = field.NewTime(tableName, "create_at")
  29. _sysStation.UpdateAt = field.NewTime(tableName, "update_at")
  30. _sysStation.fillFieldMap()
  31. _sysStation.Base = newBase(tableName, db)
  32. return _sysStation
  33. }
  34. type sysStation struct {
  35. sysStationDo
  36. ALL field.Field
  37. ID field.Int32
  38. Stationid field.Int64
  39. Name field.String
  40. Address field.String
  41. Province field.String
  42. Region field.String
  43. Stationdesc field.String
  44. CreateAt field.Time
  45. UpdateAt field.Time
  46. fieldMap map[string]field.Expr
  47. }
  48. func (s sysStation) Table(newTableName string) *sysStation {
  49. s.sysStationDo.UseTable(newTableName)
  50. return s.updateTableName(newTableName)
  51. }
  52. func (s sysStation) As(alias string) *sysStation {
  53. s.sysStationDo.DO = *(s.sysStationDo.As(alias).(*gen.DO))
  54. return s.updateTableName(alias)
  55. }
  56. func (s *sysStation) updateTableName(table string) *sysStation {
  57. s.ALL = field.NewField(table, "*")
  58. s.ID = field.NewInt32(table, "id")
  59. s.Stationid = field.NewInt64(table, "stationid")
  60. s.Name = field.NewString(table, "name")
  61. s.Address = field.NewString(table, "address")
  62. s.Province = field.NewString(table, "province")
  63. s.Region = field.NewString(table, "region")
  64. s.Stationdesc = field.NewString(table, "stationdesc")
  65. s.CreateAt = field.NewTime(table, "create_at")
  66. s.UpdateAt = field.NewTime(table, "update_at")
  67. s.fillFieldMap()
  68. return s
  69. }
  70. func (s *sysStation) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
  71. _f, ok := s.fieldMap[fieldName]
  72. if !ok || _f == nil {
  73. return nil, false
  74. }
  75. _oe, ok := _f.(field.OrderExpr)
  76. return _oe, ok
  77. }
  78. func (s *sysStation) fillFieldMap() {
  79. s.fieldMap = make(map[string]field.Expr, 9)
  80. s.fieldMap["id"] = s.ID
  81. s.fieldMap["stationid"] = s.Stationid
  82. s.fieldMap["name"] = s.Name
  83. s.fieldMap["address"] = s.Address
  84. s.fieldMap["province"] = s.Province
  85. s.fieldMap["region"] = s.Region
  86. s.fieldMap["stationdesc"] = s.Stationdesc
  87. s.fieldMap["create_at"] = s.CreateAt
  88. s.fieldMap["update_at"] = s.UpdateAt
  89. }
  90. func (s sysStation) clone(db *gorm.DB) sysStation {
  91. s.sysStationDo.ReplaceDB(db)
  92. return s
  93. }
  94. type sysStationDo struct {
  95. gen.DO
  96. Base *Base
  97. }
  98. func (s sysStationDo) Debug() *sysStationDo {
  99. return s.withDO(s.DO.Debug())
  100. }
  101. func (s sysStationDo) WithContext(ctx context.Context) *sysStationDo {
  102. return s.withDO(s.DO.WithContext(ctx))
  103. }
  104. func (s sysStationDo) ReadDB() *sysStationDo {
  105. return s.Clauses(dbresolver.Read)
  106. }
  107. func (s sysStationDo) WriteDB() *sysStationDo {
  108. return s.Clauses(dbresolver.Write)
  109. }
  110. func (s sysStationDo) Clauses(conds ...clause.Expression) *sysStationDo {
  111. return s.withDO(s.DO.Clauses(conds...))
  112. }
  113. func (s sysStationDo) Returning(value interface{}, columns ...string) *sysStationDo {
  114. return s.withDO(s.DO.Returning(value, columns...))
  115. }
  116. func (s sysStationDo) Not(conds ...gen.Condition) *sysStationDo {
  117. return s.withDO(s.DO.Not(conds...))
  118. }
  119. func (s sysStationDo) Or(conds ...gen.Condition) *sysStationDo {
  120. return s.withDO(s.DO.Or(conds...))
  121. }
  122. func (s sysStationDo) Select(conds ...field.Expr) *sysStationDo {
  123. return s.withDO(s.DO.Select(conds...))
  124. }
  125. func (s sysStationDo) Where(conds ...gen.Condition) *sysStationDo {
  126. return s.withDO(s.DO.Where(conds...))
  127. }
  128. func (s sysStationDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *sysStationDo {
  129. return s.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
  130. }
  131. func (s sysStationDo) Order(conds ...field.Expr) *sysStationDo {
  132. return s.withDO(s.DO.Order(conds...))
  133. }
  134. func (s sysStationDo) Distinct(cols ...field.Expr) *sysStationDo {
  135. return s.withDO(s.DO.Distinct(cols...))
  136. }
  137. func (s sysStationDo) Omit(cols ...field.Expr) *sysStationDo {
  138. return s.withDO(s.DO.Omit(cols...))
  139. }
  140. func (s sysStationDo) Join(table schema.Tabler, on ...field.Expr) *sysStationDo {
  141. return s.withDO(s.DO.Join(table, on...))
  142. }
  143. func (s sysStationDo) LeftJoin(table schema.Tabler, on ...field.Expr) *sysStationDo {
  144. return s.withDO(s.DO.LeftJoin(table, on...))
  145. }
  146. func (s sysStationDo) RightJoin(table schema.Tabler, on ...field.Expr) *sysStationDo {
  147. return s.withDO(s.DO.RightJoin(table, on...))
  148. }
  149. func (s sysStationDo) Group(cols ...field.Expr) *sysStationDo {
  150. return s.withDO(s.DO.Group(cols...))
  151. }
  152. func (s sysStationDo) Having(conds ...gen.Condition) *sysStationDo {
  153. return s.withDO(s.DO.Having(conds...))
  154. }
  155. func (s sysStationDo) Limit(limit int) *sysStationDo {
  156. return s.withDO(s.DO.Limit(limit))
  157. }
  158. func (s sysStationDo) Offset(offset int) *sysStationDo {
  159. return s.withDO(s.DO.Offset(offset))
  160. }
  161. func (s sysStationDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *sysStationDo {
  162. return s.withDO(s.DO.Scopes(funcs...))
  163. }
  164. func (s sysStationDo) Unscoped() *sysStationDo {
  165. return s.withDO(s.DO.Unscoped())
  166. }
  167. func (s sysStationDo) Create(values ...*model.SysStation) error {
  168. if len(values) == 0 {
  169. return nil
  170. }
  171. return s.DO.Create(values)
  172. }
  173. func (s sysStationDo) CreateInBatches(values []*model.SysStation, batchSize int) error {
  174. return s.DO.CreateInBatches(values, batchSize)
  175. }
  176. // Save : !!! underlying implementation is different with GORM
  177. // The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
  178. func (s sysStationDo) Save(values ...*model.SysStation) error {
  179. if len(values) == 0 {
  180. return nil
  181. }
  182. return s.DO.Save(values)
  183. }
  184. func (s sysStationDo) First() (*model.SysStation, error) {
  185. if result, err := s.DO.First(); err != nil {
  186. return nil, err
  187. } else {
  188. return result.(*model.SysStation), nil
  189. }
  190. }
  191. func (s sysStationDo) Take() (*model.SysStation, error) {
  192. if result, err := s.DO.Take(); err != nil {
  193. return nil, err
  194. } else {
  195. return result.(*model.SysStation), nil
  196. }
  197. }
  198. func (s sysStationDo) Last() (*model.SysStation, error) {
  199. if result, err := s.DO.Last(); err != nil {
  200. return nil, err
  201. } else {
  202. return result.(*model.SysStation), nil
  203. }
  204. }
  205. func (s sysStationDo) Find() ([]*model.SysStation, error) {
  206. result, err := s.DO.Find()
  207. return result.([]*model.SysStation), err
  208. }
  209. func (s sysStationDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.SysStation, err error) {
  210. buf := make([]*model.SysStation, 0, batchSize)
  211. err = s.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
  212. defer func() { results = append(results, buf...) }()
  213. return fc(tx, batch)
  214. })
  215. return results, err
  216. }
  217. func (s sysStationDo) FindInBatches(result *[]*model.SysStation, batchSize int, fc func(tx gen.Dao, batch int) error) error {
  218. return s.DO.FindInBatches(result, batchSize, fc)
  219. }
  220. func (s sysStationDo) Attrs(attrs ...field.AssignExpr) *sysStationDo {
  221. return s.withDO(s.DO.Attrs(attrs...))
  222. }
  223. func (s sysStationDo) Assign(attrs ...field.AssignExpr) *sysStationDo {
  224. return s.withDO(s.DO.Assign(attrs...))
  225. }
  226. func (s sysStationDo) Joins(fields ...field.RelationField) *sysStationDo {
  227. for _, _f := range fields {
  228. s = *s.withDO(s.DO.Joins(_f))
  229. }
  230. return &s
  231. }
  232. func (s sysStationDo) Preload(fields ...field.RelationField) *sysStationDo {
  233. for _, _f := range fields {
  234. s = *s.withDO(s.DO.Preload(_f))
  235. }
  236. return &s
  237. }
  238. func (s sysStationDo) FirstOrInit() (*model.SysStation, error) {
  239. if result, err := s.DO.FirstOrInit(); err != nil {
  240. return nil, err
  241. } else {
  242. return result.(*model.SysStation), nil
  243. }
  244. }
  245. func (s sysStationDo) FirstOrCreate() (*model.SysStation, error) {
  246. if result, err := s.DO.FirstOrCreate(); err != nil {
  247. return nil, err
  248. } else {
  249. return result.(*model.SysStation), nil
  250. }
  251. }
  252. func (s sysStationDo) FindByPage(offset int, limit int) (result []*model.SysStation, count int64, err error) {
  253. result, err = s.Offset(offset).Limit(limit).Find()
  254. if err != nil {
  255. return
  256. }
  257. if size := len(result); 0 < limit && 0 < size && size < limit {
  258. count = int64(size + offset)
  259. return
  260. }
  261. count, err = s.Offset(-1).Limit(-1).Count()
  262. return
  263. }
  264. func (s sysStationDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
  265. count, err = s.Count()
  266. if err != nil {
  267. return
  268. }
  269. err = s.Offset(offset).Limit(limit).Scan(result)
  270. return
  271. }
  272. func (s sysStationDo) Scan(result interface{}) (err error) {
  273. return s.DO.Scan(result)
  274. }
  275. func (s sysStationDo) Delete(models ...*model.SysStation) (result gen.ResultInfo, err error) {
  276. return s.DO.Delete(models)
  277. }
  278. func (s *sysStationDo) withDO(do gen.Dao) *sysStationDo {
  279. s.DO = *do.(*gen.DO)
  280. return s
  281. }