From 5bc84c6bd739d65759c3fca753cdffadea12ce4b Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Mon, 30 Jan 2023 11:10:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/api/v1/api.go | 5 +++-- routers/api/v1/tech/tech.go | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 71cc54f41..fa91ff514 100755 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -540,8 +540,9 @@ func RegisterRoutes(m *macaron.Macaron) { m.Group("/tech", func() { m.Get("", tech.FindTech) m.Post("/basic", tech.ImportBasicInfo) - m.Post("/openi", bind(api.TechRepo{}), tech.CommitOpenIRepo) - m.Post("/no_openi", bind(api.TechRepo{}), tech.CommitNotOpenIRepo) + m.Get("/filter", tech.GetFilterInfo) + m.Get("/search", tech.SearchTechProjectInfo) + m.Get("/repo_search", tech.SearchRepoInfo) }, reqToken()) diff --git a/routers/api/v1/tech/tech.go b/routers/api/v1/tech/tech.go index 6416a5036..9b0f7bc93 100644 --- a/routers/api/v1/tech/tech.go +++ b/routers/api/v1/tech/tech.go @@ -14,6 +14,45 @@ import ( "github.com/360EntSecGroup-Skylar/excelize/v2" ) +func GetFilterInfo(ctx *context.APIContext) { + filterType := ctx.QueryInt("type") + limit := ctx.QueryInt("limit") + if filterType == 0 { + projectTypes := models.GetProjectTypes() + allInstitutions := models.GetAllInstitutions() + applyYears, executeYears := models.GetApplyExecuteYears() + ctx.JSON(http.StatusOK, map[string]interface{}{ + "type_name": projectTypes, + "institution_name": allInstitutions, + "execute_year": executeYears, + "apply_year": applyYears, + }) + return + } + if filterType == 1 { + projectNames := models.GetProjectNames() + topics := models.GetTechRepoTopics(limit) + allInstitutions := models.GetAllInstitutions() + ctx.JSON(http.StatusOK, map[string]interface{}{ + "topic": topics, + "institution_name": allInstitutions, + "project_name": projectNames, + }) + return + + } + ctx.Error(http.StatusBadRequest, "parameter error", "") + +} + +func SearchRepoInfo(ctx *context.APIContext) { + +} + +func SearchTechProjectInfo(ctx *context.APIContext) { + +} + func ImportBasicInfo(ctx *context.APIContext) { file, _, err := ctx.GetFile("file") if err != nil {