All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 5m18s
主要变更: - 重构分配模型:从加价模式(pricing_mode/pricing_value)改为返佣模式(base_commission + tier_commission) - 删除独立的 my_package 接口,统一到 /api/admin/packages(通过数据权限自动过滤) - 新增批量分配和批量调价功能,支持事务和性能优化 - 新增配置版本管理,订单创建时锁定返佣配置 - 新增成本价历史记录,支持审计和纠纷处理 - 新增统计缓存系统(Redis + 异步任务),优化梯度返佣计算性能 - 删除冗余的梯度佣金独立 CRUD 接口(合并到分配配置中) - 归档 3 个已完成的 OpenSpec changes 并同步 8 个新 capabilities 到 main specs 技术细节: - 数据库迁移:000026_refactor_shop_package_allocation - 新增 Store:AllocationConfigStore, PriceHistoryStore, CommissionStatsStore - 新增 Service:BatchAllocationService, BatchPricingService, CommissionStatsService - 新增异步任务:统计更新、定时同步、周期归档 - 测试覆盖:批量操作集成测试、梯度佣金 CRUD 清理验证 影响: - API 变更:删除 4 个梯度 CRUD 接口(POST/GET/PUT/DELETE /:id/tiers) - API 新增:批量分配、批量调价接口 - 数据模型:重构 shop_series_allocation 表结构 - 性能优化:批量操作使用 CreateInBatches,统计使用 Redis 缓存 相关文档: - openspec/changes/archive/2026-01-28-refactor-shop-package-allocation/ - openspec/specs/agent-available-packages/ - openspec/specs/allocation-config-versioning/ - 等 8 个新 capability specs
66 lines
2.9 KiB
Go
66 lines
2.9 KiB
Go
package main
|
||
|
||
import (
|
||
"github.com/gofiber/fiber/v2"
|
||
"go.uber.org/zap"
|
||
|
||
"github.com/break/junhong_cmp_fiber/internal/bootstrap"
|
||
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
|
||
"github.com/break/junhong_cmp_fiber/internal/handler/h5"
|
||
"github.com/break/junhong_cmp_fiber/internal/routes"
|
||
"github.com/break/junhong_cmp_fiber/pkg/openapi"
|
||
)
|
||
|
||
// generateOpenAPIDocs 生成 OpenAPI 文档
|
||
// outputPath: 文档输出路径
|
||
// logger: 日志记录器
|
||
// 生成失败时记录错误但不影响程序继续运行
|
||
func generateOpenAPIDocs(outputPath string, logger *zap.Logger) {
|
||
// 1. 创建生成器
|
||
adminDoc := openapi.NewGenerator("君鸿卡管系统 API", "1.0.0")
|
||
|
||
// 2. 创建临时 Fiber App 用于路由注册
|
||
app := fiber.New()
|
||
|
||
// 3. 创建 Handler(使用 nil 依赖,因为只需要路由结构)
|
||
handlers := &bootstrap.Handlers{
|
||
AdminAuth: admin.NewAuthHandler(nil, nil),
|
||
H5Auth: h5.NewAuthHandler(nil, nil),
|
||
Account: admin.NewAccountHandler(nil),
|
||
Role: admin.NewRoleHandler(nil),
|
||
Permission: admin.NewPermissionHandler(nil),
|
||
Shop: admin.NewShopHandler(nil),
|
||
ShopAccount: admin.NewShopAccountHandler(nil),
|
||
ShopCommission: admin.NewShopCommissionHandler(nil),
|
||
CommissionWithdrawal: admin.NewCommissionWithdrawalHandler(nil),
|
||
CommissionWithdrawalSetting: admin.NewCommissionWithdrawalSettingHandler(nil),
|
||
Enterprise: admin.NewEnterpriseHandler(nil),
|
||
EnterpriseCard: admin.NewEnterpriseCardHandler(nil),
|
||
Authorization: admin.NewAuthorizationHandler(nil),
|
||
CustomerAccount: admin.NewCustomerAccountHandler(nil),
|
||
MyCommission: admin.NewMyCommissionHandler(nil),
|
||
IotCard: admin.NewIotCardHandler(nil),
|
||
IotCardImport: admin.NewIotCardImportHandler(nil),
|
||
Device: admin.NewDeviceHandler(nil),
|
||
DeviceImport: admin.NewDeviceImportHandler(nil),
|
||
AssetAllocationRecord: admin.NewAssetAllocationRecordHandler(nil),
|
||
Storage: admin.NewStorageHandler(nil),
|
||
Carrier: admin.NewCarrierHandler(nil),
|
||
PackageSeries: admin.NewPackageSeriesHandler(nil),
|
||
Package: admin.NewPackageHandler(nil),
|
||
ShopSeriesAllocation: admin.NewShopSeriesAllocationHandler(nil),
|
||
ShopPackageAllocation: admin.NewShopPackageAllocationHandler(nil),
|
||
}
|
||
|
||
// 4. 注册所有路由到文档生成器
|
||
routes.RegisterRoutesWithDoc(app, handlers, &bootstrap.Middlewares{}, adminDoc)
|
||
|
||
// 6. 保存规范到指定路径
|
||
if err := adminDoc.Save(outputPath); err != nil {
|
||
logger.Error("生成 OpenAPI 文档失败", zap.String("path", outputPath), zap.Error(err))
|
||
return
|
||
}
|
||
|
||
logger.Info("OpenAPI 文档生成成功", zap.String("path", outputPath))
|
||
}
|