enterprise.go 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. // EnterpriseDao is the manager for logic model data accessing and custom defined data operations functions management.
  11. type EnterpriseDao 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 EnterpriseColumns // Columns is the short type for Columns, which contains all the column names of Table for convenient usage.
  15. }
  16. // EnterpriseColumns defines and stores column names for table enterprise.
  17. type EnterpriseColumns struct {
  18. EnterpriseId string // 企业id
  19. Industry string // 行业,1-14分别代表能源、化工、材料、机械设备/军工、企业服务/造纸印刷、运输设备、旅游酒店、媒体/信息通信服务、批发/零售、消费品、卫生保健/医疗、金融、建材/建筑/房地产、公共事业
  20. BusinessName string // 公司或组织名称
  21. UserId string // 对应用户id
  22. Balance string // 账户余额
  23. FrozenBalance string // 冻结余额
  24. AvailableBalance string // 可用余额
  25. CreatedAt string // 创建时间
  26. UpdatedAt string // 更新时间
  27. }
  28. // enterpriseColumns holds the columns for table enterprise.
  29. var enterpriseColumns = EnterpriseColumns{
  30. EnterpriseId: "enterprise_id",
  31. Industry: "industry",
  32. BusinessName: "business_name",
  33. UserId: "user_id",
  34. Balance: "balance",
  35. FrozenBalance: "frozen_balance",
  36. AvailableBalance: "available_balance",
  37. CreatedAt: "created_at",
  38. UpdatedAt: "updated_at",
  39. }
  40. // NewEnterpriseDao creates and returns a new DAO object for table data access.
  41. func NewEnterpriseDao() *EnterpriseDao {
  42. return &EnterpriseDao{
  43. Group: "default",
  44. Table: "enterprise",
  45. Columns: enterpriseColumns,
  46. }
  47. }
  48. // DB retrieves and returns the underlying raw database management object of current DAO.
  49. func (dao *EnterpriseDao) DB() gdb.DB {
  50. return g.DB(dao.Group)
  51. }
  52. // Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
  53. func (dao *EnterpriseDao) Ctx(ctx context.Context) *gdb.Model {
  54. return dao.DB().Model(dao.Table).Safe().Ctx(ctx)
  55. }
  56. // Transaction wraps the transaction logic using function f.
  57. // It rollbacks the transaction and returns the error from function f if it returns non-nil error.
  58. // It commits the transaction and returns nil if function f returns nil.
  59. //
  60. // Note that, you should not Commit or Rollback the transaction in function f
  61. // as it is automatically handled by this function.
  62. func (dao *EnterpriseDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
  63. return dao.Ctx(ctx).Transaction(ctx, f)
  64. }