v2.go 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. package http
  2. import (
  3. v1 "go-common/app/service/main/account/api"
  4. "go-common/app/service/main/account/model"
  5. member "go-common/app/service/main/member/model"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. // v2MyInfo
  9. func v2MyInfo(c *bm.Context) {
  10. p := new(model.ParamMid)
  11. if err := c.Bind(p); err != nil {
  12. return
  13. }
  14. ps, err := accSvc.ProfileWithStat(c, p.Mid)
  15. if err != nil {
  16. c.JSON(nil, err)
  17. return
  18. }
  19. info := &V2MyInfo{}
  20. info.FromProfile(ps)
  21. c.JSON(info, nil)
  22. }
  23. // V2MyInfo myinfo.
  24. type V2MyInfo struct {
  25. Mid int64 `json:"mid"`
  26. Name string `json:"uname"`
  27. Face string `json:"face"`
  28. Rank int32 `json:"rank"`
  29. Scores int32 `json:"scores"`
  30. Coins float64 `json:"coins"`
  31. Sex int32 `json:"sex"`
  32. Sign string `json:"sign"`
  33. JoinTime int32 `json:"jointime"`
  34. Spacesta int32 `json:"spacesta"`
  35. Active int32 `json:"active"`
  36. Silence int32 `protobuf:"varint,12,opt,name=Silence,proto3" json:"silence"`
  37. EmailStatus int32 `protobuf:"varint,13,opt,name=EmailStatus,proto3" json:"email_status"`
  38. TelStatus int32 `protobuf:"varint,14,opt,name=TelStatus,proto3" json:"tel_status"`
  39. Identification int32 `protobuf:"varint,15,opt,name=Identification,proto3" json:"identification"`
  40. Moral int32 `protobuf:"varint,16,opt,name=Moral,proto3" json:"moral"`
  41. Birthday string `protobuf:"bytes,17,opt,name=Birthday,proto3" json:"birthday"`
  42. Telephone string `protobuf:"bytes,18,opt,name=Telephone,proto3" json:"telephone"`
  43. Level member.LevelInfo `protobuf:"bytes,19,opt,name=Level" json:"level_info"`
  44. Pendant v1.PendantInfo `protobuf:"bytes,20,opt,name=Pendant" json:"pendant"`
  45. Nameplate v1.NameplateInfo `protobuf:"bytes,21,opt,name=Nameplate" json:"nameplate"`
  46. Official model.OldOfficial `json:"official_verify"`
  47. Vip struct {
  48. Type int32 `protobuf:"varint,1,opt,name=Type,proto3" json:"vipType"`
  49. DueDate int64 `protobuf:"varint,2,opt,name=DueDate,proto3" json:"vipDueDate"`
  50. DueRemark string `protobuf:"bytes,3,opt,name=DueRemark,proto3" json:"dueRemark"`
  51. AccessStatus int32 `protobuf:"varint,4,opt,name=AccessStatus,proto3" json:"accessStatus"`
  52. VipStatus int32 `protobuf:"varint,5,opt,name=VipStatus,proto3" json:"vipStatus"`
  53. VipStatusWarn string `protobuf:"bytes,6,opt,name=VipStatusWarn,proto3" json:"vipStatusWarn"`
  54. } `json:"vip"`
  55. }
  56. // FromProfile from profile.
  57. func (i *V2MyInfo) FromProfile(c *model.ProfileStat) {
  58. i.Mid = c.Mid
  59. i.Name = c.Name
  60. switch c.Sex {
  61. case "男":
  62. i.Sex = 1
  63. case "女":
  64. i.Sex = 2
  65. default:
  66. i.Sex = 0
  67. }
  68. i.Sign = c.Sign
  69. i.Face = c.Face
  70. i.Rank = c.Rank
  71. i.JoinTime = c.JoinTime
  72. i.Silence = c.Silence
  73. if c.Silence == 1 {
  74. i.Spacesta = -2
  75. }
  76. i.EmailStatus = c.EmailStatus
  77. i.TelStatus = c.TelStatus
  78. if c.EmailStatus == 1 || c.TelStatus == 1 {
  79. i.Active = 1
  80. }
  81. i.Identification = c.Identification
  82. i.Coins = c.Coins
  83. i.Moral = c.Moral
  84. i.Level.Cur = c.Level
  85. i.Level.Min = c.LevelExp.Min
  86. i.Level.NowExp = c.LevelExp.NowExp
  87. i.Level.NextExp = c.LevelExp.NextExp
  88. i.Pendant = c.Pendant
  89. i.Nameplate = c.Nameplate
  90. i.Official = model.CvtOfficial(c.Official)
  91. i.Vip.Type = c.Vip.Type
  92. i.Vip.VipStatus = c.Vip.Status
  93. i.Vip.DueDate = c.Vip.DueDate
  94. }