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

36 lines
909 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 InitRoleRouter(router *gin.RouterGroup) {
rg := router.Group("sys/roles")
2024-01-21 22:52:20 +08:00
r := new(api.Role)
biz.ErrIsNil(ioc.Inject(r))
reqs := [...]*req.Conf{
req.NewGet("", r.Roles),
2024-11-20 22:43:53 +08:00
req.NewPost("", r.SaveRole).Log(req.NewLogSaveI(imsg.LogRoleSave)).RequiredPermissionCode("role:add"),
2024-11-20 22:43:53 +08:00
req.NewDelete(":id", r.DelRole).Log(req.NewLogSaveI(imsg.LogRoleDelete)).RequiredPermissionCode("role:del"),
req.NewGet(":id/resourceIds", r.RoleResourceIds),
req.NewGet(":id/resources", r.RoleResource),
2024-11-20 22:43:53 +08:00
req.NewPost(":id/resources", r.SaveResource).Log(req.NewLogSaveI(imsg.LogAssignRoleResource)).RequiredPermissionCode("role:saveResources"),
req.NewGet(":id/accounts", r.RoleAccount),
}
req.BatchSetGroup(rg, reqs[:])
}