Files
mayfly-go/server/internal/sys/router/role.go
meilin.huang 99a746085b feat: i18n
2024-11-20 22:43:53 +08:00

36 lines
909 B
Go

package router
import (
"mayfly-go/internal/sys/api"
"mayfly-go/internal/sys/imsg"
"mayfly-go/pkg/biz"
"mayfly-go/pkg/ioc"
"mayfly-go/pkg/req"
"github.com/gin-gonic/gin"
)
func InitRoleRouter(router *gin.RouterGroup) {
rg := router.Group("sys/roles")
r := new(api.Role)
biz.ErrIsNil(ioc.Inject(r))
reqs := [...]*req.Conf{
req.NewGet("", r.Roles),
req.NewPost("", r.SaveRole).Log(req.NewLogSaveI(imsg.LogRoleSave)).RequiredPermissionCode("role:add"),
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),
req.NewPost(":id/resources", r.SaveResource).Log(req.NewLogSaveI(imsg.LogAssignRoleResource)).RequiredPermissionCode("role:saveResources"),
req.NewGet(":id/accounts", r.RoleAccount),
}
req.BatchSetGroup(rg, reqs[:])
}