- Add Group and GroupMember models with CRUD service methods - Implement social group endpoints: create, list, get, join, leave - Add WishlistItem model with get/add/remove service methods - Add CartItem model with get/add/remove/checkout service methods - Create handlers for marketplace wishlist and cart operations - Register playlist export (JSON/CSV) and duplicate routes - Enable PLAYLIST_SHARE and NOTIFICATIONS feature flags Co-authored-by: Cursor <cursoragent@cursor.com>
45 lines
1.6 KiB
Go
45 lines
1.6 KiB
Go
package social
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// Group represents a social group that users can create and join
|
|
type Group struct {
|
|
ID uuid.UUID `gorm:"type:uuid;primaryKey;default:gen_random_uuid()" json:"id"`
|
|
Name string `gorm:"not null;size:255" json:"name"`
|
|
Description string `gorm:"type:text" json:"description"`
|
|
CreatorID uuid.UUID `gorm:"type:uuid;not null;index" json:"creator_id"`
|
|
AvatarURL string `gorm:"size:500" json:"avatar_url,omitempty"`
|
|
IsPublic bool `gorm:"default:true" json:"is_public"`
|
|
MemberCount int `gorm:"default:1" json:"member_count"`
|
|
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
|
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
|
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
|
}
|
|
|
|
func (g *Group) BeforeCreate(tx *gorm.DB) (err error) {
|
|
if g.ID == uuid.Nil {
|
|
g.ID = uuid.New()
|
|
}
|
|
return
|
|
}
|
|
|
|
// GroupMember represents a user's membership in a group
|
|
type GroupMember struct {
|
|
ID uuid.UUID `gorm:"type:uuid;primaryKey;default:gen_random_uuid()" json:"id"`
|
|
GroupID uuid.UUID `gorm:"type:uuid;not null;uniqueIndex:idx_group_member" json:"group_id"`
|
|
UserID uuid.UUID `gorm:"type:uuid;not null;uniqueIndex:idx_group_member" json:"user_id"`
|
|
Role string `gorm:"default:'member';size:50" json:"role"` // "admin", "moderator", "member"
|
|
JoinedAt time.Time `gorm:"autoCreateTime" json:"joined_at"`
|
|
}
|
|
|
|
func (gm *GroupMember) BeforeCreate(tx *gorm.DB) (err error) {
|
|
if gm.ID == uuid.Nil {
|
|
gm.ID = uuid.New()
|
|
}
|
|
return
|
|
}
|