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.

81 lines
2.5 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. // ConfigDao is the data access object for table cms_config.
  11. type ConfigDao 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 ConfigColumns // columns contains all the column names of Table for convenient usage.
  15. }
  16. // ConfigColumns defines and stores column names for table cms_config.
  17. type ConfigColumns struct {
  18. Id string //
  19. Name string //
  20. Value string //
  21. CreatedAt string // 创建时间
  22. UpdatedAt string // 更新时间
  23. }
  24. // configColumns holds the columns for table cms_config.
  25. var configColumns = ConfigColumns{
  26. Id: "id",
  27. Name: "name",
  28. Value: "value",
  29. CreatedAt: "created_at",
  30. UpdatedAt: "updated_at",
  31. }
  32. // NewConfigDao creates and returns a new DAO object for table data access.
  33. func NewConfigDao() *ConfigDao {
  34. return &ConfigDao{
  35. group: "cms",
  36. table: "cms_config",
  37. columns: configColumns,
  38. }
  39. }
  40. // DB retrieves and returns the underlying raw database management object of current DAO.
  41. func (dao *ConfigDao) DB() gdb.DB {
  42. return g.DB(dao.group)
  43. }
  44. // Table returns the table name of current dao.
  45. func (dao *ConfigDao) Table() string {
  46. return dao.table
  47. }
  48. // Columns returns all column names of current dao.
  49. func (dao *ConfigDao) Columns() ConfigColumns {
  50. return dao.columns
  51. }
  52. // Group returns the configuration group name of database of current dao.
  53. func (dao *ConfigDao) Group() string {
  54. return dao.group
  55. }
  56. // Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
  57. func (dao *ConfigDao) Ctx(ctx context.Context) *gdb.Model {
  58. return dao.DB().Model(dao.table).Safe().Ctx(ctx)
  59. }
  60. // Transaction wraps the transaction logic using function f.
  61. // It rollbacks the transaction and returns the error from function f if it returns non-nil error.
  62. // It commits the transaction and returns nil if function f returns nil.
  63. //
  64. // Note that, you should not Commit or Rollback the transaction in function f
  65. // as it is automatically handled by this function.
  66. func (dao *ConfigDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
  67. return dao.Ctx(ctx).Transaction(ctx, f)
  68. }