tutorial.gen.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  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. "wechat-api/database/dao/wechat/model"
  14. )
  15. func newTutorial(db *gorm.DB, opts ...gen.DOOption) tutorial {
  16. _tutorial := tutorial{}
  17. _tutorial.tutorialDo.UseDB(db, opts...)
  18. _tutorial.tutorialDo.UseModel(&model.Tutorial{})
  19. tableName := _tutorial.tutorialDo.TableName()
  20. _tutorial.ALL = field.NewAsterisk(tableName)
  21. _tutorial.ID = field.NewInt64(tableName, "id")
  22. _tutorial.EmployeeID = field.NewInt64(tableName, "employee_id")
  23. _tutorial.CreatedAt = field.NewTime(tableName, "created_at")
  24. _tutorial.UpdatedAt = field.NewTime(tableName, "updated_at")
  25. _tutorial.DeletedAt = field.NewField(tableName, "deleted_at")
  26. _tutorial.Index = field.NewInt64(tableName, "index")
  27. _tutorial.Title = field.NewString(tableName, "title")
  28. _tutorial.Content = field.NewString(tableName, "content")
  29. _tutorial.OrganizationID = field.NewInt64(tableName, "organization_id")
  30. _tutorial.fillFieldMap()
  31. return _tutorial
  32. }
  33. // tutorial 数字员工使用教程表
  34. type tutorial struct {
  35. tutorialDo
  36. ALL field.Asterisk
  37. ID field.Int64
  38. EmployeeID field.Int64 // 员工ID
  39. CreatedAt field.Time // Create Time | 创建日期
  40. UpdatedAt field.Time // Update Time | 修改日期
  41. DeletedAt field.Field // Delete Time | 删除日期
  42. Index field.Int64 // 序号
  43. Title field.String // 标题
  44. Content field.String // 内容
  45. OrganizationID field.Int64 // 机构ID
  46. fieldMap map[string]field.Expr
  47. }
  48. func (t tutorial) Table(newTableName string) *tutorial {
  49. t.tutorialDo.UseTable(newTableName)
  50. return t.updateTableName(newTableName)
  51. }
  52. func (t tutorial) As(alias string) *tutorial {
  53. t.tutorialDo.DO = *(t.tutorialDo.As(alias).(*gen.DO))
  54. return t.updateTableName(alias)
  55. }
  56. func (t *tutorial) updateTableName(table string) *tutorial {
  57. t.ALL = field.NewAsterisk(table)
  58. t.ID = field.NewInt64(table, "id")
  59. t.EmployeeID = field.NewInt64(table, "employee_id")
  60. t.CreatedAt = field.NewTime(table, "created_at")
  61. t.UpdatedAt = field.NewTime(table, "updated_at")
  62. t.DeletedAt = field.NewField(table, "deleted_at")
  63. t.Index = field.NewInt64(table, "index")
  64. t.Title = field.NewString(table, "title")
  65. t.Content = field.NewString(table, "content")
  66. t.OrganizationID = field.NewInt64(table, "organization_id")
  67. t.fillFieldMap()
  68. return t
  69. }
  70. func (t *tutorial) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
  71. _f, ok := t.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 (t *tutorial) fillFieldMap() {
  79. t.fieldMap = make(map[string]field.Expr, 9)
  80. t.fieldMap["id"] = t.ID
  81. t.fieldMap["employee_id"] = t.EmployeeID
  82. t.fieldMap["created_at"] = t.CreatedAt
  83. t.fieldMap["updated_at"] = t.UpdatedAt
  84. t.fieldMap["deleted_at"] = t.DeletedAt
  85. t.fieldMap["index"] = t.Index
  86. t.fieldMap["title"] = t.Title
  87. t.fieldMap["content"] = t.Content
  88. t.fieldMap["organization_id"] = t.OrganizationID
  89. }
  90. func (t tutorial) clone(db *gorm.DB) tutorial {
  91. t.tutorialDo.ReplaceConnPool(db.Statement.ConnPool)
  92. return t
  93. }
  94. func (t tutorial) replaceDB(db *gorm.DB) tutorial {
  95. t.tutorialDo.ReplaceDB(db)
  96. return t
  97. }
  98. type tutorialDo struct{ gen.DO }
  99. type ITutorialDo interface {
  100. gen.SubQuery
  101. Debug() ITutorialDo
  102. WithContext(ctx context.Context) ITutorialDo
  103. WithResult(fc func(tx gen.Dao)) gen.ResultInfo
  104. ReplaceDB(db *gorm.DB)
  105. ReadDB() ITutorialDo
  106. WriteDB() ITutorialDo
  107. As(alias string) gen.Dao
  108. Session(config *gorm.Session) ITutorialDo
  109. Columns(cols ...field.Expr) gen.Columns
  110. Clauses(conds ...clause.Expression) ITutorialDo
  111. Not(conds ...gen.Condition) ITutorialDo
  112. Or(conds ...gen.Condition) ITutorialDo
  113. Select(conds ...field.Expr) ITutorialDo
  114. Where(conds ...gen.Condition) ITutorialDo
  115. Order(conds ...field.Expr) ITutorialDo
  116. Distinct(cols ...field.Expr) ITutorialDo
  117. Omit(cols ...field.Expr) ITutorialDo
  118. Join(table schema.Tabler, on ...field.Expr) ITutorialDo
  119. LeftJoin(table schema.Tabler, on ...field.Expr) ITutorialDo
  120. RightJoin(table schema.Tabler, on ...field.Expr) ITutorialDo
  121. Group(cols ...field.Expr) ITutorialDo
  122. Having(conds ...gen.Condition) ITutorialDo
  123. Limit(limit int) ITutorialDo
  124. Offset(offset int) ITutorialDo
  125. Count() (count int64, err error)
  126. Scopes(funcs ...func(gen.Dao) gen.Dao) ITutorialDo
  127. Unscoped() ITutorialDo
  128. Create(values ...*model.Tutorial) error
  129. CreateInBatches(values []*model.Tutorial, batchSize int) error
  130. Save(values ...*model.Tutorial) error
  131. First() (*model.Tutorial, error)
  132. Take() (*model.Tutorial, error)
  133. Last() (*model.Tutorial, error)
  134. Find() ([]*model.Tutorial, error)
  135. FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Tutorial, err error)
  136. FindInBatches(result *[]*model.Tutorial, batchSize int, fc func(tx gen.Dao, batch int) error) error
  137. Pluck(column field.Expr, dest interface{}) error
  138. Delete(...*model.Tutorial) (info gen.ResultInfo, err error)
  139. Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
  140. UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
  141. Updates(value interface{}) (info gen.ResultInfo, err error)
  142. UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
  143. UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
  144. UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
  145. UpdateFrom(q gen.SubQuery) gen.Dao
  146. Attrs(attrs ...field.AssignExpr) ITutorialDo
  147. Assign(attrs ...field.AssignExpr) ITutorialDo
  148. Joins(fields ...field.RelationField) ITutorialDo
  149. Preload(fields ...field.RelationField) ITutorialDo
  150. FirstOrInit() (*model.Tutorial, error)
  151. FirstOrCreate() (*model.Tutorial, error)
  152. FindByPage(offset int, limit int) (result []*model.Tutorial, count int64, err error)
  153. ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
  154. Scan(result interface{}) (err error)
  155. Returning(value interface{}, columns ...string) ITutorialDo
  156. UnderlyingDB() *gorm.DB
  157. schema.Tabler
  158. }
  159. func (t tutorialDo) Debug() ITutorialDo {
  160. return t.withDO(t.DO.Debug())
  161. }
  162. func (t tutorialDo) WithContext(ctx context.Context) ITutorialDo {
  163. return t.withDO(t.DO.WithContext(ctx))
  164. }
  165. func (t tutorialDo) ReadDB() ITutorialDo {
  166. return t.Clauses(dbresolver.Read)
  167. }
  168. func (t tutorialDo) WriteDB() ITutorialDo {
  169. return t.Clauses(dbresolver.Write)
  170. }
  171. func (t tutorialDo) Session(config *gorm.Session) ITutorialDo {
  172. return t.withDO(t.DO.Session(config))
  173. }
  174. func (t tutorialDo) Clauses(conds ...clause.Expression) ITutorialDo {
  175. return t.withDO(t.DO.Clauses(conds...))
  176. }
  177. func (t tutorialDo) Returning(value interface{}, columns ...string) ITutorialDo {
  178. return t.withDO(t.DO.Returning(value, columns...))
  179. }
  180. func (t tutorialDo) Not(conds ...gen.Condition) ITutorialDo {
  181. return t.withDO(t.DO.Not(conds...))
  182. }
  183. func (t tutorialDo) Or(conds ...gen.Condition) ITutorialDo {
  184. return t.withDO(t.DO.Or(conds...))
  185. }
  186. func (t tutorialDo) Select(conds ...field.Expr) ITutorialDo {
  187. return t.withDO(t.DO.Select(conds...))
  188. }
  189. func (t tutorialDo) Where(conds ...gen.Condition) ITutorialDo {
  190. return t.withDO(t.DO.Where(conds...))
  191. }
  192. func (t tutorialDo) Order(conds ...field.Expr) ITutorialDo {
  193. return t.withDO(t.DO.Order(conds...))
  194. }
  195. func (t tutorialDo) Distinct(cols ...field.Expr) ITutorialDo {
  196. return t.withDO(t.DO.Distinct(cols...))
  197. }
  198. func (t tutorialDo) Omit(cols ...field.Expr) ITutorialDo {
  199. return t.withDO(t.DO.Omit(cols...))
  200. }
  201. func (t tutorialDo) Join(table schema.Tabler, on ...field.Expr) ITutorialDo {
  202. return t.withDO(t.DO.Join(table, on...))
  203. }
  204. func (t tutorialDo) LeftJoin(table schema.Tabler, on ...field.Expr) ITutorialDo {
  205. return t.withDO(t.DO.LeftJoin(table, on...))
  206. }
  207. func (t tutorialDo) RightJoin(table schema.Tabler, on ...field.Expr) ITutorialDo {
  208. return t.withDO(t.DO.RightJoin(table, on...))
  209. }
  210. func (t tutorialDo) Group(cols ...field.Expr) ITutorialDo {
  211. return t.withDO(t.DO.Group(cols...))
  212. }
  213. func (t tutorialDo) Having(conds ...gen.Condition) ITutorialDo {
  214. return t.withDO(t.DO.Having(conds...))
  215. }
  216. func (t tutorialDo) Limit(limit int) ITutorialDo {
  217. return t.withDO(t.DO.Limit(limit))
  218. }
  219. func (t tutorialDo) Offset(offset int) ITutorialDo {
  220. return t.withDO(t.DO.Offset(offset))
  221. }
  222. func (t tutorialDo) Scopes(funcs ...func(gen.Dao) gen.Dao) ITutorialDo {
  223. return t.withDO(t.DO.Scopes(funcs...))
  224. }
  225. func (t tutorialDo) Unscoped() ITutorialDo {
  226. return t.withDO(t.DO.Unscoped())
  227. }
  228. func (t tutorialDo) Create(values ...*model.Tutorial) error {
  229. if len(values) == 0 {
  230. return nil
  231. }
  232. return t.DO.Create(values)
  233. }
  234. func (t tutorialDo) CreateInBatches(values []*model.Tutorial, batchSize int) error {
  235. return t.DO.CreateInBatches(values, batchSize)
  236. }
  237. // Save : !!! underlying implementation is different with GORM
  238. // The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
  239. func (t tutorialDo) Save(values ...*model.Tutorial) error {
  240. if len(values) == 0 {
  241. return nil
  242. }
  243. return t.DO.Save(values)
  244. }
  245. func (t tutorialDo) First() (*model.Tutorial, error) {
  246. if result, err := t.DO.First(); err != nil {
  247. return nil, err
  248. } else {
  249. return result.(*model.Tutorial), nil
  250. }
  251. }
  252. func (t tutorialDo) Take() (*model.Tutorial, error) {
  253. if result, err := t.DO.Take(); err != nil {
  254. return nil, err
  255. } else {
  256. return result.(*model.Tutorial), nil
  257. }
  258. }
  259. func (t tutorialDo) Last() (*model.Tutorial, error) {
  260. if result, err := t.DO.Last(); err != nil {
  261. return nil, err
  262. } else {
  263. return result.(*model.Tutorial), nil
  264. }
  265. }
  266. func (t tutorialDo) Find() ([]*model.Tutorial, error) {
  267. result, err := t.DO.Find()
  268. return result.([]*model.Tutorial), err
  269. }
  270. func (t tutorialDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Tutorial, err error) {
  271. buf := make([]*model.Tutorial, 0, batchSize)
  272. err = t.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
  273. defer func() { results = append(results, buf...) }()
  274. return fc(tx, batch)
  275. })
  276. return results, err
  277. }
  278. func (t tutorialDo) FindInBatches(result *[]*model.Tutorial, batchSize int, fc func(tx gen.Dao, batch int) error) error {
  279. return t.DO.FindInBatches(result, batchSize, fc)
  280. }
  281. func (t tutorialDo) Attrs(attrs ...field.AssignExpr) ITutorialDo {
  282. return t.withDO(t.DO.Attrs(attrs...))
  283. }
  284. func (t tutorialDo) Assign(attrs ...field.AssignExpr) ITutorialDo {
  285. return t.withDO(t.DO.Assign(attrs...))
  286. }
  287. func (t tutorialDo) Joins(fields ...field.RelationField) ITutorialDo {
  288. for _, _f := range fields {
  289. t = *t.withDO(t.DO.Joins(_f))
  290. }
  291. return &t
  292. }
  293. func (t tutorialDo) Preload(fields ...field.RelationField) ITutorialDo {
  294. for _, _f := range fields {
  295. t = *t.withDO(t.DO.Preload(_f))
  296. }
  297. return &t
  298. }
  299. func (t tutorialDo) FirstOrInit() (*model.Tutorial, error) {
  300. if result, err := t.DO.FirstOrInit(); err != nil {
  301. return nil, err
  302. } else {
  303. return result.(*model.Tutorial), nil
  304. }
  305. }
  306. func (t tutorialDo) FirstOrCreate() (*model.Tutorial, error) {
  307. if result, err := t.DO.FirstOrCreate(); err != nil {
  308. return nil, err
  309. } else {
  310. return result.(*model.Tutorial), nil
  311. }
  312. }
  313. func (t tutorialDo) FindByPage(offset int, limit int) (result []*model.Tutorial, count int64, err error) {
  314. result, err = t.Offset(offset).Limit(limit).Find()
  315. if err != nil {
  316. return
  317. }
  318. if size := len(result); 0 < limit && 0 < size && size < limit {
  319. count = int64(size + offset)
  320. return
  321. }
  322. count, err = t.Offset(-1).Limit(-1).Count()
  323. return
  324. }
  325. func (t tutorialDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
  326. count, err = t.Count()
  327. if err != nil {
  328. return
  329. }
  330. err = t.Offset(offset).Limit(limit).Scan(result)
  331. return
  332. }
  333. func (t tutorialDo) Scan(result interface{}) (err error) {
  334. return t.DO.Scan(result)
  335. }
  336. func (t tutorialDo) Delete(models ...*model.Tutorial) (result gen.ResultInfo, err error) {
  337. return t.DO.Delete(models)
  338. }
  339. func (t *tutorialDo) withDO(do gen.Dao) *tutorialDo {
  340. t.DO = *do.(*gen.DO)
  341. return t
  342. }