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.

101 lines
3.1 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. // CategoryDao is the data access object for table cms_category.
  11. type CategoryDao 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 CategoryColumns // columns contains all the column names of Table for convenient usage.
  15. }
  16. // CategoryColumns defines and stores column names for table cms_category.
  17. type CategoryColumns struct {
  18. Id string //
  19. ParentId string // 父节点
  20. Name string // 分类名字
  21. Union string // 关联
  22. Sort string // 排序
  23. Status string // 状态
  24. SeoTitle string //
  25. SeoKey string //
  26. SeoDes string //
  27. TplIndex string // Index
  28. TplList string // List
  29. TplDetail string // Detail
  30. TplDown string // Down
  31. TplPlay string // player
  32. Extend string // 扩展属性 集合
  33. }
  34. // categoryColumns holds the columns for table cms_category.
  35. var categoryColumns = CategoryColumns{
  36. Id: "id",
  37. ParentId: "parent_id",
  38. Name: "name",
  39. Union: "union",
  40. Sort: "sort",
  41. Status: "status",
  42. SeoTitle: "seo_title",
  43. SeoKey: "seo_key",
  44. SeoDes: "seo_des",
  45. TplIndex: "tpl_index",
  46. TplList: "tpl_list",
  47. TplDetail: "tpl_detail",
  48. TplDown: "tpl_down",
  49. TplPlay: "tpl_play",
  50. Extend: "extend",
  51. }
  52. // NewCategoryDao creates and returns a new DAO object for table data access.
  53. func NewCategoryDao() *CategoryDao {
  54. return &CategoryDao{
  55. group: "cms",
  56. table: "cms_category",
  57. columns: categoryColumns,
  58. }
  59. }
  60. // DB retrieves and returns the underlying raw database management object of current DAO.
  61. func (dao *CategoryDao) DB() gdb.DB {
  62. return g.DB(dao.group)
  63. }
  64. // Table returns the table name of current dao.
  65. func (dao *CategoryDao) Table() string {
  66. return dao.table
  67. }
  68. // Columns returns all column names of current dao.
  69. func (dao *CategoryDao) Columns() CategoryColumns {
  70. return dao.columns
  71. }
  72. // Group returns the configuration group name of database of current dao.
  73. func (dao *CategoryDao) Group() string {
  74. return dao.group
  75. }
  76. // Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
  77. func (dao *CategoryDao) Ctx(ctx context.Context) *gdb.Model {
  78. return dao.DB().Model(dao.table).Safe().Ctx(ctx)
  79. }
  80. // Transaction wraps the transaction logic using function f.
  81. // It rollbacks the transaction and returns the error from function f if it returns non-nil error.
  82. // It commits the transaction and returns nil if function f returns nil.
  83. //
  84. // Note that, you should not Commit or Rollback the transaction in function f
  85. // as it is automatically handled by this function.
  86. func (dao *CategoryDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
  87. return dao.Ctx(ctx).Transaction(ctx, f)
  88. }