// ==========================================================================
// 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"
)

// AdEventLogsDao is the data access object for the table ad_event_logs.
type AdEventLogsDao 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  AdEventLogsColumns // columns contains all the column names of Table for convenient usage.
	handlers []gdb.ModelHandler // handlers for customized model modification.
}

// AdEventLogsColumns defines and stores column names for the table ad_event_logs.
type AdEventLogsColumns struct {
	Id            string // 广告事件ID
	UserId        string // 用户ID
	AdsPlatId     string // 平台ID：1-META，2-ADMOB
	AdsCategoryId string // 广告类型：1-横幅，2-插页，3-激励插页，4-激励，5-原生，6-开屏
	AppPackage    string // App包名
	Status        string // 广告状态：1-拉取失败，2-拉取成功，3-显示失败，4-显示成功，5-未观看完成，6-观看完成，7-未点击，8-已点击，9-未下载，10-已下载
	StatusDesc    string // 状态描述
	CreatedAt     string // 创建时间
	UpdatedAt     string // 更新时间
	DeletedAt     string // 软删除时间戳
}

// adEventLogsColumns holds the columns for the table ad_event_logs.
var adEventLogsColumns = AdEventLogsColumns{
	Id:            "id",
	UserId:        "user_id",
	AdsPlatId:     "ads_plat_id",
	AdsCategoryId: "ads_category_id",
	AppPackage:    "app_package",
	Status:        "status",
	StatusDesc:    "status_desc",
	CreatedAt:     "created_at",
	UpdatedAt:     "updated_at",
	DeletedAt:     "deleted_at",
}

// NewAdEventLogsDao creates and returns a new DAO object for table data access.
func NewAdEventLogsDao(handlers ...gdb.ModelHandler) *AdEventLogsDao {
	return &AdEventLogsDao{
		group:    "default",
		table:    "ad_event_logs",
		columns:  adEventLogsColumns,
		handlers: handlers,
	}
}

// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *AdEventLogsDao) DB() gdb.DB {
	return g.DB(dao.group)
}

// Table returns the table name of the current DAO.
func (dao *AdEventLogsDao) Table() string {
	return dao.table
}

// Columns returns all column names of the current DAO.
func (dao *AdEventLogsDao) Columns() AdEventLogsColumns {
	return dao.columns
}

// Group returns the database configuration group name of the current DAO.
func (dao *AdEventLogsDao) 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 *AdEventLogsDao) 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 *AdEventLogsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
	return dao.Ctx(ctx).Transaction(ctx, f)
}
