official.go 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. package model
  2. import (
  3. "encoding/json"
  4. xtime "go-common/library/time"
  5. )
  6. // official role const.
  7. const (
  8. OfficialRoleUnauth = iota
  9. OfficialRoleUp
  10. OfficialRoleIdentify
  11. OfficialRoleBusiness
  12. OfficialRoleGov
  13. OfficialRoleMedia
  14. OfficialRoleOther
  15. )
  16. // OfficialRoleName official role name.
  17. func OfficialRoleName(role int8) string {
  18. switch role {
  19. case OfficialRoleUnauth:
  20. return "未认证"
  21. case OfficialRoleUp:
  22. return "UP主认证"
  23. case OfficialRoleIdentify:
  24. return "身份认证"
  25. case OfficialRoleBusiness:
  26. return "企业认证"
  27. case OfficialRoleGov:
  28. return "政府认证"
  29. case OfficialRoleMedia:
  30. return "媒体认证"
  31. case OfficialRoleOther:
  32. return "其他认证"
  33. }
  34. return ""
  35. }
  36. // official state const.
  37. const (
  38. OfficialStateWait = iota
  39. OfficialStatePass
  40. OfficialStateNoPass
  41. OfficialStateReWait
  42. )
  43. // OfficialStateName official state name.
  44. func OfficialStateName(state int8) string {
  45. switch state {
  46. case OfficialStateWait:
  47. return "待审核"
  48. case OfficialStatePass:
  49. return "审核通过"
  50. case OfficialStateNoPass:
  51. return "审核未通过"
  52. case OfficialStateReWait:
  53. return "待重新审核"
  54. }
  55. return ""
  56. }
  57. // all
  58. var (
  59. AllRoles = []int8{
  60. OfficialRoleUnauth,
  61. OfficialRoleUp,
  62. OfficialRoleIdentify,
  63. OfficialRoleBusiness,
  64. OfficialRoleGov,
  65. OfficialRoleMedia,
  66. OfficialRoleOther,
  67. }
  68. AllStates = []int8{
  69. OfficialStateWait,
  70. OfficialStatePass,
  71. OfficialStateNoPass,
  72. OfficialStateReWait,
  73. }
  74. )
  75. // Official is.
  76. type Official struct {
  77. ID int64 `json:"id" gorm:"column:id"`
  78. Mid int64 `json:"mid" gorm:"column:mid"`
  79. Role int8 `json:"role" gorm:"column:role"`
  80. Title string `json:"title" gorm:"column:title"`
  81. Desc string `json:"desc" gorm:"column:description"`
  82. CTime xtime.Time `json:"ctime" gorm:"column:ctime"`
  83. MTime xtime.Time `json:"mtime" gorm:"column:mtime"`
  84. // 后台展示需求,需要查 official doc 对应的昵称
  85. Name string `json:"name" gorm:"-"`
  86. }
  87. // OfficialDoc is.
  88. type OfficialDoc struct {
  89. ID int64 `json:"id" gorm:"column:id"`
  90. Mid int64 `json:"mid" gorm:"column:mid"`
  91. Name string `json:"name" gorm:"column:name"`
  92. State int8 `json:"state" gorm:"column:state"`
  93. Role int8 `json:"role" gorm:"column:role"`
  94. Title string `json:"title" gorm:"column:title"`
  95. Desc string `json:"desc" gorm:"column:description"`
  96. Uname string `json:"uname" gorm:"column:uname"`
  97. Extra string `json:"-" gorm:"column:extra"`
  98. IsInternal bool `json:"is_internal" gorm:"column:is_internal"`
  99. RejectReason string `json:"reject_reason" gorm:"column:reject_reason"`
  100. SubmitSource string `json:"submit_source" gorm:"column:submit_source"`
  101. SubmitTime xtime.Time `json:"submit_time" gorm:"column:submit_time"`
  102. CTime xtime.Time `json:"ctime" gorm:"column:ctime"`
  103. MTime xtime.Time `json:"mtime" gorm:"column:mtime"`
  104. *OfficialExtra `gorm:"-"`
  105. }
  106. // OfficialExtra extra.
  107. type OfficialExtra struct {
  108. Realname int8 `json:"realname" gorm:"-"`
  109. Operator string `json:"operator" gorm:"-"`
  110. Telephone string `json:"telephone" gorm:"-"`
  111. Email string `json:"email" gorm:"-"`
  112. Address string `json:"address" gorm:"-"`
  113. Company string `json:"company" gorm:"-"`
  114. CreditCode string `json:"credit_code" gorm:"-"` // 社会信用代码
  115. Organization string `json:"organization" gorm:"-"` // 政府或组织名称
  116. OrganizationType string `json:"organization_type" gorm:"-"` // 政府或机构类型
  117. BusinessLicense string `json:"business_license" gorm:"-"` // 企业营业执照
  118. BusinessScale string `json:"business_scale" gorm:"-"` // 企业规模
  119. BusinessLevel string `json:"business_level" gorm:"-"` // 行政级别
  120. BusinessAuth string `json:"business_auth" gorm:"-"` // 企业授权函
  121. Supplement string `json:"supplement" gorm:"-"` // 其他补充材料
  122. Professional string `json:"professional" gorm:"-"` // 专业资质
  123. Identification string `json:"identification" gorm:"-"` // 身份证明
  124. OfficalSite string `json:"official_site" gorm:"-"` // 官方站点
  125. RegisteredCapital string `json:"registered_capital" gorm:"-"` // 注册资本
  126. }
  127. // OfficialDocAddit .
  128. type OfficialDocAddit struct {
  129. Mid int64 `json:"mid" gorm:"mid"`
  130. Property string `json:"property" gorm:"property"`
  131. Vstring string `json:"vstring" gorm:"vstring"`
  132. }
  133. // ParseExtra parse extra.
  134. func (oc *OfficialDoc) ParseExtra() {
  135. oe := &OfficialExtra{}
  136. if len(oc.Extra) > 0 {
  137. json.Unmarshal([]byte(oc.Extra), oe)
  138. }
  139. oc.OfficialExtra = oe
  140. }
  141. // Validate is.
  142. func (oc *OfficialDoc) Validate() bool {
  143. if oc.Mid <= 0 ||
  144. oc.Name == "" ||
  145. oc.Role <= 0 ||
  146. oc.Title == "" {
  147. return false
  148. }
  149. return true
  150. }
  151. // String is
  152. func (oe *OfficialExtra) String() string {
  153. bs, _ := json.Marshal(oe)
  154. if len(bs) == 0 {
  155. bs = []byte("{}")
  156. }
  157. return string(bs)
  158. }