完善授权凭证授权

This commit is contained in:
dushixiang
2021-01-15 19:17:10 +08:00
parent f4ec963f85
commit f38c77c202
11 changed files with 261 additions and 58 deletions

26
pkg/api/resource.go Normal file
View File

@ -0,0 +1,26 @@
package api
import (
"github.com/labstack/echo/v4"
"next-terminal/pkg/model"
"strings"
)
func ResourceGetAssignEndPoint(c echo.Context) error {
resourceId := c.Param("id")
userIds, err := model.FindUserIdsByResourceId(resourceId)
if err != nil {
return err
}
return Success(c, userIds)
}
func ResourceOverwriteAssignEndPoint(c echo.Context) error {
resourceId := c.Param("id")
userIds := c.QueryParam("userIds")
uIds := strings.Split(userIds, ",")
model.OverwriteUserIdsByResourceId(resourceId, uIds)
return Success(c, "")
}

View File

@ -102,15 +102,11 @@ func SetupRoutes() *echo.Echo {
sessions.GET("/:id", SessionGetEndpoint)
}
//tags := e.Group("/tags")
//{
// tags.POST("", TagAllEndpoint)
// tags.GET("/paging", TagPagingEndpoint)
// tags.POST("", TagCreateEndpoint)
// tags.PUT("/:id", TagUpdateEndpoint)
// tags.DELETE("/:id", TagDeleteEndpoint)
// tags.GET("/:id", TagGetEndpoint)
//}
resources := e.Group("/resources")
{
resources.GET("/:id/assign", ResourceGetAssignEndPoint)
resources.POST("/:id/assign", ResourceOverwriteAssignEndPoint)
}
e.GET("/properties", PropertyGetEndpoint)
e.PUT("/properties", PropertyUpdateEndpoint)