feat: add Go backend
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
// ==========================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// ProductDao is the data access object for the table hg_product.
|
||||
type ProductDao struct {
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
columns ProductColumns // columns contains all the column names of Table for convenient usage.
|
||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||
}
|
||||
|
||||
// ProductColumns defines and stores column names for the table hg_product.
|
||||
type ProductColumns struct {
|
||||
Id string // 主键
|
||||
TenantId string // 租户ID
|
||||
ProductNo string // 商品编号
|
||||
CategoryId string // 分类ID
|
||||
ProductType string // 商品类型
|
||||
PaymentType string // 支付方式
|
||||
Name string // 商品名称
|
||||
ShopName string // 店铺名称
|
||||
PriceAmount string // 单价(分)
|
||||
Currency string // 币种
|
||||
CoverAttachmentId string // 封面附件ID
|
||||
CoverUrl string // 封面URL
|
||||
DetailHtml string // 商品详情
|
||||
IsRecommended string // 是否推荐
|
||||
PublishStatus string // 发布状态
|
||||
StartAt string // 展示开始时间
|
||||
EndAt string // 展示结束时间
|
||||
Sort string // 排序
|
||||
Version string // 乐观锁
|
||||
Remark string // 备注
|
||||
CreatedBy string // 创建者
|
||||
UpdatedBy string // 更新者
|
||||
DeletedBy string // 删除者
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 更新时间
|
||||
DeletedAt string // 删除时间
|
||||
}
|
||||
|
||||
// productColumns holds the columns for the table hg_product.
|
||||
var productColumns = ProductColumns{
|
||||
Id: "id",
|
||||
TenantId: "tenant_id",
|
||||
ProductNo: "product_no",
|
||||
CategoryId: "category_id",
|
||||
ProductType: "product_type",
|
||||
PaymentType: "payment_type",
|
||||
Name: "name",
|
||||
ShopName: "shop_name",
|
||||
PriceAmount: "price_amount",
|
||||
Currency: "currency",
|
||||
CoverAttachmentId: "cover_attachment_id",
|
||||
CoverUrl: "cover_url",
|
||||
DetailHtml: "detail_html",
|
||||
IsRecommended: "is_recommended",
|
||||
PublishStatus: "publish_status",
|
||||
StartAt: "start_at",
|
||||
EndAt: "end_at",
|
||||
Sort: "sort",
|
||||
Version: "version",
|
||||
Remark: "remark",
|
||||
CreatedBy: "created_by",
|
||||
UpdatedBy: "updated_by",
|
||||
DeletedBy: "deleted_by",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
DeletedAt: "deleted_at",
|
||||
}
|
||||
|
||||
// NewProductDao creates and returns a new DAO object for table data access.
|
||||
func NewProductDao(handlers ...gdb.ModelHandler) *ProductDao {
|
||||
return &ProductDao{
|
||||
group: "default",
|
||||
table: "hg_product",
|
||||
columns: productColumns,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||
func (dao *ProductDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
func (dao *ProductDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
func (dao *ProductDao) Columns() ProductColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
func (dao *ProductDao) Group() string {
|
||||
return dao.group
|
||||
}
|
||||
|
||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||
func (dao *ProductDao) Ctx(ctx context.Context) *gdb.Model {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
model = handler(model)
|
||||
}
|
||||
return model.Safe().Ctx(ctx)
|
||||
}
|
||||
|
||||
// Transaction wraps the transaction logic using function f.
|
||||
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||
// It commits the transaction and returns nil if function f returns nil.
|
||||
//
|
||||
// Note: Do not commit or roll back the transaction in function f,
|
||||
// as it is automatically handled by this function.
|
||||
func (dao *ProductDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
Reference in New Issue
Block a user