(isGetFans bool)
| 284 | } |
| 285 | |
| 286 | func (this *CommonController) getFansOrFollow(isGetFans bool) { |
| 287 | page, _ := this.GetInt("page", 1) |
| 288 | size, _ := this.GetInt("size", 10) |
| 289 | if page <= 0 { |
| 290 | page = 1 |
| 291 | } |
| 292 | size = utils.RangeNumber(size, 10, maxPageSize) |
| 293 | uid, _ := this.GetInt("uid") |
| 294 | if uid <= 0 { |
| 295 | uid = this.isLogin() |
| 296 | } |
| 297 | if uid <= 0 { |
| 298 | this.Response(http.StatusBadRequest, messageBadRequest) |
| 299 | } |
| 300 | var ( |
| 301 | fans []models.FansResult |
| 302 | totalCount int64 |
| 303 | err error |
| 304 | model = new(models.Fans) |
| 305 | ) |
| 306 | |
| 307 | if isGetFans { |
| 308 | fans, totalCount, err = model.GetFansList(uid, page, size) |
| 309 | } else { |
| 310 | fans, totalCount, err = model.GetFollowList(uid, page, size) |
| 311 | } |
| 312 | if err != nil { |
| 313 | beego.Error(err.Error()) |
| 314 | this.Response(http.StatusInternalServerError, messageInternalServerError) |
| 315 | } |
| 316 | |
| 317 | var users []APIUser |
| 318 | for _, item := range fans { |
| 319 | user := &APIUser{} |
| 320 | utils.CopyObject(&item, user) |
| 321 | user.Avatar = this.completeLink(utils.ShowImg(user.Avatar, "avatar")) |
| 322 | users = append(users, *user) |
| 323 | } |
| 324 | |
| 325 | data := map[string]interface{}{"total": totalCount} |
| 326 | if len(users) > 0 { |
| 327 | data["users"] = users |
| 328 | } |
| 329 | this.Response(http.StatusOK, messageSuccess, data) |
| 330 | } |
| 331 | |
| 332 | // 查询用户的公开信息 |
| 333 | func (this *CommonController) UserInfo() { |
no test coverage detected