Browse Source

去掉重名的函数

tags/v1.22.5.1^2
wangjr 3 years ago
parent
commit
0bebc91b0d
1 changed files with 0 additions and 82 deletions
  1. +0
    -82
      routers/home.go

+ 0
- 82
routers/home.go View File

@@ -750,88 +750,6 @@ func GetUserRankFromPromote(ctx *context.Context) {
ctx.JSON(200, resultUserRank) ctx.JSON(200, resultUserRank)
} }


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)

if err != nil {
return nil, err
}
resultOrg := make([]map[string]interface{}, 0)
for _, userRank := range result {
tmpIndex := strings.Index(userRank, " ")
userName := userRank
score := 0
if tmpIndex != -1 {
userName = userRank[0:tmpIndex]
tmpScore, err := strconv.Atoi(userRank[tmpIndex+1:])
if err != nil {
log.Info("convert to int error.")
}
score = tmpScore
}
user, err := models.GetUserByName(userName)
if err == nil {
userMap := make(map[string]interface{})
userMap["Name"] = user.Name
userMap["Description"] = user.Description
userMap["FullName"] = user.FullName
userMap["HomeLink"] = user.HomeLink()
userMap["ID"] = user.ID
userMap["Avatar"] = user.RelAvatarLink()
userMap["Score"] = score
resultOrg = append(resultOrg, userMap)
} else {
log.Info("query user error," + err.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)
if err != nil {
ctx.ServerError("500", err)
return
}
ctx.JSON(200, resultUserRank)
}

func RecommendOrgFromPromote(ctx *context.Context) { func RecommendOrgFromPromote(ctx *context.Context) {
resultOrg, err := GetRecommendOrg() resultOrg, err := GetRecommendOrg()
if err != nil { if err != nil {


Loading…
Cancel
Save