info_region.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. // InfoRegionDao is the manager for logic model data accessing and custom defined data operations functions management.
  11. type InfoRegionDao 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 InfoRegionColumns // Columns is the short type for Columns, which contains all the column names of Table for convenient usage.
  15. }
  16. // InfoRegionColumns defines and stores column names for table info_region.
  17. type InfoRegionColumns struct {
  18. RegionId string //
  19. SelfCode string //
  20. RegionLevel string //
  21. ParentCode string //
  22. RegionName string //
  23. }
  24. // infoRegionColumns holds the columns for table info_region.
  25. var infoRegionColumns = InfoRegionColumns{
  26. RegionId: "region_id",
  27. SelfCode: "self_code",
  28. RegionLevel: "region_level",
  29. ParentCode: "parent_code",
  30. RegionName: "region_name",
  31. }
  32. // NewInfoRegionDao creates and returns a new DAO object for table data access.
  33. func NewInfoRegionDao() *InfoRegionDao {
  34. return &InfoRegionDao{
  35. Group: "default",
  36. Table: "info_region",
  37. Columns: infoRegionColumns,
  38. }
  39. }
  40. // DB retrieves and returns the underlying raw database management object of current DAO.
  41. func (dao *InfoRegionDao) DB() gdb.DB {
  42. return g.DB(dao.Group)
  43. }
  44. // Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
  45. func (dao *InfoRegionDao) Ctx(ctx context.Context) *gdb.Model {
  46. return dao.DB().Model(dao.Table).Safe().Ctx(ctx)
  47. }
  48. // Transaction wraps the transaction logic using function f.
  49. // It rollbacks the transaction and returns the error from function f if it returns non-nil error.
  50. // It commits the transaction and returns nil if function f returns nil.
  51. //
  52. // Note that, you should not Commit or Rollback the transaction in function f
  53. // as it is automatically handled by this function.
  54. func (dao *InfoRegionDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
  55. return dao.Ctx(ctx).Transaction(ctx, f)
  56. }