feat: 实现企业设备授权功能并归档 OpenSpec 变更
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 5m39s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 5m39s
- 新增企业设备授权模块(Model、DTO、Service、Handler、Store) - 实现设备授权的创建、查询、更新、删除等完整业务逻辑 - 添加企业卡授权与设备授权的关联关系 - 新增 2 个数据库迁移脚本 - 同步 OpenSpec delta specs 到 main specs - 归档 add-enterprise-device-authorization 变更 - 更新 API 文档和路由配置 - 新增完整的集成测试和单元测试覆盖
This commit is contained in:
@@ -46,6 +46,9 @@ func RegisterAdminRoutes(router fiber.Router, handlers *bootstrap.Handlers, midd
|
||||
if handlers.EnterpriseCard != nil {
|
||||
registerEnterpriseCardRoutes(authGroup, handlers.EnterpriseCard, doc, basePath)
|
||||
}
|
||||
if handlers.EnterpriseDevice != nil {
|
||||
registerEnterpriseDeviceRoutes(authGroup, handlers.EnterpriseDevice, doc, basePath)
|
||||
}
|
||||
if handlers.Authorization != nil {
|
||||
registerAuthorizationRoutes(authGroup, handlers.Authorization, doc, basePath)
|
||||
}
|
||||
|
||||
38
internal/routes/enterprise_device.go
Normal file
38
internal/routes/enterprise_device.go
Normal file
@@ -0,0 +1,38 @@
|
||||
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 registerEnterpriseDeviceRoutes(router fiber.Router, handler *admin.EnterpriseDeviceHandler, doc *openapi.Generator, basePath string) {
|
||||
enterprises := router.Group("/enterprises")
|
||||
groupPath := basePath + "/enterprises"
|
||||
|
||||
Register(enterprises, doc, groupPath, "POST", "/:id/allocate-devices", handler.AllocateDevices, RouteSpec{
|
||||
Summary: "授权设备给企业",
|
||||
Tags: []string{"企业设备授权"},
|
||||
Input: new(dto.AllocateDevicesReq),
|
||||
Output: new(dto.AllocateDevicesResp),
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(enterprises, doc, groupPath, "POST", "/:id/recall-devices", handler.RecallDevices, RouteSpec{
|
||||
Summary: "撤销设备授权",
|
||||
Tags: []string{"企业设备授权"},
|
||||
Input: new(dto.RecallDevicesReq),
|
||||
Output: new(dto.RecallDevicesResp),
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(enterprises, doc, groupPath, "GET", "/:id/devices", handler.ListDevices, RouteSpec{
|
||||
Summary: "企业设备列表",
|
||||
Tags: []string{"企业设备授权"},
|
||||
Input: new(dto.EnterpriseDeviceListReq),
|
||||
Output: new(dto.EnterpriseDeviceListResp),
|
||||
Auth: true,
|
||||
})
|
||||
}
|
||||
@@ -20,6 +20,9 @@ func RegisterH5Routes(router fiber.Router, handlers *bootstrap.Handlers, middlew
|
||||
if handlers.H5Order != nil {
|
||||
registerH5OrderRoutes(authGroup, handlers.H5Order, doc, basePath)
|
||||
}
|
||||
if handlers.EnterpriseDeviceH5 != nil {
|
||||
registerH5EnterpriseDeviceRoutes(authGroup, handlers.EnterpriseDeviceH5, doc, basePath)
|
||||
}
|
||||
}
|
||||
|
||||
func registerH5AuthRoutes(router fiber.Router, handler interface{}, authMiddleware fiber.Handler, doc *openapi.Generator, basePath string) {
|
||||
|
||||
46
internal/routes/h5_enterprise_device.go
Normal file
46
internal/routes/h5_enterprise_device.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/handler/h5"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/openapi"
|
||||
)
|
||||
|
||||
func registerH5EnterpriseDeviceRoutes(router fiber.Router, handler *h5.EnterpriseDeviceHandler, doc *openapi.Generator, basePath string) {
|
||||
devices := router.Group("/devices")
|
||||
groupPath := basePath + "/devices"
|
||||
|
||||
Register(devices, doc, groupPath, "GET", "", handler.ListDevices, RouteSpec{
|
||||
Summary: "企业设备列表(H5)",
|
||||
Tags: []string{"H5-企业设备"},
|
||||
Input: new(dto.H5EnterpriseDeviceListReq),
|
||||
Output: new(dto.EnterpriseDeviceListResp),
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(devices, doc, groupPath, "GET", "/:device_id", handler.GetDeviceDetail, RouteSpec{
|
||||
Summary: "获取设备详情(H5)",
|
||||
Tags: []string{"H5-企业设备"},
|
||||
Input: new(dto.DeviceDetailReq),
|
||||
Output: new(dto.EnterpriseDeviceDetailResp),
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(devices, doc, groupPath, "POST", "/:device_id/cards/:card_id/suspend", handler.SuspendCard, RouteSpec{
|
||||
Summary: "停机卡(H5)",
|
||||
Tags: []string{"H5-企业设备"},
|
||||
Input: new(dto.DeviceCardOperationReq),
|
||||
Output: new(dto.DeviceCardOperationResp),
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(devices, doc, groupPath, "POST", "/:device_id/cards/:card_id/resume", handler.ResumeCard, RouteSpec{
|
||||
Summary: "复机卡(H5)",
|
||||
Tags: []string{"H5-企业设备"},
|
||||
Input: new(dto.DeviceCardOperationReq),
|
||||
Output: new(dto.DeviceCardOperationResp),
|
||||
Auth: true,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user