info_bank.go 2.1 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. // InfoBankDao is the manager for logic model data accessing and custom defined data operations functions management.
  11. type InfoBankDao 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 InfoBankColumns // Columns is the short type for Columns, which contains all the column names of Table for convenient usage.
  15. }
  16. // InfoBankColumns defines and stores column names for table info_bank.
  17. type InfoBankColumns struct {
  18. Id string // 银行id
  19. Name string // 银行名称
  20. }
  21. // infoBankColumns holds the columns for table info_bank.
  22. var infoBankColumns = InfoBankColumns{
  23. Id: "id",
  24. Name: "name",
  25. }
  26. // NewInfoBankDao creates and returns a new DAO object for table data access.
  27. func NewInfoBankDao() *InfoBankDao {
  28. return &InfoBankDao{
  29. Group: "default",
  30. Table: "info_bank",
  31. Columns: infoBankColumns,
  32. }
  33. }
  34. // DB retrieves and returns the underlying raw database management object of current DAO.
  35. func (dao *InfoBankDao) 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 *InfoBankDao) 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 *InfoBankDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
  49. return dao.Ctx(ctx).Transaction(ctx, f)
  50. }