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

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

// V1SysUserLoginLogColumns defines and stores column names for the table sys_user_login_log.
type V1SysUserLoginLogColumns struct {
	Id            string //
	UserId        string //
	LoginName     string // 登录名
	IpAddr        string // 登录IP
	LoginLocation string // 登录地点
	UserAgent     string //
	Browser       string //
	Os            string //
	CreatedAt     string // 登录时间
	Status        string // 登录状态 1登录成功2登录失败
	Message       string //
	LoginTime     string // 登录时长
	Module        string //
}

// v1SysUserLoginLogColumns holds the columns for the table sys_user_login_log.
var v1SysUserLoginLogColumns = V1SysUserLoginLogColumns{
	Id:            "id",
	UserId:        "user_id",
	LoginName:     "login_name",
	IpAddr:        "ip_addr",
	LoginLocation: "login_location",
	UserAgent:     "user_agent",
	Browser:       "browser",
	Os:            "os",
	CreatedAt:     "created_at",
	Status:        "status",
	Message:       "message",
	LoginTime:     "login_time",
	Module:        "module",
}

// NewV1SysUserLoginLogDao creates and returns a new DAO object for table data access.
func NewV1SysUserLoginLogDao(handlers ...gdb.ModelHandler) *V1SysUserLoginLogDao {
	return &V1SysUserLoginLogDao{
		group:    "default",
		table:    "sys_user_login_log",
		columns:  v1SysUserLoginLogColumns,
		handlers: handlers,
	}
}

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

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

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

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