查询用户的公开信息
()
| 331 | |
| 332 | // 查询用户的公开信息 |
| 333 | func (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,则表示查询当前登录的用户发布的书籍 |
| 363 | func (this *CommonController) UserReleaseBook() { |
nothing calls this directly
no test coverage detected