models.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. package common
  2. import (
  3. "encoding/json"
  4. "time"
  5. "github.com/google/uuid"
  6. "gorm.io/gorm"
  7. )
  8. // Platform represents supported social media platforms
  9. type Platform string
  10. const (
  11. PlatformInstagram Platform = "instagram"
  12. PlatformTikTok Platform = "tiktok"
  13. PlatformYoutube Platform = "youtube"
  14. )
  15. // String converts Platform to string
  16. func (p Platform) String() string {
  17. return string(p)
  18. }
  19. // TrendAnalysis represents a trend analysis result
  20. type TrendAnalysis struct {
  21. ID uuid.UUID `gorm:"type:uuid;primary_key" json:"id"`
  22. ProfileID uuid.UUID `gorm:"type:uuid" json:"profile_id"`
  23. Type string `gorm:"not null" json:"type"` // social, google, audience
  24. Data json.RawMessage `gorm:"type:jsonb" json:"data"`
  25. CreatedAt time.Time `json:"created_at"`
  26. UpdatedAt time.Time `json:"updated_at"`
  27. DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
  28. }
  29. // SocialProfile represents a social media profile
  30. type SocialProfile struct {
  31. ID uuid.UUID `gorm:"type:uuid;primary_key" json:"id"`
  32. Platform string `gorm:"not null" json:"platform"`
  33. Username string `gorm:"not null" json:"username"`
  34. ProfileURL string `gorm:"not null" json:"profile_url"`
  35. FollowerCount int64 `json:"follower_count"`
  36. Engagement float64 `json:"engagement"`
  37. CreatedAt time.Time `json:"created_at"`
  38. UpdatedAt time.Time `json:"updated_at"`
  39. DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
  40. }
  41. // AudienceInsight represents audience analysis data
  42. type AudienceInsight struct {
  43. ID uuid.UUID `gorm:"type:uuid;primary_key" json:"id"`
  44. ProfileID uuid.UUID `gorm:"type:uuid" json:"profile_id"`
  45. Demographics json.RawMessage `gorm:"type:jsonb" json:"demographics"`
  46. Interests json.RawMessage `gorm:"type:jsonb" json:"interests"`
  47. ActivityTimes json.RawMessage `gorm:"type:jsonb" json:"activity_times"`
  48. CreatedAt time.Time `json:"created_at"`
  49. UpdatedAt time.Time `json:"updated_at"`
  50. DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
  51. }
  52. // GoogleTrend represents Google Trends data
  53. type GoogleTrend struct {
  54. ID uuid.UUID `gorm:"type:uuid;primary_key" json:"id"`
  55. Keywords []string `gorm:"type:text[]" json:"keywords"`
  56. TrendData json.RawMessage `gorm:"type:jsonb" json:"trend_data"`
  57. StartDate time.Time `json:"start_date"`
  58. EndDate time.Time `json:"end_date"`
  59. CreatedAt time.Time `json:"created_at"`
  60. UpdatedAt time.Time `json:"updated_at"`
  61. DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
  62. }
  63. type ContentTrend struct {
  64. TrendType TrendType `json:"trend_type"`
  65. Items []TrendItem `json:"items"`
  66. Timeframe string `json:"timeframe"`
  67. Platform Platform `json:"platform"`
  68. }
  69. type TrendType string
  70. const (
  71. TrendTypeHashtags TrendType = "hashtags"
  72. TrendTypeKeywords TrendType = "keywords"
  73. TrendTypeTopics TrendType = "topics"
  74. TrendTypePhrases TrendType = "phrases"
  75. TrendTypeMusicTracks TrendType = "music_tracks"
  76. TrendTypeChallenges TrendType = "challenges"
  77. )
  78. type TrendItem struct {
  79. Value string `json:"value"`
  80. Frequency int `json:"frequency"`
  81. GrowthRate float64 `json:"growth_rate"`
  82. Examples []string `json:"examples"`
  83. FirstSeen time.Time `json:"first_seen"`
  84. }
  85. type ProductSuggestion struct {
  86. ID uuid.UUID `gorm:"type:uuid;primary_key" json:"id"`
  87. UserID string `gorm:"not null" json:"user_id"`
  88. Name string `json:"name"`
  89. Description string `json:"description"`
  90. TargetAudience string `json:"target_audience"`
  91. RelevanceScore float64 `json:"relevance_score"`
  92. SuccessFactors []string `gorm:"type:text[]" json:"success_factors"`
  93. CreatedAt time.Time `json:"created_at"`
  94. UpdatedAt time.Time `json:"updated_at"`
  95. DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
  96. }
  97. type TrendQuery struct {
  98. Platform *Platform `form:"platform"`
  99. TrendTypes []TrendType `form:"trend_types"`
  100. Timeframe *string `form:"timeframe"`
  101. }
  102. type GetSuggestionsRequest struct {
  103. UserID string `json:"user_id"`
  104. Socials []Social `json:"socials"`
  105. }
  106. type Social struct {
  107. Platform Platform `json:"platform"`
  108. Username string `json:"username"`
  109. }