Files
olons_admin/server/internal/dao/internal/dashboard_daily_stat.go
T
2026-10-10 20:56:17 +08:00

100 lines
3.6 KiB
Go

// ==========================================================================
// 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"
)
// DashboardDailyStatDao is the data access object for the table hg_dashboard_daily_stat.
type DashboardDailyStatDao 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 DashboardDailyStatColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// DashboardDailyStatColumns defines and stores column names for the table hg_dashboard_daily_stat.
type DashboardDailyStatColumns struct {
Id string // 主键
TenantId string // 租户ID
StatDate string // 统计日期
DimensionType string // 维度类型
DimensionValue string // 维度值
MetricCode string // 指标编码
MetricCount string // 指标数量
MetricAmount string // 指标金额(最小货币单位)
CalculatedAt string // 计算时间
CreatedAt string // 创建时间
UpdatedAt string // 更新时间
}
// dashboardDailyStatColumns holds the columns for the table hg_dashboard_daily_stat.
var dashboardDailyStatColumns = DashboardDailyStatColumns{
Id: "id",
TenantId: "tenant_id",
StatDate: "stat_date",
DimensionType: "dimension_type",
DimensionValue: "dimension_value",
MetricCode: "metric_code",
MetricCount: "metric_count",
MetricAmount: "metric_amount",
CalculatedAt: "calculated_at",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
}
// NewDashboardDailyStatDao creates and returns a new DAO object for table data access.
func NewDashboardDailyStatDao(handlers ...gdb.ModelHandler) *DashboardDailyStatDao {
return &DashboardDailyStatDao{
group: "default",
table: "hg_dashboard_daily_stat",
columns: dashboardDailyStatColumns,
handlers: handlers,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *DashboardDailyStatDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *DashboardDailyStatDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *DashboardDailyStatDao) Columns() DashboardDailyStatColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *DashboardDailyStatDao) 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 *DashboardDailyStatDao) 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 *DashboardDailyStatDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}