product.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. // ProductDao is the manager for logic model data accessing and custom defined data operations functions management.
  11. type ProductDao 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 ProductColumns // Columns is the short type for Columns, which contains all the column names of Table for convenient usage.
  15. }
  16. // ProductColumns defines and stores column names for table product.
  17. type ProductColumns struct {
  18. ProductId string //
  19. ProductName string // 商品名称
  20. ProductType string // 商品类型 1:实物 ,2:商品,3:线下
  21. ProductClassify string // 商品分类id(info_product_classifyh表id)
  22. ProductPrice string // 商品价格
  23. ProductSpecification string // 商品规格
  24. CreatedAt string // 创建时间
  25. CreatPeople string // 创建人
  26. UpdatedAt string // 更新时间
  27. UpdatePeople string // 更新人
  28. }
  29. // productColumns holds the columns for table product.
  30. var productColumns = ProductColumns{
  31. ProductId: "product_id",
  32. ProductName: "product_name",
  33. ProductType: "product_type",
  34. ProductClassify: "product_classify",
  35. ProductPrice: "product_price",
  36. ProductSpecification: "product_specification",
  37. CreatedAt: "created_at",
  38. CreatPeople: "creat_people",
  39. UpdatedAt: "updated_at",
  40. UpdatePeople: "update_people",
  41. }
  42. // NewProductDao creates and returns a new DAO object for table data access.
  43. func NewProductDao() *ProductDao {
  44. return &ProductDao{
  45. Group: "default",
  46. Table: "product",
  47. Columns: productColumns,
  48. }
  49. }
  50. // DB retrieves and returns the underlying raw database management object of current DAO.
  51. func (dao *ProductDao) DB() gdb.DB {
  52. return g.DB(dao.Group)
  53. }
  54. // Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
  55. func (dao *ProductDao) Ctx(ctx context.Context) *gdb.Model {
  56. return dao.DB().Model(dao.Table).Safe().Ctx(ctx)
  57. }
  58. // Transaction wraps the transaction logic using function f.
  59. // It rollbacks the transaction and returns the error from function f if it returns non-nil error.
  60. // It commits the transaction and returns nil if function f returns nil.
  61. //
  62. // Note that, you should not Commit or Rollback the transaction in function f
  63. // as it is automatically handled by this function.
  64. func (dao *ProductDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
  65. return dao.Ctx(ctx).Transaction(ctx, f)
  66. }