You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.7 KiB

11 months ago
  1. // ==========================================================================
  2. // Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
  3. // ==========================================================================
  4. package internal
  5. import (
  6. "context"
  7. "github.com/gogf/gf/v2/database/gdb"
  8. "github.com/gogf/gf/v2/frame/g"
  9. )
  10. // FavoriteDao is the data access object for table cms_favorite.
  11. type FavoriteDao struct {
  12. table string // table is the underlying table name of the DAO.
  13. group string // group is the database configuration group name of current DAO.
  14. columns FavoriteColumns // columns contains all the column names of Table for convenient usage.
  15. }
  16. // FavoriteColumns defines and stores column names for table cms_favorite.
  17. type FavoriteColumns struct {
  18. Id string //
  19. VideoId string //
  20. VideoTitle string //
  21. VideoPic string //
  22. UserId string //
  23. RecordId string //
  24. CreatedAt string //
  25. UpdatedAt string //
  26. }
  27. // favoriteColumns holds the columns for table cms_favorite.
  28. var favoriteColumns = FavoriteColumns{
  29. Id: "id",
  30. VideoId: "video_id",
  31. VideoTitle: "video_title",
  32. VideoPic: "video_pic",
  33. UserId: "user_id",
  34. RecordId: "record_id",
  35. CreatedAt: "created_at",
  36. UpdatedAt: "updated_at",
  37. }
  38. // NewFavoriteDao creates and returns a new DAO object for table data access.
  39. func NewFavoriteDao() *FavoriteDao {
  40. return &FavoriteDao{
  41. group: "cms",
  42. table: "cms_favorite",
  43. columns: favoriteColumns,
  44. }
  45. }
  46. // DB retrieves and returns the underlying raw database management object of current DAO.
  47. func (dao *FavoriteDao) DB() gdb.DB {
  48. return g.DB(dao.group)
  49. }
  50. // Table returns the table name of current dao.
  51. func (dao *FavoriteDao) Table() string {
  52. return dao.table
  53. }
  54. // Columns returns all column names of current dao.
  55. func (dao *FavoriteDao) Columns() FavoriteColumns {
  56. return dao.columns
  57. }
  58. // Group returns the configuration group name of database of current dao.
  59. func (dao *FavoriteDao) Group() string {
  60. return dao.group
  61. }
  62. // Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
  63. func (dao *FavoriteDao) Ctx(ctx context.Context) *gdb.Model {
  64. return dao.DB().Model(dao.table).Safe().Ctx(ctx)
  65. }
  66. // Transaction wraps the transaction logic using function f.
  67. // It rollbacks the transaction and returns the error from function f if it returns non-nil error.
  68. // It commits the transaction and returns nil if function f returns nil.
  69. //
  70. // Note that, you should not Commit or Rollback the transaction in function f
  71. // as it is automatically handled by this function.
  72. func (dao *FavoriteDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
  73. return dao.Ctx(ctx).Transaction(ctx, f)
  74. }