删除无效文件

This commit is contained in:
Max 2021-10-19 00:41:09 +08:00
parent b1fc2dc049
commit c8d1025adf
4 changed files with 23 additions and 145 deletions

View file

@ -30,17 +30,6 @@ func Load(cfg config.Config) {
plugin.Load(cfg) // 加载业务插件 plugin
table.Load(cfg) // 加载数据表格 table
// LoadApp(share.AppRoot{
// APIs: cfg.RootAPI,
// Flows: cfg.RootFLow,
// Models: cfg.RootModel,
// Plugins: cfg.RootPlugin,
// Tables: cfg.RootTable,
// Charts: cfg.RootChart,
// Screens: cfg.RootScreen,
// Data: cfg.RootData,
// })
// 加密密钥函数
gou.LoadCrypt(fmt.Sprintf(`{"key":"%s"}`, cfg.Database.AESKey), "AES")
gou.LoadCrypt(`{}`, "PASSWORD")
@ -55,23 +44,6 @@ func Reload(cfg config.Config) {
Load(cfg)
}
// // DBConnect 建立数据库连接
// func DBConnect(dbconfig config.DatabaseConfig) {
// // 连接主库
// for i, dsn := range dbconfig.Primary {
// db := capsule.AddConn("primary", dbconfig.Driver, dsn)
// if i == 0 {
// db.SetAsGlobal()
// }
// }
// // 连接从库
// for _, dsn := range dbconfig.Secondary {
// capsule.AddReadConn("secondary", dbconfig.Driver, dsn)
// }
// }
// LoadEngine 加载引擎的 API, Flow, Model 配置
func LoadEngine(from string) {
@ -116,76 +88,3 @@ func LoadEngine(from string) {
}
}
}
// LoadApp 加载应用的 API, Flow, Model 和 Plugin
func LoadApp(app share.AppRoot) {
// api string, flow string, model string, plugin string
// 创建应用目录
// paths := []string{app.APIs, app.Flows, app.Models, app.Plugins, app.Charts, app.Tables, app.Screens, app.Data}
// paths := []string{app.Flows, app.Models, app.Plugins, app.Charts, app.Tables, app.Screens, app.Data}
// for _, p := range paths {
// if !strings.HasPrefix(p, "fs://") && strings.Contains(p, "://") {
// continue
// }
// root, err := filepath.Abs(strings.TrimPrefix(p, "fs://"))
// if err != nil {
// log.Panicf("创建目录失败(%s) %s", root, err)
// }
// if _, err := os.Stat(root); os.IsNotExist(err) {
// err := os.MkdirAll(root, os.ModePerm)
// if err != nil {
// log.Panicf("创建目录失败(%s) %s", root, err)
// }
// }
// }
// // 加载API
// if strings.HasPrefix(app.APIs, "fs://") || !strings.Contains(app.APIs, "://") {
// root := strings.TrimPrefix(app.APIs, "fs://")
// scripts := share.GetAppFilesFS(root, ".json")
// for _, script := range scripts {
// // 验证API 加载逻辑
// gou.LoadAPI(string(script.Content), script.Name)
// }
// }
// // 加载Flow
// if strings.HasPrefix(app.Flows, "fs://") || !strings.Contains(app.Flows, "://") {
// root := strings.TrimPrefix(app.Flows, "fs://")
// scripts := share.GetAppFilesFS(root, ".json")
// for _, script := range scripts {
// gou.LoadFlow(string(script.Content), script.Name)
// }
// }
// // 加载Model
// if strings.HasPrefix(app.Models, "fs://") || !strings.Contains(app.Models, "://") {
// root := strings.TrimPrefix(app.Models, "fs://")
// scripts := share.GetAppFilesFS(root, ".json")
// for _, script := range scripts {
// gou.LoadModel(string(script.Content), script.Name)
// }
// }
// 加载Plugin
// if strings.HasPrefix(app.Plugins, "fs://") || !strings.Contains(app.Plugins, "://") {
// root := strings.TrimPrefix(app.Plugins, "fs://")
// scripts := share.GetAppPlugins(root, ".so")
// for _, script := range scripts {
// gou.LoadPlugin(script.File, script.Name)
// }
// }
// 加载Table
// if strings.HasPrefix(app.Tables, "fs://") || !strings.Contains(app.Tables, "://") {
// root := strings.TrimPrefix(app.Tables, "fs://")
// scripts := share.GetAppFilesFS(root, ".json")
// for _, script := range scripts {
// // 验证API 加载逻辑
// table.Load(string(script.Content), script.Name)
// }
// }
}

View file

@ -6,8 +6,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/yaoapp/xiang/config"
"github.com/yaoapp/xiang/share"
"github.com/yaoapp/xiang/table"
)
func TestLoad(t *testing.T) {
@ -35,44 +33,3 @@ func TestLoadEngineBin(t *testing.T) {
LoadEngine(root)
})
}
// 从文件系统载入应用脚本
func TestLoadAppFS(t *testing.T) {
defer Load(config.Conf)
assert.NotPanics(t, func() {
LoadApp(share.AppRoot{
APIs: config.Conf.RootAPI,
Flows: config.Conf.RootFLow,
Models: config.Conf.RootModel,
Plugins: config.Conf.RootPlugin,
Tables: config.Conf.RootTable,
Charts: config.Conf.RootChart,
Screens: config.Conf.RootScreen,
})
})
}
func TestTableLoad(t *testing.T) {
defer Load(config.Conf)
table, has := table.Tables["service"]
assert.Equal(t, table.Table, "service")
assert.True(t, has)
_, has = table.Columns["id"]
assert.True(t, has)
price, has := table.Columns["计费方式"]
assert.True(t, has)
if has {
assert.True(t, price.Edit.Props["multiple"].(bool))
}
_, has = table.Filters["id"]
assert.True(t, has)
keywords, has := table.Filters["关键词"]
assert.True(t, has)
if has {
assert.True(t, keywords.Bind == "where.name.like")
}
}

View file

@ -18,6 +18,28 @@ func TestLoad(t *testing.T) {
Load(config.Conf)
LoadFrom("not a path", "404.")
check(t)
table, has := Tables["service"]
assert.Equal(t, table.Table, "service")
assert.True(t, has)
_, has = table.Columns["id"]
assert.True(t, has)
price, has := table.Columns["计费方式"]
assert.True(t, has)
if has {
assert.True(t, price.Edit.Props["multiple"].(bool))
}
_, has = table.Filters["id"]
assert.True(t, has)
keywords, has := table.Filters["关键词"]
assert.True(t, has)
if has {
assert.True(t, keywords.Bind == "where.name.like")
}
}
func check(t *testing.T) {

View file

@ -54,6 +54,6 @@ func TestProcessGetToken(t *testing.T) {
// 上传字符串。
now := fmt.Sprintf("%d", time.Now().UnixNano())
err = bucket.PutObject("xiang/unit-test.txt", strings.NewReader(now))
err = bucket.PutObject("xiang/unit-test."+now+".txt", strings.NewReader(now))
assert.Nil(t, err)
}