map_zone.gen.go 8.5 KB

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