base/resource.go、resource_hooks.go、resource_test.go、query_field.go 删除,ResField 等具体实现搬到 req/resx(见 res_field.go 里的类型别名)。res_listener.go 替换成 res_watcher.go,对应资源变更监听概念改名。新增 res_api_param.go 及配套测试(ResApi 参数建模,给 MCP tool 的 JSON Schema 生成用)。
23 lines
605 B
Go
23 lines
605 B
Go
package base
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.fsdpf.net/go/db/schema"
|
|
"git.fsdpf.net/go/req"
|
|
"git.fsdpf.net/go/req/resx"
|
|
|
|
_ "git.fsdpf.net/go/db/schema/dialect/mysql"
|
|
_ "git.fsdpf.net/go/db/schema/dialect/sqlite3"
|
|
)
|
|
|
|
func TestResFieldToBlueprint(t *testing.T) {
|
|
t.Run("id", func(t *testing.T) {
|
|
table := schema.NewBlueprint("users")
|
|
|
|
id := resx.NewResField("id", "User", resx.FieldWithUuid("00000000-0000-0000-0000-000000000000"), resx.FieldWithName("ID"), resx.FieldWithLength("20"), resx.FieldWithDefault("sql:AUTO_INCREMENT"), resx.FieldWithDataType(req.ResInteger))
|
|
|
|
id.ToBlueprint(table)
|
|
})
|
|
}
|