mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-18 08:44:25 +08:00
add comments
This commit is contained in:
@@ -20,23 +20,29 @@ const (
|
|||||||
defaultStaticRootPath = "public"
|
defaultStaticRootPath = "public"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// SystemMode represents running mode of system
|
||||||
type SystemMode string
|
type SystemMode string
|
||||||
|
|
||||||
|
// System running modes
|
||||||
const (
|
const (
|
||||||
MODE_DEVELOPMENT SystemMode = "development"
|
MODE_DEVELOPMENT SystemMode = "development"
|
||||||
MODE_PRODUCTION SystemMode = "production"
|
MODE_PRODUCTION SystemMode = "production"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Scheme represents how the web backend service exposes
|
||||||
type Scheme string
|
type Scheme string
|
||||||
|
|
||||||
|
// Scheme types
|
||||||
const (
|
const (
|
||||||
SCHEME_HTTP Scheme = "http"
|
SCHEME_HTTP Scheme = "http"
|
||||||
SCHEME_HTTPS Scheme = "https"
|
SCHEME_HTTPS Scheme = "https"
|
||||||
SCHEME_SOCKET Scheme = "socket"
|
SCHEME_SOCKET Scheme = "socket"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Level represents log level
|
||||||
type Level string
|
type Level string
|
||||||
|
|
||||||
|
// Log levels
|
||||||
const (
|
const (
|
||||||
LOGLEVEL_DEBUG Level = "debug"
|
LOGLEVEL_DEBUG Level = "debug"
|
||||||
LOGLEVEL_INFO Level = "info"
|
LOGLEVEL_INFO Level = "info"
|
||||||
@@ -44,12 +50,14 @@ const (
|
|||||||
LOGLEVEL_ERROR Level = "error"
|
LOGLEVEL_ERROR Level = "error"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Database types
|
||||||
const (
|
const (
|
||||||
MySqlDbType string = "mysql"
|
MySqlDbType string = "mysql"
|
||||||
PostgresDbType string = "postgres"
|
PostgresDbType string = "postgres"
|
||||||
Sqlite3DbType string = "sqlite3"
|
Sqlite3DbType string = "sqlite3"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Uuid generator types
|
||||||
const (
|
const (
|
||||||
InternalUuidGeneratorType string = "internal"
|
InternalUuidGeneratorType string = "internal"
|
||||||
)
|
)
|
||||||
@@ -75,6 +83,7 @@ const (
|
|||||||
defaultTemporaryTokenExpiredTime int = 300 // 5 minutes
|
defaultTemporaryTokenExpiredTime int = 300 // 5 minutes
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DatabaseConfig represents the database setting config
|
||||||
type DatabaseConfig struct {
|
type DatabaseConfig struct {
|
||||||
DatabaseType string
|
DatabaseType string
|
||||||
DatabaseHost string
|
DatabaseHost string
|
||||||
@@ -91,6 +100,7 @@ type DatabaseConfig struct {
|
|||||||
ConnectionMaxLifeTime int
|
ConnectionMaxLifeTime int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Config represents the global setting config
|
||||||
type Config struct {
|
type Config struct {
|
||||||
// Global
|
// Global
|
||||||
AppName string
|
AppName string
|
||||||
@@ -145,6 +155,7 @@ type Config struct {
|
|||||||
EnableUserRegister bool
|
EnableUserRegister bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoadConfiguration loads setting config from given config file path
|
||||||
func LoadConfiguration(configFilePath string) (*Config, error) {
|
func LoadConfiguration(configFilePath string) (*Config, error) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
@@ -206,6 +217,7 @@ func LoadConfiguration(configFilePath string) (*Config, error) {
|
|||||||
return config, nil
|
return config, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDefaultConfigFilePath returns the defaule config file path
|
||||||
func GetDefaultConfigFilePath() (string, error) {
|
func GetDefaultConfigFilePath() (string, error) {
|
||||||
workingPath, err := getWorkingPath()
|
workingPath, err := getWorkingPath()
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
package settings
|
package settings
|
||||||
|
|
||||||
|
// ConfigContainer contains the current setting config
|
||||||
type ConfigContainer struct {
|
type ConfigContainer struct {
|
||||||
Current *Config
|
Current *Config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initialize a config container singleton instance
|
||||||
var (
|
var (
|
||||||
Container = &ConfigContainer{}
|
Container = &ConfigContainer{}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// SetCurrentConfig sets the current config by a given config
|
||||||
func SetCurrentConfig(config *Config) {
|
func SetCurrentConfig(config *Config) {
|
||||||
Container.Current = config
|
Container.Current = config
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user