MCPcopy Index your code
hub / github.com/TruthHun/BookStack / getFansOrFollow

Method getFansOrFollow

controllers/api/CommonController.go:286–330  ·  view source on GitHub ↗
(isGetFans bool)

Source from the content-addressed store, hash-verified

284}
285
286func (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// 查询用户的公开信息
333func (this *CommonController) UserInfo() {

Callers 2

UserFollowMethod · 0.95
UserFansMethod · 0.95

Calls 9

RangeNumberFunction · 0.92
CopyObjectFunction · 0.92
ShowImgFunction · 0.92
isLoginMethod · 0.80
ResponseMethod · 0.80
GetFansListMethod · 0.80
GetFollowListMethod · 0.80
completeLinkMethod · 0.80
appendFunction · 0.50

Tested by

no test coverage detected