Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
wk331100 committed Aug 2, 2021
1 parent e9995c1 commit a39117d
Show file tree
Hide file tree
Showing 14 changed files with 136 additions and 96 deletions.
34 changes: 34 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[APP]
page_size=20
log_path=storage/log
log_type=error
time_location=asia/shanghai

[SERVER]
port=80

[DB_MASTER]
host=127.0.0.1
port=3306
username=root
password=123456
dbname=test

[DB_SLAVE]
host=127.0.0.1
port=3306
username=root
password=123456
dbname=test

[REDIS_MASTER]
host=127.0.0.1
port=6379
password=123456
db=0

[REDIS_SLAVE1]
host=127.0.0.1
port=6379
password=123456
db=0
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
.env
.env_test
.env_production
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/iFTY.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 20 additions & 5 deletions bootstrap/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,27 @@ func (app *Application) Run () {
}

func (app *Application) PrintWelcome (params helper.Map){
fmt.Println("+-------------------------------------------------------+")
line := "+-------------------------------------------------------+"
fmt.Println(line)
fmt.Println("| iFTY |")
fmt.Println("| Is A Web Api Framework Short For Infinity |")
fmt.Println("|-------------------------------------------------------|")
fmt.Println("| Status: ",helper.Green("Running!")," |")
fmt.Println("| Listening Port: ", helper.Green(strconv.Itoa(params["port"].(int))), " |")
fmt.Println("| Running Environment: ", helper.Green(global.Env), " |")
fmt.Println(line)
len := len(line)
status := "| Status: " + helper.Green("Running!")
port := "| Listening Port: " + helper.Green(strconv.Itoa(params["port"].(int)))
env := "| Running Environment: " + helper.Green(global.Env)
fillBlankPrintln(status, len)
fillBlankPrintln(port, len)
fillBlankPrintln(env, len)
fmt.Println("+-------------------------------------------------------+")
}

func fillBlankPrintln(str string, maxlen int) {
fmt.Print(str)
strlen := len(str)
for i:=0; i< maxlen - strlen + 10; i++ {
fmt.Print(" ")
}
fmt.Println("|")

}
23 changes: 23 additions & 0 deletions config/Redis.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package config

import "github.com/wk331100/iFTY/system/helper"

var RedisConfig = helper.Map{}

func InitRedisConfig(){
RedisConfig = helper.Map{
"master" : helper.Map{
"host" : helper.Env("host", "REDIS_MASTER"),
"port" : helper.EnvInt("port", "REDIS_MASTER"),
"password" : helper.Env("password", "REDIS_MASTER"),
"db" : helper.EnvInt("db", "REDIS_MASTER"),
},
"slave1" : helper.Map{
"host" : helper.Env("host", "REDIS_SLAVE1"),
"port" : helper.EnvInt("port", "REDIS_SLAVE1"),
"password" : helper.Env("password", "REDIS_SLAVE1"),
"db" : helper.EnvInt("db", "REDIS_SLAVE1"),
},
}
}

49 changes: 10 additions & 39 deletions config/app.go
Original file line number Diff line number Diff line change
@@ -1,52 +1,23 @@
package config

import "github.com/wk331100/iFTY/system/helper"
import (
"github.com/wk331100/iFTY/system/helper"
)

var MysqlConfig = helper.Map{}
var RedisConfig = helper.Map{}
var AppConfig = helper.Map{}
var ServerConfig = helper.Map{}

func InitConfig(){
ServerConfig = helper.Map{
"port" : helper.EnvInt("port", "SERVER"),
}
InitAppConfig()
InitServerConfig()
InitDatabaseConfig()
InitRedisConfig()
}

func InitAppConfig() {
AppConfig = helper.Map{
"pageSize" : helper.EnvInt("page_size", "APP"),
"logPath" : helper.Env("log_path", "APP"),
"logType" : helper.Env("log_type", "APP"),
"timeLocation" : helper.Env("time_location", "APP"),
}
MysqlConfig = helper.Map{
"master" : helper.Map{
"host" : helper.Env("host", "DB_MASTER"),
"port" : helper.EnvInt("port", "DB_MASTER"),
"username" : helper.Env("username", "DB_MASTER"),
"password" : helper.Env("password", "DB_MASTER"),
"dbname" : helper.Env("dbname", "DB_MASTER"),
},
"slave" : helper.Map{
"host" : helper.Env("host", "DB_SLAVE"),
"port" : helper.EnvInt("port", "DB_SLAVE"),
"username" : helper.Env("username", "DB_SLAVE"),
"password" : helper.Env("password", "DB_SLAVE"),
"dbname" : helper.Env("dbname", "DB_SLAVE"),
},
}

RedisConfig = helper.Map{
"master" : helper.Map{
"host" : helper.Env("host", "REDIS_MASTER"),
"port" : helper.EnvInt("port", "REDIS_MASTER"),
"password" : helper.Env("password", "REDIS_MASTER"),
"db" : helper.EnvInt("db", "REDIS_MASTER"),
},
"slave1" : helper.Map{
"host" : helper.Env("host", "REDIS_SLAVE1"),
"port" : helper.EnvInt("port", "REDIS_SLAVE1"),
"password" : helper.Env("password", "REDIS_SLAVE1"),
"db" : helper.EnvInt("db", "REDIS_SLAVE1"),
},
}
}

18 changes: 1 addition & 17 deletions config/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package config
import "github.com/wk331100/iFTY/system/helper"

var MysqlConfig = helper.Map{}
var RedisConfig = helper.Map{}

func InitConfig(){
func InitDatabaseConfig(){
MysqlConfig = helper.Map{
"master" : helper.Map{
"host" : helper.Env("host", "DB_MASTER"),
Expand All @@ -22,20 +21,5 @@ func InitConfig(){
"dbname" : helper.Env("dbname", "DB_SLAVE"),
},
}

RedisConfig = helper.Map{
"master" : helper.Map{
"host" : helper.Env("host", "REDIS_MASTER"),
"port" : helper.EnvInt("port", "REDIS_MASTER"),
"password" : helper.Env("password", "REDIS_MASTER"),
"db" : helper.EnvInt("db", "REDIS_MASTER"),
},
"slave1" : helper.Map{
"host" : helper.Env("host", "REDIS_SLAVE1"),
"port" : helper.EnvInt("port", "REDIS_SLAVE1"),
"password" : helper.Env("password", "REDIS_SLAVE1"),
"db" : helper.EnvInt("db", "REDIS_SLAVE1"),
},
}
}

34 changes: 0 additions & 34 deletions config/middleware.go

This file was deleted.

8 changes: 8 additions & 0 deletions config/server.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
package config

import "github.com/wk331100/iFTY/system/helper"

var ServerConfig = map[string]interface{}{
"Port" : 8080,
}

func InitServerConfig() {
ServerConfig = helper.Map{
"port" : helper.EnvInt("port", "SERVER"),
}
}
5 changes: 5 additions & 0 deletions storage/log/errors.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[2021-08-02 20:37:32] [info] Request Log From After MiddleWare
[2021-08-02 20:37:32] [info] Request Log From After MiddleWare
[2021-08-02 20:40:27] [info] Request Log From After MiddleWare
[2021-08-02 20:47:04] [info] Request Log From After MiddleWare
[2021-08-02 20:48:13] [info] Request Log From After MiddleWare

0 comments on commit a39117d

Please sign in to comment.