Browse Source

提交代码。

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.22.5.1^2
zouap 3 years ago
parent
commit
c17e3bd36e
2 changed files with 35 additions and 0 deletions
  1. +34
    -0
      routers/home.go
  2. +1
    -0
      routers/routes/routes.go

+ 34
- 0
routers/home.go View File

@@ -642,6 +642,31 @@ func GetRecommendOrg() ([]map[string]interface{}, error) {
return resultOrg, nil
}

func GetImageInfo() ([]map[string]interface{}, error) {
url := setting.RecommentRepoAddr + "picture_info"
result, err := repository.RecommendFromPromote(url)

if err != nil {
return nil, err
}
imageInfo := make([]map[string]interface{}, 0)
for i := 0; i < (len(result) - 1); i++ {
line := result[i]
imageMap := make(map[string]interface{})
if line[0:4] == "url=" {
url := line[4:]
imageMap["url"] = url
if result[i+1][0:11] == "image_link=" {
image_link := result[i+1][11:]
imageMap["image_link"] = image_link
}
}
imageInfo = append(imageInfo, imageMap)
i = i + 1
}
return imageInfo, nil
}

func GetRankUser(index string) ([]map[string]interface{}, error) {
url := setting.RecommentRepoAddr + "user_rank_" + index
result, err := repository.RecommendFromPromote(url)
@@ -680,6 +705,15 @@ func GetRankUser(index string) ([]map[string]interface{}, error) {
return resultOrg, nil
}

func GetImageInfoFromPromote(ctx *context.Context) {
imageInfo, err := GetImageInfo()
if err != nil {
ctx.ServerError("500", err)
return
}
ctx.JSON(200, imageInfo)
}

func GetUserRankFromPromote(ctx *context.Context) {
index := ctx.Params("index")
resultUserRank, err := GetRankUser(index)


+ 1
- 0
routers/routes/routes.go View File

@@ -326,6 +326,7 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Get("/recommend/org", routers.RecommendOrgFromPromote)
m.Get("/recommend/repo", routers.RecommendRepoFromPromote)
m.Get("/recommend/userrank/:index", routers.GetUserRankFromPromote)
m.Get("/recommend/imageinfo", routers.GetImageInfoFromPromote)
m.Post("/all/search/", routers.Search)
m.Get("/all/search/", routers.EmptySearch)
m.Get("/all/dosearch/", routers.SearchApi)


Loading…
Cancel
Save