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