This commit is contained in:
@@ -30,6 +30,7 @@ public sealed class SchClassOpenApi
|
|||||||
TeachInfo = new SchClassTeachInfoClient(httpClient, options);
|
TeachInfo = new SchClassTeachInfoClient(httpClient, options);
|
||||||
SubInfo = new SchClassSubInfoClient(httpClient, options);
|
SubInfo = new SchClassSubInfoClient(httpClient, options);
|
||||||
FamilyCompat = new SchClassFamilyCompatClient(httpClient, options);
|
FamilyCompat = new SchClassFamilyCompatClient(httpClient, options);
|
||||||
|
SchTree = new SchClassSchTreeClient(httpClient, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>当前生效的配置。</summary>
|
/// <summary>当前生效的配置。</summary>
|
||||||
@@ -69,6 +70,9 @@ public sealed class SchClassOpenApi
|
|||||||
|
|
||||||
/// <summary>FamCom:家长兼容(<c>/oapi/Common/FamCom/</c>)。</summary>
|
/// <summary>FamCom:家长兼容(<c>/oapi/Common/FamCom/</c>)。</summary>
|
||||||
public SchClassFamilyCompatClient FamilyCompat { get; }
|
public SchClassFamilyCompatClient FamilyCompat { get; }
|
||||||
|
|
||||||
|
/// <summary>SchTree:学校教师组树(<c>/oapi/SchGroup/</c>)。</summary>
|
||||||
|
public SchClassSchTreeClient SchTree { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary><see cref="SchClassOpenApi"/> 的轻量工厂(不依赖 DI 容器)。</summary>
|
/// <summary><see cref="SchClassOpenApi"/> 的轻量工厂(不依赖 DI 容器)。</summary>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
//
|
//
|
||||||
// 注意:csproj 已设 GenerateProgramFile=false(关掉 Test SDK 自动 Main),dotnet test 不受影响。
|
// 注意:csproj 已设 GenerateProgramFile=false(关掉 Test SDK 自动 Main),dotnet test 不受影响。
|
||||||
|
|
||||||
|
using Microsoft.VisualStudio.TestPlatform.Utilities;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Yh.SchClass.OpenApi.Tests;
|
namespace Yh.SchClass.OpenApi.Tests;
|
||||||
@@ -20,34 +21,38 @@ public static class DebugMain
|
|||||||
{
|
{
|
||||||
Console.OutputEncoding = Encoding.UTF8;
|
Console.OutputEncoding = Encoding.UTF8;
|
||||||
|
|
||||||
string? only = null;
|
var sch = "8d920c30-0f9b-4d8c-8a9f-2f9682899635";
|
||||||
foreach (var arg in args)
|
var api = SchClassLiveDebug.Create();
|
||||||
{
|
var teachers = await api.TeaInfo.GetSchTeaInfoAsync(sch, null);
|
||||||
if (arg.StartsWith("--only=", StringComparison.OrdinalIgnoreCase))
|
Console.WriteLine($"OATea[{sch}] 共 {teachers.Count} 名教师");
|
||||||
{
|
//string? only = null;
|
||||||
only = arg[7..].Trim();
|
//foreach (var arg in args)
|
||||||
}
|
//{
|
||||||
else if (arg.Equals("--off", StringComparison.OrdinalIgnoreCase))
|
// if (arg.StartsWith("--only=", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
// {
|
||||||
Console.WriteLine("跳过联调:--off(同 YH_SCHCLASS_DEBUG_OFF=1)");
|
// only = arg[7..].Trim();
|
||||||
return 0;
|
// }
|
||||||
}
|
// else if (arg.Equals("--off", StringComparison.OrdinalIgnoreCase))
|
||||||
}
|
// {
|
||||||
|
// Console.WriteLine("跳过联调:--off(同 YH_SCHCLASS_DEBUG_OFF=1)");
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
if (Environment.GetEnvironmentVariable(SchClassLiveDebug.OffVar) is "1" or "true")
|
//if (Environment.GetEnvironmentVariable(SchClassLiveDebug.OffVar) is "1" or "true")
|
||||||
{
|
//{
|
||||||
Console.WriteLine("跳过联调:已设置 " + SchClassLiveDebug.OffVar + "=1(清除该变量即可恢复联调)");
|
// Console.WriteLine("跳过联调:已设置 " + SchClassLiveDebug.OffVar + "=1(清除该变量即可恢复联调)");
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
//}
|
||||||
|
|
||||||
Console.WriteLine("== SchClass OpenAPI 测试工程调试入口 ==");
|
//Console.WriteLine("== SchClass OpenAPI 测试工程调试入口 ==");
|
||||||
var failures = await SchClassLiveDebug.RunAllAsync(Console.WriteLine, only);
|
//var failures = await SchClassLiveDebug.RunAllAsync(Console.WriteLine, only);
|
||||||
if (failures.Count == 0)
|
//if (failures.Count == 0)
|
||||||
{
|
//{
|
||||||
Console.WriteLine("全部通过 ✅");
|
// Console.WriteLine("全部通过 ✅");
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
//}
|
||||||
Console.WriteLine($"失败 {failures.Count} 个:{string.Join(", ", failures)}");
|
//Console.WriteLine($"失败 {failures.Count} 个:{string.Join(", ", failures)}");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ internal static class SchClassLiveDebug
|
|||||||
public const string DefaultHost = "http://base.yunhaixingtong.com";
|
public const string DefaultHost = "http://base.yunhaixingtong.com";
|
||||||
|
|
||||||
/// <summary>配置与配置文件都未提供时的兜底应用路径。</summary>
|
/// <summary>配置与配置文件都未提供时的兜底应用路径。</summary>
|
||||||
public const string DefaultPath = "/bschclass";
|
public const string DefaultPath = "/userclass";
|
||||||
|
|
||||||
private static readonly IConfiguration? Config;
|
private static readonly IConfiguration? Config;
|
||||||
|
|
||||||
@@ -143,6 +143,7 @@ internal static class SchClassLiveDebug
|
|||||||
("SchInfo.GetSchlist", async () => (await api.SchInfo.GetSchListAsync(null)).Count),
|
("SchInfo.GetSchlist", async () => (await api.SchInfo.GetSchListAsync(null)).Count),
|
||||||
("OATea.GetSchTeainfo", async () => (await api.TeaInfo.GetSchTeaInfoAsync(sch, null)).Count),
|
("OATea.GetSchTeainfo", async () => (await api.TeaInfo.GetSchTeaInfoAsync(sch, null)).Count),
|
||||||
("OATea.GetArrTeainfo", async () => (await api.TeaInfo.GetArrTeaInfoAsync(teaId.Value.ToString())).Count),
|
("OATea.GetArrTeainfo", async () => (await api.TeaInfo.GetArrTeaInfoAsync(teaId.Value.ToString())).Count),
|
||||||
|
("SchGroup.GetTeaTree", async () => (await api.SchTree.GetTeaTreeAsync(sch, null)).Count),
|
||||||
("OAStu.GetAllStulist", async () => (await api.StuInfo.GetAllStuListAsync()).Count),
|
("OAStu.GetAllStulist", async () => (await api.StuInfo.GetAllStuListAsync()).Count),
|
||||||
("OAStu.GetSchStulist", async () => (await api.StuInfo.GetSchStuListAsync(sch, null)).Count),
|
("OAStu.GetSchStulist", async () => (await api.StuInfo.GetSchStuListAsync(sch, null)).Count),
|
||||||
("OAStu.GetClaStulist", async () => (await api.StuInfo.GetClaStuListAsync(classId, null)).Count),
|
("OAStu.GetClaStulist", async () => (await api.StuInfo.GetClaStuListAsync(classId, null)).Count),
|
||||||
|
|||||||
@@ -77,6 +77,28 @@ public class SchClassLiveDebugTests(ITestOutputHelper output)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task 联调_教师组树()
|
||||||
|
{
|
||||||
|
if (!Live()) return;
|
||||||
|
|
||||||
|
var api = SchClassLiveDebug.Create();
|
||||||
|
var sch = SchClassLiveDebug.Sch
|
||||||
|
?? (await api.SchInfo.AllListAsync()).FirstOrDefault()?.SchSerId;
|
||||||
|
if (string.IsNullOrEmpty(sch))
|
||||||
|
{
|
||||||
|
output.WriteLine("未取到学校序列号(设置 YH_SCHCLASS_DEBUG_SCH 或确认学校列表非空)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var tree = await api.SchTree.GetTeaTreeAsync(sch, null);
|
||||||
|
output.WriteLine($"SchTree[{sch}] 根节点 {tree.Count} 个");
|
||||||
|
foreach (var root in tree)
|
||||||
|
{
|
||||||
|
output.WriteLine($" {root.Id} / {root.Name} / type={root.Type} / 子节点 {root.Children?.Count ?? 0} 个");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task 联调_一键跑通全部端点()
|
public async Task 联调_一键跑通全部端点()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"Enabled": true,
|
"Enabled": true,
|
||||||
"BaseHost": "http://base.yunhaixingtong.com",
|
"BaseHost": "http://base.yunhaixingtong.com",
|
||||||
"BasePath": "/userbase",
|
"BasePath": "/userbase",
|
||||||
"SchClassPath": "/bschclass",
|
"SchClassPath": "/userclass",
|
||||||
"AppKey": "100002",
|
"AppKey": "100002",
|
||||||
"AppSecret": "2314a3b158b24a838b2b9b69fd3db118"
|
"AppSecret": "2314a3b158b24a838b2b9b69fd3db118"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user