// ==========================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================

package internal

import (
	"context"
	"github.com/gogf/gf/database/gdb"
	"github.com/gogf/gf/frame/g"
)

// YounggeeUserDao is the manager for logic model data accessing and custom defined data operations functions management.
type YounggeeUserDao struct {
	Table   string              // Table is the underlying table name of the DAO.
	Group   string              // Group is the database configuration group name of current DAO.
	Columns YounggeeUserColumns // Columns is the short type for Columns, which contains all the column names of Table for convenient usage.
}

// YounggeeUserColumns defines and stores column names for table younggee_user.
type YounggeeUserColumns struct {
	Id            string // 用户表id
	User          string // 账号
	Username      string // 后台用户名
	Password      string // 用户密码
	RealName      string // 真实姓名
	Role          string // 角色 1，超级管理员； 2，管理员；3，企业用户
	Phone         string // 绑定手机
	Email         string // 电子邮件
	LastLoginTime string // 最后一次登录时间
	UserState     string // 0，禁用，1，正常
	CreatedAt     string // 创建时间
	UpdatedAt     string // 更新时间
}

//  younggeeUserColumns holds the columns for table younggee_user.
var younggeeUserColumns = YounggeeUserColumns{
	Id:            "id",
	User:          "user",
	Username:      "username",
	Password:      "password",
	RealName:      "real_name",
	Role:          "role",
	Phone:         "phone",
	Email:         "email",
	LastLoginTime: "last_login_time",
	UserState:     "user_state",
	CreatedAt:     "created_at",
	UpdatedAt:     "updated_at",
}

// NewYounggeeUserDao creates and returns a new DAO object for table data access.
func NewYounggeeUserDao() *YounggeeUserDao {
	return &YounggeeUserDao{
		Group:   "default",
		Table:   "younggee_user",
		Columns: younggeeUserColumns,
	}
}

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

// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *YounggeeUserDao) Ctx(ctx context.Context) *gdb.Model {
	return dao.DB().Model(dao.Table).Safe().Ctx(ctx)
}

// Transaction wraps the transaction logic using function f.
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note that, you should not Commit or Rollback the transaction in function f
// as it is automatically handled by this function.
func (dao *YounggeeUserDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
	return dao.Ctx(ctx).Transaction(ctx, f)
}
