Files
mayfly-go/server/internal/sys/router/resource.go

36 lines
972 B
Go
Raw Normal View History

package router
import (
"mayfly-go/internal/sys/api"
2024-11-20 22:43:53 +08:00
"mayfly-go/internal/sys/imsg"
2024-01-21 22:52:20 +08:00
"mayfly-go/pkg/biz"
"mayfly-go/pkg/ioc"
2023-01-14 16:29:52 +08:00
"mayfly-go/pkg/req"
"github.com/gin-gonic/gin"
)
func InitResourceRouter(router *gin.RouterGroup) {
rg := router.Group("sys/resources")
2024-01-21 22:52:20 +08:00
r := new(api.Resource)
biz.ErrIsNil(ioc.Inject(r))
reqs := [...]*req.Conf{
req.NewGet("", r.GetAllResourceTree),
req.NewGet(":id", r.GetById),
2024-11-20 22:43:53 +08:00
req.NewGet(":id/roles", r.GetResourceRoles),
2024-11-20 22:43:53 +08:00
req.NewPost("", r.SaveResource).Log(req.NewLogSaveI(imsg.LogResourceSave)).RequiredPermissionCode("resource:add"),
2024-11-20 22:43:53 +08:00
req.NewPut(":id/:status", r.ChangeStatus).Log(req.NewLogSaveI(imsg.LogChangeResourceStatus)).RequiredPermissionCode("resource:changeStatus"),
2024-11-20 22:43:53 +08:00
req.NewPost("sort", r.Sort).Log(req.NewLogSaveI(imsg.LogSortResource)),
req.NewDelete(":id", r.DelResource).Log(req.NewLogSaveI(imsg.LogResourceDelete)).RequiredPermissionCode("resource:delete"),
}
req.BatchSetGroup(rg, reqs[:])
}