complete role crud

This commit is contained in:
yanghao05
2023-02-04 19:54:29 +08:00
parent 2fb6bba903
commit 285e1f1c51
13 changed files with 270 additions and 19 deletions

View File

@@ -1,8 +1,11 @@
package routes
import (
"atom/common/err"
"atom/common/request"
"atom/contracts"
"atom/modules/auth/controller"
"atom/modules/auth/dto"
"atom/providers/http"
"github.com/rogeecn/gen"
@@ -29,9 +32,29 @@ func NewRoute(
func (r *Route) Register() {
group := r.svc.Engine.Group("auth")
{
roleGroup := group.Group("role")
roleGroup := group.Group("roles")
{
roleGroup.GET("/roles", gen.DataFunc(r.role.GetName))
roleGroup.GET("", gen.DataFunc2(
r.role.GetByFilter,
gen.BindQuery(dto.RoleRequestFilter{}, err.BindQueryFailed),
gen.BindQuery(request.PageFilter{}, err.BindQueryFailed),
))
roleGroup.POST("", gen.Func1(
r.role.Create,
gen.BindBody(dto.RoleRequestForm{}, err.BindBodyFailed),
))
roleGroup.PUT("/:id", gen.Func2(
r.role.UpdateByID,
gen.Int("role_id", err.BindPathFailed.Format("id")),
gen.BindBody(dto.RoleRequestForm{}, err.BindBodyFailed),
))
roleGroup.DELETE("/:id", gen.Func1(
r.role.Delete,
gen.Int("role_id", err.BindPathFailed.Format("id")),
))
}
permissionGroup := group.Group("permission")