enterprise.go 3.3 KB

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