|
|
@@ -7,6 +7,7 @@ package routers |
|
|
|
|
|
|
|
import ( |
|
|
|
"bytes" |
|
|
|
"encoding/json" |
|
|
|
"net/http" |
|
|
|
"strconv" |
|
|
|
"strings" |
|
|
@@ -672,7 +673,7 @@ func NotFound(ctx *context.Context) { |
|
|
|
} |
|
|
|
|
|
|
|
func getRecommendOrg() ([]map[string]interface{}, error) { |
|
|
|
url := setting.RecommentRepoAddr + "organizations" |
|
|
|
url := setting.RecommentRepoAddr + "home/organizations" |
|
|
|
result, err := repository.RecommendFromPromote(url) |
|
|
|
|
|
|
|
if err != nil { |
|
|
@@ -745,7 +746,7 @@ func GetMapInfo(ctx *context.Context) { |
|
|
|
} |
|
|
|
|
|
|
|
func GetRankUser(index string) ([]map[string]interface{}, error) { |
|
|
|
url := setting.RecommentRepoAddr + "user_rank_" + index |
|
|
|
url := setting.RecommentRepoAddr + "user_rank/user_rank_" + index |
|
|
|
result, err := repository.RecommendFromPromote(url) |
|
|
|
|
|
|
|
if err != nil { |
|
|
@@ -792,25 +793,47 @@ func GetUserRankFromPromote(ctx *context.Context) { |
|
|
|
ctx.JSON(200, resultUserRank) |
|
|
|
} |
|
|
|
|
|
|
|
func getMapContent(fileName string) []map[string]string { |
|
|
|
url := setting.RecommentRepoAddr + fileName |
|
|
|
result, err := repository.RecommendContentFromPromote(url) |
|
|
|
remap := make([]map[string]string, 0) |
|
|
|
if err == nil { |
|
|
|
json.Unmarshal([]byte(result), &remap) |
|
|
|
} |
|
|
|
return remap |
|
|
|
} |
|
|
|
|
|
|
|
func RecommendHomeInfo(ctx *context.Context) { |
|
|
|
resultOrg, err := getRecommendOrg() |
|
|
|
if err != nil { |
|
|
|
log.Info("error." + err.Error()) |
|
|
|
} |
|
|
|
resultRepo, err := repository.GetRecommendRepoFromPromote("projects") |
|
|
|
if err != nil { |
|
|
|
log.Info("error." + err.Error()) |
|
|
|
} |
|
|
|
resultImage, err := getImageInfo("picture_info") |
|
|
|
resultRepo, err := repository.GetRecommendRepoFromPromote("home/projects") |
|
|
|
if err != nil { |
|
|
|
log.Info("error." + err.Error()) |
|
|
|
} |
|
|
|
|
|
|
|
resultActivityInfo := getMapContent("home/activity_info") |
|
|
|
mapInterface := make(map[string]interface{}) |
|
|
|
mapInterface["org"] = resultOrg |
|
|
|
mapInterface["repo"] = resultRepo |
|
|
|
mapInterface["image"] = resultImage |
|
|
|
//mapInterface["cloudbrain"] = resultCloudBrain |
|
|
|
mapInterface["activity"] = resultActivityInfo |
|
|
|
|
|
|
|
user_experience := getMapContent("home/user_experience") |
|
|
|
for _, amap := range user_experience { |
|
|
|
userId := amap["userid"] |
|
|
|
userIntId, _ := strconv.Atoi(userId) |
|
|
|
user, err := models.GetUserByID(int64(userIntId)) |
|
|
|
if err == nil { |
|
|
|
amap["name"] = user.FullName |
|
|
|
amap["detail"] = user.Description |
|
|
|
amap["avatar"] = user.AvatarLink() |
|
|
|
} |
|
|
|
} |
|
|
|
mapInterface["user_experience"] = user_experience |
|
|
|
dataset, err := models.QueryDatasetGroupByTask() |
|
|
|
if err == nil { |
|
|
|
mapInterface["dataset"] = dataset |
|
|
|
} |
|
|
|
ctx.JSON(http.StatusOK, mapInterface) |
|
|
|
} |
|
|
|
|
|
|
@@ -824,4 +847,4 @@ func HomePrivacy(ctx *context.Context) { |
|
|
|
|
|
|
|
func HomeResoruceDesc(ctx *context.Context) { |
|
|
|
ctx.HTML(200, tplResoruceDesc) |
|
|
|
} |
|
|
|
} |