info_message.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // ==========================================================================
  2. // Code generated by GoFrame CLI tool. DO NOT EDIT.
  3. // ==========================================================================
  4. package internal
  5. import (
  6. "context"
  7. "github.com/gogf/gf/database/gdb"
  8. "github.com/gogf/gf/frame/g"
  9. )
  10. // InfoMessageDao is the manager for logic model data accessing and custom defined data operations functions management.
  11. type InfoMessageDao 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 InfoMessageColumns // Columns is the short type for Columns, which contains all the column names of Table for convenient usage.
  15. }
  16. // InfoMessageColumns defines and stores column names for table info_message.
  17. type InfoMessageColumns struct {
  18. Id string // 消息类型id
  19. Text string // 消息内容
  20. }
  21. // infoMessageColumns holds the columns for table info_message.
  22. var infoMessageColumns = InfoMessageColumns{
  23. Id: "id",
  24. Text: "text",
  25. }
  26. // NewInfoMessageDao creates and returns a new DAO object for table data access.
  27. func NewInfoMessageDao() *InfoMessageDao {
  28. return &InfoMessageDao{
  29. Group: "default",
  30. Table: "info_message",
  31. Columns: infoMessageColumns,
  32. }
  33. }
  34. // DB retrieves and returns the underlying raw database management object of current DAO.
  35. func (dao *InfoMessageDao) DB() gdb.DB {
  36. return g.DB(dao.Group)
  37. }
  38. // Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
  39. func (dao *InfoMessageDao) Ctx(ctx context.Context) *gdb.Model {
  40. return dao.DB().Model(dao.Table).Safe().Ctx(ctx)
  41. }
  42. // Transaction wraps the transaction logic using function f.
  43. // It rollbacks the transaction and returns the error from function f if it returns non-nil error.
  44. // It commits the transaction and returns nil if function f returns nil.
  45. //
  46. // Note that, you should not Commit or Rollback the transaction in function f
  47. // as it is automatically handled by this function.
  48. func (dao *InfoMessageDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
  49. return dao.Ctx(ctx).Transaction(ctx, f)
  50. }