review.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. package model
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "go-common/app/admin/main/member/model/block"
  6. "go-common/library/log"
  7. xtime "go-common/library/time"
  8. )
  9. // review state const.
  10. const (
  11. ReviewStateWait = iota
  12. ReviewStatePass
  13. ReviewStateNoPass
  14. ReviewStateArchived
  15. ReviewStateQueuing = 10
  16. )
  17. // review property const.
  18. const (
  19. ReviewProperty = iota
  20. ReviewPropertyFace
  21. ReviewPropertySign
  22. ReviewPropertyName
  23. )
  24. // all
  25. var (
  26. AllReviewStates = []int8{
  27. ReviewStateWait,
  28. ReviewStatePass,
  29. ReviewStateNoPass,
  30. ReviewStateQueuing,
  31. }
  32. )
  33. // UserPropertyReview is
  34. type UserPropertyReview struct {
  35. ID int64 `json:"id" gorm:"column:id"`
  36. Mid int64 `json:"mid" gorm:"column:mid"`
  37. Old string `json:"old" gorm:"column:old"`
  38. New string `json:"new" gorm:"column:new"`
  39. State int8 `json:"state" gorm:"column:state"`
  40. Property int8 `json:"property" gorm:"column:property"`
  41. Remark string `json:"remark" gorm:"column:remark"`
  42. Operator string `json:"operator" gorm:"column:operator"`
  43. IsMonitor bool `json:"is_monitor" gorm:"column:is_monitor"`
  44. Extra string `json:"extra" gorm:"column:extra"`
  45. CTime xtime.Time `json:"ctime" gorm:"column:ctime"`
  46. MTime xtime.Time `json:"mtime" gorm:"column:mtime"`
  47. // 昵称,展示用
  48. Name string `json:"name" gorm:"-"`
  49. FaceReject int64 `json:"face_reject" gorm:"-"`
  50. Block *block.BlockDetail `json:"block" gorm:"-"`
  51. Follower int64 `json:"follower" gorm:"-"`
  52. }
  53. // Extra is.
  54. type Extra struct {
  55. NickFree bool `json:"nick_free"`
  56. }
  57. // NickFree nick free.
  58. func (r *UserPropertyReview) NickFree() bool {
  59. if len(r.Extra) == 0 {
  60. return false
  61. }
  62. ext := Extra{}
  63. if err := json.Unmarshal([]byte(r.Extra), &ext); err != nil {
  64. log.Error("Failed to unmarshal extra, userPropertyReview: %+v error: %v", r, err)
  65. return false
  66. }
  67. return ext.NickFree
  68. }
  69. // FaceCheckRes is.
  70. type FaceCheckRes struct {
  71. Blood float64 `json:"blood,omitempty"`
  72. Violent float64 `json:"violent,omitempty"`
  73. Sex float64 `json:"sex,omitempty"`
  74. Politics float64 `json:"politics,omitempty"`
  75. }
  76. // Valid is.
  77. func (fcr *FaceCheckRes) Valid() bool {
  78. return fcr.Sex < 0.19 && fcr.Politics < 0.5 && fcr.Blood < 0.5 && fcr.Violent < 0.5
  79. }
  80. // String is.
  81. func (fcr *FaceCheckRes) String() string {
  82. return fmt.Sprintf("Sex: %.4f, Politics: %.4f", fcr.Sex, fcr.Politics)
  83. }
  84. //BuildFaceURL buildFaceUrl.
  85. func (r *UserPropertyReview) BuildFaceURL() {
  86. r.Old = BuildFaceURL(r.Old)
  87. r.New = BuildFaceURL(r.New)
  88. }