base.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package model
  2. import (
  3. "fmt"
  4. "math/rand"
  5. )
  6. // consts
  7. const (
  8. URLNoFace = "http://static.hdslb.com/images/member/noface.gif"
  9. ActUpdateByAdmin = "updateByAdmin"
  10. ActUpdatePersonInfo = "updatePersonInfo"
  11. ActUpdateFace = "updateFace"
  12. ActUpdateUname = "updateUname"
  13. ActBlockUser = "blockUser"
  14. CertNO = -1 // 未认证
  15. DefaultRank = 5000 // default rank
  16. DefaultTime = -28800 // default time
  17. DefaultMoral = 7000 // default moral
  18. MaxMoral = 10000 // max moral
  19. CacheKeyBase = "bs_%d" // key of baseInfo
  20. )
  21. // RandFaceURL get face URL
  22. func (b *BaseInfo) RandFaceURL() {
  23. if b.Face == "" {
  24. b.Face = URLNoFace
  25. return
  26. }
  27. b.Face = fmt.Sprintf("http://i%d.hdslb.com%s", rand.Int63n(3), b.Face)
  28. }
  29. // SexStr get sex str
  30. func (b *BaseInfo) SexStr() string {
  31. switch b.Sex {
  32. case 0:
  33. return "保密"
  34. case 1:
  35. return "男"
  36. case 2:
  37. return "女"
  38. default:
  39. return "保密"
  40. }
  41. }
  42. // NotifyInfo notify info.
  43. type NotifyInfo struct {
  44. Uname string `json:"uname"`
  45. Mid int64 `json:"mid"`
  46. Type string `json:"type"`
  47. NewName string `json:"newName"`
  48. Action string `json:"action"`
  49. }
  50. // Equal is.
  51. func (of *OfficialInfo) Equal(cof *OfficialInfo) bool {
  52. return of.Role == cof.Role && of.Title == cof.Title && of.Desc == cof.Desc
  53. }
  54. // BaseExp exp and base info.
  55. type BaseExp struct {
  56. *BaseInfo
  57. *LevelInfo
  58. }
  59. // Member is the full information within member-service.
  60. type Member struct {
  61. *BaseInfo
  62. *LevelInfo
  63. *OfficialInfo
  64. }