All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 5m30s
新增功能: - 门店套餐分配管理(shop_package_allocation):支持门店套餐库存管理 - 门店套餐系列分配管理(shop_series_allocation):支持套餐系列分配和佣金层级设置 - 我的套餐查询(my_package):支持门店查询自己的套餐分配情况 测试改进: - 统一集成测试基础设施,新增 testutils.NewIntegrationTestEnv - 重构所有集成测试使用新的测试环境设置 - 移除旧的测试辅助函数和冗余测试文件 - 新增 test_helpers_test.go 统一任务测试辅助 技术细节: - 新增数据库迁移 000025_create_shop_allocation_tables - 新增 3 个 Handler、Service、Store 和对应的单元测试 - 更新 OpenAPI 文档和文档生成器 - 测试覆盖率:Service 层 > 90% Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
67 lines
3.0 KiB
Go
67 lines
3.0 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),
|
||
MyPackage: admin.NewMyPackageHandler(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))
|
||
}
|