All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m3s
- 新增 GET /api/admin/shops/cascade 接口,支持按店铺名模糊查询和上级ID过滤
- Store 层新增 ListForCascade(支持数据权限过滤)和 GetParentIDsWithChildren 方法
- Service 层新增 ListCascade,批量判断 has_children 避免 N+1 查询
- 返回格式:[{id, shop_name, has_children}]
💘 Generated with Crush
Assisted-by: Claude Sonnet 4.6 via Crush <crush@charm.land>
123 lines
4.0 KiB
Go
123 lines
4.0 KiB
Go
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 registerShopRoutes(router fiber.Router, handler *admin.ShopHandler, doc *openapi.Generator, basePath string) {
|
|
shops := router.Group("/shops")
|
|
groupPath := basePath + "/shops"
|
|
|
|
Register(shops, doc, groupPath, "GET", "", handler.List, RouteSpec{
|
|
Summary: "店铺列表",
|
|
Tags: []string{"店铺管理"},
|
|
Input: new(dto.ShopListRequest),
|
|
Output: new(dto.ShopPageResult),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(shops, doc, groupPath, "POST", "", handler.Create, RouteSpec{
|
|
Summary: "创建店铺",
|
|
Tags: []string{"店铺管理"},
|
|
Input: new(dto.CreateShopRequest),
|
|
Output: new(dto.ShopResponse),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(shops, doc, groupPath, "PUT", "/:id", handler.Update, RouteSpec{
|
|
Summary: "更新店铺",
|
|
Tags: []string{"店铺管理"},
|
|
Input: new(dto.UpdateShopParams),
|
|
Output: new(dto.ShopResponse),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(shops, doc, groupPath, "DELETE", "/:id", handler.Delete, RouteSpec{
|
|
Summary: "删除店铺",
|
|
Tags: []string{"店铺管理"},
|
|
Input: new(dto.IDReq),
|
|
Output: nil,
|
|
Auth: true,
|
|
})
|
|
|
|
Register(shops, doc, groupPath, "GET", "/cascade", handler.Cascade, RouteSpec{
|
|
Summary: "店铺联级查询",
|
|
Tags: []string{"店铺管理"},
|
|
Input: new(dto.ShopCascadeRequest),
|
|
Output: new([]dto.ShopCascadeItem),
|
|
Auth: true,
|
|
})
|
|
}
|
|
|
|
func registerShopRoleRoutes(router fiber.Router, handler *admin.ShopRoleHandler, doc *openapi.Generator, basePath string) {
|
|
shops := router.Group("/shops")
|
|
groupPath := basePath + "/shops"
|
|
|
|
Register(shops, doc, groupPath, "POST", "/:shop_id/roles", handler.AssignShopRoles, RouteSpec{
|
|
Summary: "分配店铺默认角色",
|
|
Tags: []string{"店铺管理"},
|
|
Input: new(dto.AssignShopRolesRequest),
|
|
Output: new(dto.ShopRolesResponse),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(shops, doc, groupPath, "GET", "/:shop_id/roles", handler.GetShopRoles, RouteSpec{
|
|
Summary: "查询店铺默认角色",
|
|
Tags: []string{"店铺管理"},
|
|
Input: new(dto.GetShopRolesRequest),
|
|
Output: new(dto.ShopRolesResponse),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(shops, doc, groupPath, "DELETE", "/:shop_id/roles/:role_id", handler.DeleteShopRole, RouteSpec{
|
|
Summary: "删除店铺默认角色",
|
|
Tags: []string{"店铺管理"},
|
|
Input: new(dto.DeleteShopRoleRequest),
|
|
Output: nil,
|
|
Auth: true,
|
|
})
|
|
}
|
|
|
|
func registerShopCommissionRoutes(router fiber.Router, handler *admin.ShopCommissionHandler, doc *openapi.Generator, basePath string) {
|
|
shops := router.Group("/shops")
|
|
groupPath := basePath + "/shops"
|
|
|
|
Register(shops, doc, groupPath, "GET", "/commission-summary", handler.ListCommissionSummary, RouteSpec{
|
|
Summary: "代理商佣金列表",
|
|
Tags: []string{"代理商佣金管理"},
|
|
Input: new(dto.ShopCommissionSummaryListReq),
|
|
Output: new(dto.ShopCommissionSummaryPageResult),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(shops, doc, groupPath, "GET", "/:shop_id/withdrawal-requests", handler.ListWithdrawalRequests, RouteSpec{
|
|
Summary: "代理商提现记录",
|
|
Tags: []string{"代理商佣金管理"},
|
|
Input: new(dto.ShopWithdrawalRequestListReq),
|
|
Output: new(dto.ShopWithdrawalRequestPageResult),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(shops, doc, groupPath, "GET", "/:shop_id/commission-records", handler.ListCommissionRecords, RouteSpec{
|
|
Summary: "代理商佣金明细",
|
|
Tags: []string{"代理商佣金管理"},
|
|
Input: new(dto.ShopCommissionRecordListReq),
|
|
Output: new(dto.ShopCommissionRecordPageResult),
|
|
Auth: true,
|
|
})
|
|
|
|
commissionRecords := router.Group("/commission-records")
|
|
crPath := basePath + "/commission-records"
|
|
|
|
Register(commissionRecords, doc, crPath, "POST", "/:id/resolve", handler.ResolveCommissionRecord, RouteSpec{
|
|
Summary: "修正待审佣金记录",
|
|
Tags: []string{"代理商佣金管理"},
|
|
Input: new(dto.CommissionRecordResolveRequest),
|
|
Auth: true,
|
|
})
|
|
}
|