mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-04 00:10:25 +08:00
refactor: 后端包结构重构、去除无用的文件
This commit is contained in:
55
server/internal/sys/router/role.go
Normal file
55
server/internal/sys/router/role.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/sys/api"
|
||||
"mayfly-go/internal/sys/application"
|
||||
"mayfly-go/pkg/ctx"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func InitRoleRouter(router *gin.RouterGroup) {
|
||||
r := &api.Role{
|
||||
RoleApp: application.RoleApp,
|
||||
ResourceApp: application.ResourceApp,
|
||||
}
|
||||
db := router.Group("sys/roles")
|
||||
{
|
||||
|
||||
db.GET("", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).Handle(r.Roles)
|
||||
})
|
||||
|
||||
saveRole := ctx.NewLogInfo("保存角色")
|
||||
sPermission := ctx.NewPermission("role:add")
|
||||
db.POST("", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(saveRole).
|
||||
WithRequiredPermission(sPermission).
|
||||
Handle(r.SaveRole)
|
||||
})
|
||||
|
||||
delRole := ctx.NewLogInfo("删除角色")
|
||||
drPermission := ctx.NewPermission("role:del")
|
||||
db.DELETE(":id", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(delRole).
|
||||
WithRequiredPermission(drPermission).
|
||||
Handle(r.DelRole)
|
||||
})
|
||||
|
||||
db.GET(":id/resourceIds", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).Handle(r.RoleResourceIds)
|
||||
})
|
||||
|
||||
db.GET(":id/resources", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).Handle(r.RoleResource)
|
||||
})
|
||||
|
||||
saveResource := ctx.NewLogInfo("保存角色资源")
|
||||
srPermission := ctx.NewPermission("role:saveResources")
|
||||
db.POST(":id/resources", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(saveResource).
|
||||
WithRequiredPermission(srPermission).
|
||||
Handle(r.SaveResource)
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user