mirror of
https://gitee.com/dromara/mayfly-go
synced 2026-01-03 13:16:35 +08:00
feat: 新增机器授权凭证管理与其他优化
This commit is contained in:
45
server/internal/machine/router/auth_cert.go
Normal file
45
server/internal/machine/router/auth_cert.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/machine/api"
|
||||
"mayfly-go/internal/machine/application"
|
||||
"mayfly-go/pkg/req"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func InitAuthCertRouter(router *gin.RouterGroup) {
|
||||
r := &api.AuthCert{AuthCertApp: application.GetAuthCertApp()}
|
||||
db := router.Group("sys/authcerts")
|
||||
{
|
||||
listAcP := req.NewPermission("authcert")
|
||||
db.GET("", func(c *gin.Context) {
|
||||
req.NewCtxWithGin(c).
|
||||
WithRequiredPermission(listAcP).
|
||||
Handle(r.AuthCerts)
|
||||
})
|
||||
|
||||
// 基础授权凭证信息,不包含密码等
|
||||
db.GET("base", func(c *gin.Context) {
|
||||
req.NewCtxWithGin(c).Handle(r.BaseAuthCerts)
|
||||
})
|
||||
|
||||
saveAc := req.NewLogInfo("保存授权凭证").WithSave(true)
|
||||
saveAcP := req.NewPermission("authcert:save")
|
||||
db.POST("", func(c *gin.Context) {
|
||||
req.NewCtxWithGin(c).
|
||||
WithLog(saveAc).
|
||||
WithRequiredPermission(saveAcP).
|
||||
Handle(r.SaveAuthCert)
|
||||
})
|
||||
|
||||
deleteAc := req.NewLogInfo("删除授权凭证").WithSave(true)
|
||||
deleteAcP := req.NewPermission("authcert:del")
|
||||
db.DELETE(":id", func(c *gin.Context) {
|
||||
req.NewCtxWithGin(c).
|
||||
WithLog(deleteAc).
|
||||
WithRequiredPermission(deleteAcP).
|
||||
Handle(r.Delete)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -21,10 +21,6 @@ func InitMachineRouter(router *gin.RouterGroup) {
|
||||
req.NewCtxWithGin(c).Handle(m.Machines)
|
||||
})
|
||||
|
||||
machines.GET(":machineId/pwd", func(c *gin.Context) {
|
||||
req.NewCtxWithGin(c).Handle(m.GetMachinePwd)
|
||||
})
|
||||
|
||||
machines.GET(":machineId/stats", func(c *gin.Context) {
|
||||
req.NewCtxWithGin(c).Handle(m.MachineStats)
|
||||
})
|
||||
@@ -52,6 +48,11 @@ func InitMachineRouter(router *gin.RouterGroup) {
|
||||
Handle(m.SaveMachine)
|
||||
})
|
||||
|
||||
machines.POST("test-conn", func(c *gin.Context) {
|
||||
req.NewCtxWithGin(c).
|
||||
Handle(m.TestConn)
|
||||
})
|
||||
|
||||
changeStatus := req.NewLogInfo("调整机器状态").WithSave(true)
|
||||
machines.PUT(":machineId/:status", func(c *gin.Context) {
|
||||
req.NewCtxWithGin(c).
|
||||
|
||||
@@ -6,4 +6,5 @@ func Init(router *gin.RouterGroup) {
|
||||
InitMachineRouter(router)
|
||||
InitMachineFileRouter(router)
|
||||
InitMachineScriptRouter(router)
|
||||
InitAuthCertRouter(router)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user