package util

import (
	"bwallet/pkg/setting"
	"strconv"
)

// Setup Initialize the util
func Setup() {
	jwtSecret = []byte(setting.AppSetting.JwtSecret)
}

func ToInt(o interface{}) int {
	if o == nil {
		return 1
	}
	switch t := o.(type) {
	case float64:
		return int(t)
	case int:
		return int(t)
	case int64:
		return int(t)
	case string:
		tInt, err := strconv.Atoi(t)
		if err != nil {
			return -1
		}
		return tInt
	default:
		return -1
	}
}