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

Method UserInfo

controllers/api/CommonController.go:333–360  ·  view source on GitHub ↗

查询用户的公开信息

()

Source from the content-addressed store, hash-verified

331
332// 查询用户的公开信息
333func (this *CommonController) UserInfo() {
334 uid, _ := this.GetInt("uid")
335 if uid <= 0 {
336 uid = this.isLogin()
337 }
338 if uid <= 0 {
339 if this.Token != "" {
340 this.Response(http.StatusUnauthorized, messageRequiredLogin)
341 }
342 this.Response(http.StatusNotFound, messageNotFound)
343 }
344 member, err := models.NewMember().Find(uid)
345 if err != nil && err != orm.ErrNoRows {
346 beego.Error(err.Error())
347 this.Response(http.StatusInternalServerError, messageInternalServerError)
348 }
349 if member.MemberId == 0 {
350 this.Response(http.StatusNotFound, messageNotFound)
351 }
352 var user APIUser
353 utils.CopyObject(member, &user)
354
355 // 由于是公开信息,不显示用户email
356 user.Email = ""
357 user.Uid = member.MemberId
358 user.Avatar = this.completeLink(utils.ShowImg(user.Avatar, "avatar"))
359 this.Response(http.StatusOK, messageSuccess, map[string]interface{}{"user": user})
360}
361
362// 如果不传用户id,则表示查询当前登录的用户发布的书籍
363func (this *CommonController) UserReleaseBook() {

Callers

nothing calls this directly

Calls 7

NewMemberFunction · 0.92
CopyObjectFunction · 0.92
ShowImgFunction · 0.92
isLoginMethod · 0.80
ResponseMethod · 0.80
completeLinkMethod · 0.80
FindMethod · 0.45

Tested by

no test coverage detected