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