chore: 初始开源发布
iotlcm-openapi:对外 OpenAPI 网关(V3 接口 + 旧版兼容接口)。
- Go module:iotlcm-openapi → git.5iot.com/iotlcm-public/iotlcm-openapi(178 文件)
- 凭据与地址脱敏:JWT signingKey、MySQL DSN、Redis 口令、
RabbitMQ DSN 全部改为 ${*} 占位;私网 IP → 文档地址段
- 7 处真实手机号 → 合法 11 位编造号
- 启动 banner 统一 IOTLCM 方块字 + 社区惯例署名
- 移除内部资产:CI 触发器
- Dockerfile 改用公共基础镜像,移除 GOPRIVATE 内网设置
- README 重写(原为 GoFrame 模板占位文案),补 Apache-2.0 LICENSE,
LF 行尾 + .gitattributes
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package query
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
_ "github.com/gogf/gf/contrib/drivers/sqlite/v2"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
"git.5iot.com/iotlcm-public/iotlcm-openapi/internal/library/contexts"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-openapi/internal/model"
|
||||
)
|
||||
|
||||
func TestBatchStatusScopeAndAllocationChildren(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
if err := gdb.SetConfig(gdb.Config{"default": gdb.ConfigGroup{{Type: "sqlite", Link: "sqlite::@file(:memory:)", MaxOpenConnCount: 1}}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = g.DB().Close(ctx) })
|
||||
if err := g.DB().GetCore().ClearTableFieldsAll(ctx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, statement := range []string{
|
||||
"CREATE TABLE batch_main (id INTEGER PRIMARY KEY, batch_no TEXT, batch_type INTEGER, source_batch_no TEXT, tenant_id TEXT, dept_id INTEGER, batch_async_status INTEGER, source_channel TEXT, execution_mode INTEGER, source_type INTEGER, total_count INTEGER, valid_count INTEGER, success_count INTEGER, fail_count INTEGER, run_result INTEGER, fail_reason TEXT)",
|
||||
"INSERT INTO batch_main VALUES (1,'mine',101,'mine','A',7,3,'api',1,2,1,1,1,0,2,''),(2,'other-tenant',101,'','B',7,3,'api',1,2,1,1,1,0,2,''),(3,'other-dept',101,'','A',8,3,'api',1,2,1,1,1,0,2,''),(4,'parent',3,'','A',7,2,'api',2,2,2,2,1,0,1,''),(5,'child',3,'parent','A',7,2,'api',2,2,1,1,0,0,1,''),(6,'self',3,'self','A',7,3,'api',2,2,1,1,1,0,2,'')",
|
||||
} {
|
||||
if _, err := g.DB().Exec(ctx, statement); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
ctx = contexts.Set(ctx, &model.Context{
|
||||
User: &model.Identity{BaseClaims: model.BaseClaims{TenantId: "A"}},
|
||||
AgentUser: &model.BaseClaimsApi{DeptId: 7, TenantId: "A"},
|
||||
})
|
||||
for _, batchNo := range []string{"mine", "parent", "self"} {
|
||||
result, err := NewQuerySim().QueryBatchStatus(ctx, &model.QueryBatchStatusParam{AppId: "app", BatchNo: batchNo})
|
||||
if err != nil || result == nil || result.BatchNo != batchNo || result.SourceChannel != "api" {
|
||||
t.Fatalf("batch %s: result=%+v err=%v", batchNo, result, err)
|
||||
}
|
||||
}
|
||||
for _, batchNo := range []string{"other-tenant", "other-dept", "child", "missing"} {
|
||||
if _, err := NewQuerySim().QueryBatchStatus(ctx, &model.QueryBatchStatusParam{AppId: "app", BatchNo: batchNo}); err == nil {
|
||||
t.Fatalf("batch exposed: %s", batchNo)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user