refactor: SimApiSignProviderBase / AesBodyProviderBase 移至 interfaces 子包
- 新增 src/interfaces/SimApiSignProviderBase.cj / AesBodyProviderBase.cj(package simapi.interfaces) - SimApiSignChecker / SimApiAesBodyChecker 移除基类定义,import simapi.interfaces.* - SimApiRequestDelegateFactory 已 import interfaces,无需改 - 说明:基类含配置字段故用 open class(Cangjie 接口不能声明字段)
This commit is contained in:
@@ -11,6 +11,7 @@ import simapi_serialization.*
|
||||
import soulsoft_web_http.*
|
||||
import simapi.communications.*
|
||||
import simapi.exceptions.*
|
||||
import simapi.interfaces.*
|
||||
|
||||
/**
|
||||
* AES body 请求({"data": "密文"},对齐 C# SimApiOneFieldRequest<string>)。
|
||||
@@ -21,32 +22,13 @@ public class AesBodyRequest {
|
||||
public init() {}
|
||||
}
|
||||
|
||||
/**
|
||||
* AES body 密钥提供器(对齐 C# ModelBinders/AesBodyProviderBase):
|
||||
* 应用继承本类并实现 getKey(appId),返回 appId 对应的 AES 密钥。
|
||||
*/
|
||||
public open class AesBodyProviderBase {
|
||||
/// appId 字段名(None 表示不带 appId)
|
||||
public var appIdName: ?String = Some("appId")
|
||||
|
||||
public init() {}
|
||||
|
||||
/**
|
||||
* 根据 appId 获取密钥。
|
||||
* @param appId 应用 ID(未配置 appIdName 时为 None)。
|
||||
* @return 密钥;返回 None 表示获取失败。
|
||||
*/
|
||||
public open func getKey(appId: ?String): ?String {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务端 AES body 解密校验器(对齐 C# ModelBinders/AesBodyModelBinder)。
|
||||
*
|
||||
* 仓颉无 ModelBinder 机制,按项目惯例由控制器在方法开头调用:
|
||||
* let jsonStr = SimApiAesBodyChecker.decryptBody(context, provider)
|
||||
* let request = JsonSerializer.Deserialize<XxxRequest>(jsonStr)
|
||||
* 或标注 @AesBody 注解自动执行(SimApiRequestDelegateFactory)。
|
||||
*
|
||||
* 流程(与 C# 一致):
|
||||
* 1. 读取 body 并反序列化为 {"data": "密文"}
|
||||
|
||||
Reference in New Issue
Block a user