完善授权凭证授权
This commit is contained in:
26
pkg/api/resource.go
Normal file
26
pkg/api/resource.go
Normal 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, "")
|
||||
}
|
@ -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)
|
||||
|
Reference in New Issue
Block a user