refactor: DTO 字段去下划线 + SimApiBaseResponse 不再可继承 + 删除 SimApiJson/toJsonString

- 纯 POCO DTO 字段去下划线:AuthDto(id/name/applicationId/profileId/scene 等)、
  SimApiLoginItem(id/types/meta/extra)、AesBodyRequest(data)、
  SimApiBaseResponse 系列(code/message/data/list/page/count/total)
- SimApiBaseResponse 去 open(不再允许继承)+ 删 @SerializerParent(无子类继承)
- SimApiResponse<T> / SimApiDataResponse 改为组合(自带 code/message/data)
- 删除 toJsonString(无使用点,统一走 simapi_serialization)
- 删除 SimApiJson.cj:json() → SimApiUtil.json() 直接序列化;
  escapeJson() 迁入 SimApiUtil
- 同步更新所有字段引用(AuthCenter/AuthIam/HttpClient/ExceptionMiddleware 等)
- 保留 sqlsharp 实体 User/Bot 的 _ 前缀(soulsoft 宏依赖)
This commit is contained in:
2026-08-18 01:15:15 +08:00
parent ea31bd9b6a
commit c7099040fa
15 changed files with 175 additions and 217 deletions
+27 -3
View File
@@ -172,10 +172,34 @@ public class SimApiUtil {
}
/**
* 将对象序列化为 JSON 字符串(委托给 SimApiJson.json 统一实现,对齐 C# SimApiUtil.Json)。
* 将对象序列化为 JSON 字符串(对齐 C# SimApiUtil.Json)。
* @param obj 任意对象(None 输出 null)。
*/
public static func json(obj: ?Any): String {
SimApiJson.json(obj)
if (let Some(obj) <- obj) {
return JsonSerializer.Serialize(obj)
}
"null"
}
/**
* JSON 字符串转义(对齐 C# 内部转义逻辑)。
* @param s 原始字符串。
* @return 转义后可直接放入 JSON 字符串字面量的内容。
*/
public static func escapeJson(s: String): String {
var sb = StringBuilder()
for (c in s.runes()) {
match (c) {
case '"' => sb.append("\\\"")
case '\\' => sb.append("\\\\")
case '\n' => sb.append("\\n")
case '\r' => sb.append("\\r")
case '\t' => sb.append("\\t")
case _ => sb.append(c)
}
}
sb.toString()
}
/**
@@ -194,7 +218,7 @@ public class SimApiUtil {
* @return Base64 字符串。
*/
public static func base64Encode(obj: Any): String {
let json = SimApiJson.json(Some(obj))
let json = json(Some(obj))
base64Encode(json)
}