Files
junhong_cmp_fiber/cmd/api/docs.go
huang ce0783f96e
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 5m30s
feat: 实现设备管理和设备导入功能,修复测试问题
主要变更:
- 实现设备管理模块(创建、查询、列表、更新状态、删除)
- 实现设备批量导入功能(CSV 解析、ICCID 绑定、异步任务处理)
- 添加设备-SIM 卡绑定约束(部分唯一索引防止并发问题)
- 修复 fee_rate 数据库字段类型(numeric -> bigint)
- 修复测试数据隔离问题(基于增量断言)
- 修复集成测试中间件顺序问题
- 清理无用测试文件(PersonalCustomer、Email 相关)
- 归档 enterprise-card-authorization 变更
2026-01-26 18:05:12 +08:00

61 lines
2.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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),
}
// 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))
}