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

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

// V1CamelOilAccountColumns defines and stores column names for the table camel_oil_account.
type V1CamelOilAccountColumns struct {
	Id              string // 主键ID
	AccountName     string // 账号名称（备注）
	Phone           string // 手机号（登录后记录，不可重复）
	Token           string // 登录Token
	Status          string // 状态：1待登录 2在线 3暂停 4已失效 5登录失败
	TokenExpireAt   string // Token过期时间
	LastLoginAt     string // 最后登录时间
	LastUsedAt      string // 最后使用时间
	DailyOrderCount string // 当日已下单数量
	DailyOrderDate  string // 当日订单日期
	TotalOrderCount string // 累计下单数量
	FailureReason   string // 失败原因
	Remark          string // 备注信息
	CreatedAt       string // 创建时间
	UpdatedAt       string // 更新时间
	DeletedAt       string // 删除时间（软删除）
}

// v1CamelOilAccountColumns holds the columns for the table camel_oil_account.
var v1CamelOilAccountColumns = V1CamelOilAccountColumns{
	Id:              "id",
	AccountName:     "account_name",
	Phone:           "phone",
	Token:           "token",
	Status:          "status",
	TokenExpireAt:   "token_expire_at",
	LastLoginAt:     "last_login_at",
	LastUsedAt:      "last_used_at",
	DailyOrderCount: "daily_order_count",
	DailyOrderDate:  "daily_order_date",
	TotalOrderCount: "total_order_count",
	FailureReason:   "failure_reason",
	Remark:          "remark",
	CreatedAt:       "created_at",
	UpdatedAt:       "updated_at",
	DeletedAt:       "deleted_at",
}

// NewV1CamelOilAccountDao creates and returns a new DAO object for table data access.
func NewV1CamelOilAccountDao(handlers ...gdb.ModelHandler) *V1CamelOilAccountDao {
	return &V1CamelOilAccountDao{
		group:    "default",
		table:    "camel_oil_account",
		columns:  v1CamelOilAccountColumns,
		handlers: handlers,
	}
}

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

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

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

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