package tech import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/routers/response" "code.gitea.io/gitea/services/repository" "net/http" ) func CommitOpenIRepo(ctx *context.APIContext, form api.TechRepo) { //解析项目路径,查找项目 repo, err := repository.FindRepoByUrl(form.Url) if err != nil { ctx.JSON(http.StatusOK, response.OuterServerError(err.Error())) return } //查找项目编号 tech, err := models.GetTechByTechNo(form.TechNo) if err != nil { ctx.JSON(http.StatusOK, response.OuterServerError(err.Error())) return } //写入数据库 rci := &models.RepoConvergeInfo{ RepoID: repo.ID, Url: form.Url, BaseInfoID: tech.ID, Institution: form.Institution, UID: ctx.User.ID, Status: models.DefaultTechStatus, } err = rci.InsertOrUpdate() if err != nil { ctx.JSON(http.StatusOK, response.OuterServerError(err.Error())) return } ctx.JSON(http.StatusOK, response.OuterSuccess()) return }