You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

repo.go 1.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package tech
  2. import (
  3. "code.gitea.io/gitea/models"
  4. "code.gitea.io/gitea/modules/context"
  5. api "code.gitea.io/gitea/modules/structs"
  6. "code.gitea.io/gitea/routers/response"
  7. "code.gitea.io/gitea/services/repository"
  8. "net/http"
  9. )
  10. func CommitOpenIRepo(ctx *context.APIContext, form api.TechRepo) {
  11. //解析项目路径,查找项目
  12. repo, err := repository.FindRepoByUrl(form.Url)
  13. if err != nil {
  14. ctx.JSON(http.StatusOK, response.OuterServerError(err.Error()))
  15. return
  16. }
  17. //查找项目编号
  18. tech, err := models.GetTechByTechNo(form.TechNo)
  19. if err != nil {
  20. ctx.JSON(http.StatusOK, response.OuterServerError(err.Error()))
  21. return
  22. }
  23. //写入数据库
  24. rci := &models.RepoConvergeInfo{
  25. RepoID: repo.ID,
  26. Url: form.Url,
  27. BaseInfoID: tech.ID,
  28. Institution: form.Institution,
  29. UID: ctx.User.ID,
  30. Status: models.DefaultTechStatus,
  31. }
  32. err = rci.InsertOrUpdate()
  33. if err != nil {
  34. ctx.JSON(http.StatusOK, response.OuterServerError(err.Error()))
  35. return
  36. }
  37. ctx.JSON(http.StatusOK, response.OuterSuccess())
  38. return
  39. }