feat: 实现套餐管理模块,包含套餐系列、双状态管理、废弃模型清理
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 5m24s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 5m24s
- 新增套餐系列管理 (CRUD + 状态切换) - 新增套餐管理 (CRUD + 启用/禁用 + 上架/下架双状态) - 清理 8 个废弃分佣模型及对应数据库表 - Package 模型新增建议成本价、建议售价、上架状态字段 - 完整的 Store/Service/Handler 三层实现 - 包含单元测试和集成测试 - 归档 add-package-module change - 新增多个 OpenSpec changes (订单支付、店铺套餐分配、一次性分佣、卡设备系列绑定)
This commit is contained in:
@@ -70,6 +70,12 @@ func RegisterAdminRoutes(router fiber.Router, handlers *bootstrap.Handlers, midd
|
||||
if handlers.Carrier != nil {
|
||||
registerCarrierRoutes(authGroup, handlers.Carrier, doc, basePath)
|
||||
}
|
||||
if handlers.PackageSeries != nil {
|
||||
registerPackageSeriesRoutes(authGroup, handlers.PackageSeries, doc, basePath)
|
||||
}
|
||||
if handlers.Package != nil {
|
||||
registerPackageRoutes(authGroup, handlers.Package, doc, basePath)
|
||||
}
|
||||
}
|
||||
|
||||
func registerAdminAuthRoutes(router fiber.Router, handler interface{}, authMiddleware fiber.Handler, doc *openapi.Generator, basePath string) {
|
||||
|
||||
70
internal/routes/package.go
Normal file
70
internal/routes/package.go
Normal file
@@ -0,0 +1,70 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/openapi"
|
||||
)
|
||||
|
||||
func registerPackageRoutes(router fiber.Router, handler *admin.PackageHandler, doc *openapi.Generator, basePath string) {
|
||||
packages := router.Group("/packages")
|
||||
groupPath := basePath + "/packages"
|
||||
|
||||
Register(packages, doc, groupPath, "GET", "", handler.List, RouteSpec{
|
||||
Summary: "套餐列表",
|
||||
Tags: []string{"套餐管理"},
|
||||
Input: new(dto.PackageListRequest),
|
||||
Output: new(dto.PackagePageResult),
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(packages, doc, groupPath, "POST", "", handler.Create, RouteSpec{
|
||||
Summary: "创建套餐",
|
||||
Tags: []string{"套餐管理"},
|
||||
Input: new(dto.CreatePackageRequest),
|
||||
Output: new(dto.PackageResponse),
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(packages, doc, groupPath, "GET", "/:id", handler.Get, RouteSpec{
|
||||
Summary: "获取套餐详情",
|
||||
Tags: []string{"套餐管理"},
|
||||
Input: new(dto.IDReq),
|
||||
Output: new(dto.PackageResponse),
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(packages, doc, groupPath, "PUT", "/:id", handler.Update, RouteSpec{
|
||||
Summary: "更新套餐",
|
||||
Tags: []string{"套餐管理"},
|
||||
Input: new(dto.UpdatePackageParams),
|
||||
Output: new(dto.PackageResponse),
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(packages, doc, groupPath, "DELETE", "/:id", handler.Delete, RouteSpec{
|
||||
Summary: "删除套餐",
|
||||
Tags: []string{"套餐管理"},
|
||||
Input: new(dto.IDReq),
|
||||
Output: nil,
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(packages, doc, groupPath, "PATCH", "/:id/status", handler.UpdateStatus, RouteSpec{
|
||||
Summary: "更新套餐状态",
|
||||
Tags: []string{"套餐管理"},
|
||||
Input: new(dto.UpdatePackageStatusParams),
|
||||
Output: nil,
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(packages, doc, groupPath, "PATCH", "/:id/shelf", handler.UpdateShelfStatus, RouteSpec{
|
||||
Summary: "更新套餐上架状态",
|
||||
Tags: []string{"套餐管理"},
|
||||
Input: new(dto.UpdatePackageShelfStatusParams),
|
||||
Output: nil,
|
||||
Auth: true,
|
||||
})
|
||||
}
|
||||
62
internal/routes/package_series.go
Normal file
62
internal/routes/package_series.go
Normal file
@@ -0,0 +1,62 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/openapi"
|
||||
)
|
||||
|
||||
func registerPackageSeriesRoutes(router fiber.Router, handler *admin.PackageSeriesHandler, doc *openapi.Generator, basePath string) {
|
||||
series := router.Group("/package-series")
|
||||
groupPath := basePath + "/package-series"
|
||||
|
||||
Register(series, doc, groupPath, "GET", "", handler.List, RouteSpec{
|
||||
Summary: "套餐系列列表",
|
||||
Tags: []string{"套餐系列管理"},
|
||||
Input: new(dto.PackageSeriesListRequest),
|
||||
Output: new(dto.PackageSeriesPageResult),
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(series, doc, groupPath, "POST", "", handler.Create, RouteSpec{
|
||||
Summary: "创建套餐系列",
|
||||
Tags: []string{"套餐系列管理"},
|
||||
Input: new(dto.CreatePackageSeriesRequest),
|
||||
Output: new(dto.PackageSeriesResponse),
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(series, doc, groupPath, "GET", "/:id", handler.Get, RouteSpec{
|
||||
Summary: "获取套餐系列详情",
|
||||
Tags: []string{"套餐系列管理"},
|
||||
Input: new(dto.IDReq),
|
||||
Output: new(dto.PackageSeriesResponse),
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(series, doc, groupPath, "PUT", "/:id", handler.Update, RouteSpec{
|
||||
Summary: "更新套餐系列",
|
||||
Tags: []string{"套餐系列管理"},
|
||||
Input: new(dto.UpdatePackageSeriesParams),
|
||||
Output: new(dto.PackageSeriesResponse),
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(series, doc, groupPath, "DELETE", "/:id", handler.Delete, RouteSpec{
|
||||
Summary: "删除套餐系列",
|
||||
Tags: []string{"套餐系列管理"},
|
||||
Input: new(dto.IDReq),
|
||||
Output: nil,
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(series, doc, groupPath, "PATCH", "/:id/status", handler.UpdateStatus, RouteSpec{
|
||||
Summary: "更新套餐系列状态",
|
||||
Tags: []string{"套餐系列管理"},
|
||||
Input: new(dto.UpdatePackageSeriesStatusParams),
|
||||
Output: nil,
|
||||
Auth: true,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user