package itypes

import (
	"os"
	"path/filepath"
)

var (
	DefaultStaticHome  = os.ExpandEnv(filepath.Join("$HOME", ".intent-system/static"))
	DefaultDocsHome    = os.ExpandEnv(filepath.Join("$HOME", ".intent-system/docs"))
	DefaultImagesHome  = os.ExpandEnv(filepath.Join("$HOME", ".intent-system/images"))
	DefaultConfigHome  = os.ExpandEnv(filepath.Join("$HOME", ".intent-system/config"))
	DefaultLevelDBHome = os.ExpandEnv(filepath.Join("$HOME", ".intent-system/db"))
)

type Context struct {
	*Session
}

type Session struct {
	UserId      int32  `json:"user_id" db:"user_id"`
	UserName    string `json:"user_name" db:"user_name"`
	Email       string `json:"email" db:"email"`
	Alias       string `json:"alias" db:"alias"`
	PhoneNumber string `json:"phone_number" db:"phone_number"`
	IsAdmin     bool   `json:"is_admin" db:"is_admin"`
	LoginIP     string `json:"login_ip" db:"login_ip"`
	AuthToken   string `json:"auth_token" db:"auth_token"`
	LoginMode   int8   `json:"login_mode" db:"login_mode"`
	IsCustomer  bool   `json:"is_customer" db:"is_custom"`
}

func (ctx *Context) UserId() int32 {
	return ctx.Session.UserId
}

func (ctx *Context) AuthToken() string {
	return ctx.Session.AuthToken
}

func (ctx *Context) UserName() string {
	return ctx.Session.UserName
}

func (ctx *Context) Address() string {
	return ctx.Session.UserName
}

func (ctx *Context) Alias() string {
	return ctx.Session.Alias
}

func (ctx *Context) PhoneNumber() string {
	return ctx.Session.PhoneNumber
}

func (ctx *Context) LoginIP() string {
	return ctx.Session.LoginIP
}

func (ctx *Context) IsAdmin() bool {
	return ctx.Session.IsAdmin
}

func (ctx *Context) LoginMode() int8 {
	return ctx.Session.LoginMode
}

func (ctx *Context) GetEmail() string {
	return ctx.Session.Email
}
