Files
Christ 375e84d663 重构:统一应用服务与基础设施适配边界
将账号、认证、管理员、分析、自动化、卡券、聊天、商品、关键词、设置和订单能力迁移到 application 与 adapter,删除 Server 内对应的旧仓储和业务服务实现,并收紧架构检查。

完善批量发布与订单刷新生命周期、凭证写回、账号任务补偿、订单 reconciliation、通知和敏感数据边界;补充正常、失败、取消、并发、越权及多方言回归测试,并修正 MySQL 延迟任务表的 InnoDB 配置。

修复空卡密响应为 null 时前端加载失败的问题,重建嵌入式前端资产;重写重构总计划,清除历史流水并明确阶段 1 至 10 各对应一次完整迭代和一个 PR。

验证:make check;make test-server-race;npm test/typecheck/comments:check/build;Docker SQLite/MySQL 8.4/PostgreSQL 17 TestMultiDB_*。
2026-08-16 23:51:06 +08:00

29 lines
1.1 KiB
Go

package automation
import "context"
// PublishRuleRepository 定义批量发布成功后幂等准备自动化规则所需的最小持久化能力。
type PublishRuleRepository interface {
// EnsurePublishRule 确保同一发布商品的自动化规则只创建一次。
EnsurePublishRule(ctx context.Context, input RuleInput) error
}
// PublishRuleService 编排发布成功后的自动化规则幂等准备,不依赖 HTTP 或数据库模型。
type PublishRuleService struct {
// repository 保存调用方注入的发布自动化规则持久化端口。
repository PublishRuleRepository
}
// NewPublishRuleService 构造批量发布自动化规则应用服务。
func NewPublishRuleService(repository PublishRuleRepository) *PublishRuleService {
return &PublishRuleService{repository: repository}
}
// Ensure 确保发布自动化规则存在,并保留适配器返回的底层错误语义。
func (s *PublishRuleService) Ensure(ctx context.Context, input RuleInput) error {
if s == nil || s.repository == nil {
return ErrInvalidInput
}
return s.repository.EnsurePublishRule(ctx, input)
}