Merge pull request #14 from lanyulei/dev

Dev
This commit is contained in:
lyl_task 2020-08-21 17:10:25 +08:00 committed by GitHub
commit 4a0dd77310
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 12 deletions

View File

@ -10,7 +10,6 @@ import (
"ferry/tools" "ferry/tools"
config2 "ferry/tools/config" config2 "ferry/tools/config"
"fmt" "fmt"
"io/ioutil"
"log" "log"
"net/http" "net/http"
"os" "os"
@ -100,10 +99,14 @@ func run() error {
} }
} }
}() }()
content, _ := ioutil.ReadFile("./static/ferry.txt") fmt.Printf("%s Server Run http://%s:%s/ \r\n",
fmt.Println(string(content)) tools.GetCurrntTimeStr(),
fmt.Printf("%s Server Run http://127.0.0.1:%s/ \r\n", tools.GetCurrntTimeStr(), config2.ApplicationConfig.Port) config2.ApplicationConfig.Host,
fmt.Printf("%s Swagger URL http://127.0.0.1:%s/swagger/index.html \r\n", tools.GetCurrntTimeStr(), config2.ApplicationConfig.Port) config2.ApplicationConfig.Port)
fmt.Printf("%s Swagger URL http://%s:%s/swagger/index.html \r\n",
tools.GetCurrntTimeStr(),
config2.ApplicationConfig.Host,
config2.ApplicationConfig.Port)
fmt.Printf("%s Enter Control + C Shutdown Server \r\n", tools.GetCurrntTimeStr()) fmt.Printf("%s Enter Control + C Shutdown Server \r\n", tools.GetCurrntTimeStr())
// 等待中断信号以优雅地关闭服务器(设置 5 秒的超时时间) // 等待中断信号以优雅地关闭服务器(设置 5 秒的超时时间)
quit := make(chan os.Signal) quit := make(chan os.Signal)

View File

@ -87,7 +87,7 @@ INSERT INTO `casbin_rule`(`p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (
INSERT INTO `casbin_rule`(`p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES ('p', 'common', '/api/v1/deptTree', 'GET', NULL, NULL, NULL); INSERT INTO `casbin_rule`(`p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES ('p', 'common', '/api/v1/deptTree', 'GET', NULL, NULL, NULL);
INSERT INTO `casbin_rule`(`p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES ('p', 'common', '/api/v1/logout', 'POST', NULL, NULL, NULL); INSERT INTO `casbin_rule`(`p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES ('p', 'common', '/api/v1/logout', 'POST', NULL, NULL, NULL);
INSERT INTO `casbin_rule`(`p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES ('p', 'common', '/api/v1/user/avatar', 'POST', NULL, NULL, NULL); INSERT INTO `casbin_rule`(`p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES ('p', 'common', '/api/v1/user/avatar', 'POST', NULL, NULL, NULL);
INSERT INTO `casbin_rule`(`p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES ('p', 'common', '/api/v1/user/pwd', 'PUT', NULL, NULL, NULL; INSERT INTO `casbin_rule`(`p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES ('p', 'common', '/api/v1/user/pwd', 'PUT', NULL, NULL, NULL);
INSERT INTO `casbin_rule`(`p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES ('p', 'common', '/api/v1/dashboard', 'GET', NULL, NULL, NULL); INSERT INTO `casbin_rule`(`p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES ('p', 'common', '/api/v1/dashboard', 'GET', NULL, NULL, NULL);
INSERT INTO `casbin_rule`(`p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES ('p', 'admin', '/api/v1/settings', 'POST', NULL, NULL, NULL); INSERT INTO `casbin_rule`(`p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES ('p', 'admin', '/api/v1/settings', 'POST', NULL, NULL, NULL);
INSERT INTO `casbin_rule`(`p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES ('p', 'admin', '/api/v1/settings', 'GET', NULL, NULL, NULL); INSERT INTO `casbin_rule`(`p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES ('p', 'admin', '/api/v1/settings', 'GET', NULL, NULL, NULL);

View File

@ -24,13 +24,13 @@ func InitDb() error {
return err return err
} }
sqlList := strings.Split(sql, ";") sqlList := strings.Split(sql, ";")
for i := 0; i < len(sqlList)-1; i++ { for _, sql := range sqlList {
if strings.Contains(sqlList[i], "--") { if strings.Contains(sql, "--") {
fmt.Println(sqlList[i]) fmt.Println(sql)
continue continue
} }
sql := strings.Replace(sqlList[i]+";", "\n", "", 0) sqlValue := strings.Replace(sql+";", "\n", "", 1)
if err = orm.Eloquent.Exec(sql).Error; err != nil { if err = orm.Eloquent.Exec(sqlValue).Error; err != nil {
if !strings.Contains(err.Error(), "Query was empty") { if !strings.Contains(err.Error(), "Query was empty") {
return err return err
} }
@ -43,7 +43,6 @@ func Ioutil(name string) (string, error) {
if contents, err := ioutil.ReadFile(name); err == nil { if contents, err := ioutil.ReadFile(name); err == nil {
//因为contents是[]byte类型直接转换成string类型后会多一行空格,需要使用strings.Replace替换换行符 //因为contents是[]byte类型直接转换成string类型后会多一行空格,需要使用strings.Replace替换换行符
result := strings.Replace(string(contents), "\n", "", 1) result := strings.Replace(string(contents), "\n", "", 1)
fmt.Println("Use ioutil.ReadFile to read a file:", result)
return result, nil return result, nil
} else { } else {
return "", err return "", err