official.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package model
  2. import (
  3. "encoding/json"
  4. xtime "go-common/library/time"
  5. )
  6. // official state const.
  7. const (
  8. OfficialStateWait = iota
  9. OfficialStatePass
  10. OfficialStateNoPass
  11. OfficialStateReWait
  12. )
  13. // official role const.
  14. const (
  15. OfficialRoleUnauth = iota
  16. OfficialRoleUp
  17. OfficialRoleIdentify
  18. OfficialRoleBusiness
  19. OfficialRoleGov
  20. OfficialRoleMedia
  21. OfficialRoleOther
  22. )
  23. // OfficialDoc official doc.
  24. type OfficialDoc struct {
  25. Mid int64 `json:"mid"`
  26. Name string `json:"name"`
  27. State int8 `json:"state"`
  28. Role int8 `json:"role"`
  29. Title string `json:"title"`
  30. Desc string `json:"desc"`
  31. Extra string `json:"-"`
  32. RejectReason string `json:"reject_reason"` // 被拒绝理由
  33. SubmitSource string `json:"submit_source"` // 提交来源
  34. SubmitTime xtime.Time `json:"submit_time"` // 最后提交时间
  35. OfficialExtra
  36. }
  37. // OfficialExtra official extra.
  38. type OfficialExtra struct {
  39. Realname int8 `json:"realname"`
  40. Operator string `json:"operator"` // 经营人
  41. Telephone string `json:"telephone"` // 电话号码
  42. Email string `json:"email"` // 邮箱
  43. Address string `json:"address"` // 地址
  44. Company string `json:"company"` // 公司
  45. CreditCode string `json:"credit_code"` // 社会信用代码
  46. Organization string `json:"organization"` // 政府或组织名称
  47. OrganizationType string `json:"organization_type"` // 组织或机构类型
  48. BusinessLicense string `json:"business_license"` // 企业营业执照
  49. BusinessScale string `json:"business_scale"` // 企业规模
  50. BusinessLevel string `json:"business_level"` // 企业登记
  51. BusinessAuth string `json:"business_auth"` // 企业授权函
  52. Supplement string `json:"supplement"` // 其他补充材料
  53. Professional string `json:"professional"` // 专业资质
  54. Identification string `json:"identification"` // 身份证明
  55. OfficialSite string `json:"official_site"` // 官网地址
  56. RegisteredCapital string `json:"registered_capital"` // 注册资金
  57. }
  58. // ParseExtra parse extra.
  59. func (oc *OfficialDoc) ParseExtra() {
  60. oe := OfficialExtra{}
  61. if len(oc.Extra) > 0 {
  62. json.Unmarshal([]byte(oc.Extra), &oe)
  63. }
  64. oc.OfficialExtra = oe
  65. }
  66. // String is
  67. func (oe OfficialExtra) String() string {
  68. bs, _ := json.Marshal(oe)
  69. if len(bs) == 0 {
  70. bs = []byte("{}")
  71. }
  72. return string(bs)
  73. }
  74. // Validate is.
  75. func (oc OfficialDoc) Validate() bool {
  76. if oc.Mid <= 0 ||
  77. oc.Name == "" ||
  78. oc.Role <= 0 ||
  79. oc.Title == "" {
  80. return false
  81. }
  82. return true
  83. }