expert.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. // ExpertDao is the manager for logic model data accessing and custom defined data operations functions management.
  11. type ExpertDao 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 ExpertColumns // Columns is the short type for Columns, which contains all the column names of Table for convenient usage.
  15. }
  16. // ExpertColumns defines and stores column names for table expert.
  17. type ExpertColumns struct {
  18. Id string // 达人表ID
  19. AgeRange string // 达人年龄区间
  20. SkinChoose string // 肤质选择
  21. Nationality string // 国籍
  22. AgentShopArea string // 探店区域
  23. Gender string // 性别
  24. WechatId string // 微信号
  25. }
  26. // expertColumns holds the columns for table expert.
  27. var expertColumns = ExpertColumns{
  28. Id: "id",
  29. AgeRange: "age_range",
  30. SkinChoose: "skin_choose",
  31. Nationality: "nationality",
  32. AgentShopArea: "agent_shop_area",
  33. Gender: "gender",
  34. WechatId: "wechat_id",
  35. }
  36. // NewExpertDao creates and returns a new DAO object for table data access.
  37. func NewExpertDao() *ExpertDao {
  38. return &ExpertDao{
  39. Group: "default",
  40. Table: "expert",
  41. Columns: expertColumns,
  42. }
  43. }
  44. // DB retrieves and returns the underlying raw database management object of current DAO.
  45. func (dao *ExpertDao) DB() gdb.DB {
  46. return g.DB(dao.Group)
  47. }
  48. // Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
  49. func (dao *ExpertDao) Ctx(ctx context.Context) *gdb.Model {
  50. return dao.DB().Model(dao.Table).Safe().Ctx(ctx)
  51. }
  52. // Transaction wraps the transaction logic using function f.
  53. // It rollbacks the transaction and returns the error from function f if it returns non-nil error.
  54. // It commits the transaction and returns nil if function f returns nil.
  55. //
  56. // Note that, you should not Commit or Rollback the transaction in function f
  57. // as it is automatically handled by this function.
  58. func (dao *ExpertDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
  59. return dao.Ctx(ctx).Transaction(ctx, f)
  60. }