Browse Source

提交代码

tags/v1.22.12.2^2
yanchao 3 years ago
parent
commit
020bba5c38
2 changed files with 16 additions and 0 deletions
  1. +2
    -0
      routers/api/v1/api.go
  2. +14
    -0
      routers/api/v1/user/repo.go

+ 2
- 0
routers/api/v1/api.go View File

@@ -549,6 +549,8 @@ func RegisterRoutes(m *macaron.Macaron) {

}, reqToken())

m.Get("/compute-nodes", reqToken(), user.GetComputeNodes)

// Notifications
m.Group("/notifications", func() {
m.Combo("").


+ 14
- 0
routers/api/v1/user/repo.go View File

@@ -5,6 +5,7 @@
package user

import (
"code.gitea.io/gitea/modules/modelarts"
"net/http"

"code.gitea.io/gitea/models"
@@ -146,3 +147,16 @@ func ListOrgRepos(ctx *context.APIContext) {

listUserRepos(ctx, ctx.Org.Organization, ctx.IsSigned)
}

func GetComputeNodes(ctx *context.APIContext) {
modelarts.InitMultiNode()
if modelarts.MultiNodeConfig != nil {
for _, info := range modelarts.MultiNodeConfig.Info {
if isInOrg, _ := models.IsOrganizationMemberByOrgName(info.Org, ctx.User.ID); isInOrg {
ctx.JSON(http.StatusOK, info.Node)
return
}
}
}
ctx.JSON(http.StatusOK, []int{1})
}

Loading…
Cancel
Save