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

// ExpertDao is the manager for logic model data accessing and custom defined data operations functions management.
type ExpertDao 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 ExpertColumns // Columns is the short type for Columns, which contains all the column names of Table for convenient usage.
}

// ExpertColumns defines and stores column names for table expert.
type ExpertColumns struct {
	Id             string // 达人表ID      
    AgeRange       string // 达人年龄区间  
    SkinChoose     string // 肤质选择      
    Nationality    string // 国籍          
    AgentShopArea  string // 探店区域      
    Gender         string // 性别          
    WechatId       string // 微信号
}

//  expertColumns holds the columns for table expert.
var expertColumns = ExpertColumns{
	Id:            "id",               
            AgeRange:      "age_range",        
            SkinChoose:    "skin_choose",      
            Nationality:   "nationality",      
            AgentShopArea: "agent_shop_area",  
            Gender:        "gender",           
            WechatId:      "wechat_id",
}

// NewExpertDao creates and returns a new DAO object for table data access.
func NewExpertDao() *ExpertDao {
	return &ExpertDao{
		Group:   "default",
		Table:   "expert",
		Columns: expertColumns,
	}
}

// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *ExpertDao) 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 *ExpertDao) 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 *ExpertDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
	return dao.Ctx(ctx).Transaction(ctx, f)
}