docs(gateway): gateway 剩余文件注释改中文(逐行 1:1,代码零字节改动)
主人 2026-10-03 拍板「注释一律中文」;gateway 至此整包注释中文化完成(本会话共 3 批: 已推库 16 个文件 + 本批剩余文件)。 校验:机械校验(非注释改动行)= 空;剥注释后代码文本逐行比对全等(不一致文件数 0); 全树 go test ./... 58 包 ok / 0 FAIL;交叉编译绿。
This commit is contained in:
1 parent
91e8d7a029
commit
074ffc4ebf
73 files changed
+2529
-2529
No files matched your search
@@ -11,19 +11,19 @@ import (
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/services/automations"
|
||||
)
|
||||
|
||||
// IoT device-control and automation-rule admin writes (owner-only, audited).
|
||||
// Device control performs a real control on the owning provider; the others
|
||||
// answer honestly when no scenario/rule store is wired.
|
||||
// IoT 设备控制与自动化规则管理写操作(仅 owner,带审计)。
|
||||
// 设备控制会在所属 provider 上执行真实控制;其余在没有
|
||||
// 接线场景/规则存储时诚实作答。
|
||||
|
||||
// iotControlRequest is the POST /api/v1/admin/iot/{id}/control body.
|
||||
// iotControlRequest 是 POST /api/v1/admin/iot/{id}/control 的请求体。
|
||||
type iotControlRequest struct {
|
||||
Action string `json:"action"`
|
||||
Params map[string]any `json:"params"`
|
||||
}
|
||||
|
||||
// adminIoTControl sends a control instruction to a device through the IoT
|
||||
// manager, which applies it on the owning provider and publishes a device_update
|
||||
// event. A real action only when the deployment has a device provider.
|
||||
// adminIoTControl 经 IoT 管理器向设备发送控制指令,管理器
|
||||
// 在所属 provider 上施加它并发布 device_update
|
||||
// 事件。只有部署了设备 provider 时才是真实动作。
|
||||
func (s *Server) adminIoTControl(w http.ResponseWriter, r *http.Request) {
|
||||
id := r.PathValue("id")
|
||||
var req iotControlRequest
|
||||
@@ -56,10 +56,10 @@ func (s *Server) adminIoTControl(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, http.StatusOK, iotDeviceSummary{ID: dev.ID, Name: dev.Name, Type: dev.Type, State: dev.State, Online: dev.Online})
|
||||
}
|
||||
|
||||
// adminIoTScenario answers honestly: the IoT subsystem owns device
|
||||
// list/control/status only (the Provider interface has no scenario model or
|
||||
// store), so there is nothing to persist a scenario into. It reports the missing
|
||||
// store rather than fabricating one.
|
||||
// adminIoTScenario 诚实作答:IoT 子系统只管设备
|
||||
// 列表/控制/状态(Provider 接口没有场景模型或
|
||||
// 存储),因此没有可持久化场景的地方。它报告缺失的
|
||||
// 存储,而不是编造一个。
|
||||
func (s *Server) adminIoTScenario(w http.ResponseWriter, r *http.Request) {
|
||||
s.auditClaims(r, "iot.scenario", "error")
|
||||
writeError(w, &apperr.AppError{
|
||||
@@ -69,9 +69,9 @@ func (s *Server) adminIoTScenario(w http.ResponseWriter, r *http.Request) {
|
||||
})
|
||||
}
|
||||
|
||||
// adminIoTRule answers honestly: no IoT automation-rule model or store exists
|
||||
// (the generic automations service runs cron/event rules, not device-state
|
||||
// conditions with device actions), so a rule cannot be persisted or executed.
|
||||
// adminIoTRule 诚实作答:不存在 IoT 自动化规则模型或存储
|
||||
// (通用 automations 服务运行 cron/event 规则,而不是带设备动作的
|
||||
// 设备状态条件),因此规则无法被持久化或执行。
|
||||
func (s *Server) adminIoTRule(w http.ResponseWriter, r *http.Request) {
|
||||
s.auditClaims(r, "iot.rule", "error")
|
||||
writeError(w, &apperr.AppError{
|
||||
@@ -81,7 +81,7 @@ func (s *Server) adminIoTRule(w http.ResponseWriter, r *http.Request) {
|
||||
})
|
||||
}
|
||||
|
||||
// mapIotError maps iot sentinel errors to HTTP errors.
|
||||
// mapIotError 把 iot 哨兵错误映射为 HTTP 错误。
|
||||
func mapIotError(err error) *apperr.AppError {
|
||||
switch {
|
||||
case errors.Is(err, iot.ErrDeviceNotFound):
|
||||
@@ -97,15 +97,15 @@ func mapIotError(err error) *apperr.AppError {
|
||||
}
|
||||
}
|
||||
|
||||
// automationCreateRequest is the POST /api/v1/admin/automations body.
|
||||
// automationCreateRequest 是 POST /api/v1/admin/automations 的请求体。
|
||||
type automationCreateRequest struct {
|
||||
Name string `json:"name"`
|
||||
Kind string `json:"kind"` // cron | event
|
||||
Expression string `json:"expression"`
|
||||
}
|
||||
|
||||
// adminCreateAutomation registers a real cron/event rule whose action records its
|
||||
// fire. Invalid cron expressions or malformed rules are answered honestly.
|
||||
// adminCreateAutomation 注册一条真实的 cron/event 规则,其动作会记录
|
||||
// 触发。无效的 cron 表达式或畸形的规则会被诚实作答。
|
||||
func (s *Server) adminCreateAutomation(w http.ResponseWriter, r *http.Request) {
|
||||
var req automationCreateRequest
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
@@ -141,7 +141,7 @@ func (s *Server) adminCreateAutomation(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, http.StatusCreated, map[string]any{"id": id, "name": req.Name, "kind": req.Kind})
|
||||
}
|
||||
|
||||
// adminRunAutomation manually triggers a registered rule's action once.
|
||||
// adminRunAutomation 手动触发一次已注册规则的动作。
|
||||
func (s *Server) adminRunAutomation(w http.ResponseWriter, r *http.Request) {
|
||||
id := r.PathValue("id")
|
||||
auto, ok := s.automations.(*automations.Service)
|
||||
@@ -164,7 +164,7 @@ func (s *Server) adminRunAutomation(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, http.StatusOK, map[string]any{"id": id, "output": out})
|
||||
}
|
||||
|
||||
// adminDeleteAutomation removes a registered rule (cron or event) by id.
|
||||
// adminDeleteAutomation 按 id 移除一条已注册规则(cron 或 event)。
|
||||
func (s *Server) adminDeleteAutomation(w http.ResponseWriter, r *http.Request) {
|
||||
id := r.PathValue("id")
|
||||
auto, ok := s.automations.(*automations.Service)
|
||||
|
||||
Reference in new issue
Block a user