All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 5m9s
主要功能: - 添加企业卡授权/回收接口 (POST /enterprises/:id/allocate-cards, recall-cards) - 添加授权记录管理接口 (GET/PUT /authorizations) - 实现代理用户数据权限过滤(只能查看自己店铺下企业的授权记录) - 添加 GORM callback 支持授权记录表的数据权限过滤 技术改进: - 原生 SQL 查询手动添加数据权限过滤(ListWithJoin, GetByIDWithJoin) - 移除卡授权预检接口(allocate-cards/preview),保留内部方法 - 完善单元测试和集成测试覆盖
55 lines
1.7 KiB
Go
55 lines
1.7 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 registerEnterpriseCardRoutes(router fiber.Router, handler *admin.EnterpriseCardHandler, doc *openapi.Generator, basePath string) {
|
|
enterprises := router.Group("/enterprises")
|
|
groupPath := basePath + "/enterprises"
|
|
|
|
Register(enterprises, doc, groupPath, "POST", "/:id/allocate-cards", handler.AllocateCards, RouteSpec{
|
|
Summary: "授权卡给企业",
|
|
Tags: []string{"企业卡授权"},
|
|
Input: new(dto.AllocateCardsReq),
|
|
Output: new(dto.AllocateCardsResp),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(enterprises, doc, groupPath, "POST", "/:id/recall-cards", handler.RecallCards, RouteSpec{
|
|
Summary: "回收卡授权",
|
|
Tags: []string{"企业卡授权"},
|
|
Input: new(dto.RecallCardsReq),
|
|
Output: new(dto.RecallCardsResp),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(enterprises, doc, groupPath, "GET", "/:id/cards", handler.ListCards, RouteSpec{
|
|
Summary: "企业卡列表",
|
|
Tags: []string{"企业卡授权"},
|
|
Input: new(dto.EnterpriseCardListReq),
|
|
Output: new(dto.EnterpriseCardPageResult),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(enterprises, doc, groupPath, "POST", "/:id/cards/:card_id/suspend", handler.SuspendCard, RouteSpec{
|
|
Summary: "停机卡",
|
|
Tags: []string{"企业卡授权"},
|
|
Input: new(dto.SuspendCardReq),
|
|
Output: nil,
|
|
Auth: true,
|
|
})
|
|
|
|
Register(enterprises, doc, groupPath, "POST", "/:id/cards/:card_id/resume", handler.ResumeCard, RouteSpec{
|
|
Summary: "复机卡",
|
|
Tags: []string{"企业卡授权"},
|
|
Input: new(dto.ResumeCardReq),
|
|
Output: nil,
|
|
Auth: true,
|
|
})
|
|
}
|