models

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FastCheckExternalMedia

func FastCheckExternalMedia(media *ExternalMedia) error

func RegesterExternalPlatform

func RegesterExternalPlatform(externalPlatform ExternalPlatform)

Types

type BiliBiliVideo

type BiliBiliVideo struct {
	BVID string `json:"bvid" property:"bvid;视频ID"`
}

func (*BiliBiliVideo) GetDisplayName

func (*BiliBiliVideo) GetDisplayName() string

func (*BiliBiliVideo) GetMediaType

func (*BiliBiliVideo) GetMediaType() MediaType

func (*BiliBiliVideo) GetName

func (*BiliBiliVideo) GetName() string

func (*BiliBiliVideo) Html

func (b *BiliBiliVideo) Html(isMobile bool) string

func (*BiliBiliVideo) Init

func (b *BiliBiliVideo) Init(config map[string]string)

type Card

type Card struct {
	Name  string      `json:"name"`
	Model interface{} `json:"model"`
}

type Comment

type Comment struct {
	gorm.Model

	UserID     uint     `gorm:"column:userId" json:"userId"`
	PostId     uint     `gorm:"column:postId;not null;index" json:"postId"`
	IP         string   `gorm:"column:ip;not null" json:"-"`
	Content    string   `gorm:"column:content;not null" json:"content"`
	ReplyTo    *ReplyTo `gorm:"column:replyTo;serializer:json" json:"replyTo"`
	IsApproved bool     `gorm:"column:isApproved;default:false" json:"isApproved"`
}

type CommentDetail

type CommentDetail struct {
	PostDetail *PostDetail `json:"post"`
	UserDetail *UserDetail `json:"user"`
	Comment    *Comment    `json:"comment"`
	ReplyTo    *UserDetail `json:"replyto"`
}

type ExternalMedia

type ExternalMedia struct {
	Type   MediaType         `json:"type"`
	Name   string            `json:"name"`
	Config map[string]string `json:"config"`
}

type ExternalPlatform

type ExternalPlatform interface {
	GetName() string
	GetDisplayName() string
	GetMediaType() MediaType
	Init(config map[string]string)
	Html(isMobile bool) string
}

func GetExternalPlatform

func GetExternalPlatform(media *ExternalMedia) (ExternalPlatform, error)

type Like

type Like struct {
	gorm.Model

	UserID uint   `gorm:"column:userId;not null" json:"userId"`
	PostId uint   `gorm:"column:postId;not null;index:index_postid" json:"postId"`
	IP     string `gorm:"column:ip;not null" json:"ip"`
}

func (*Like) MarshalJSON

func (l *Like) MarshalJSON() ([]byte, error)

type LikeDetail

type LikeDetail struct {
	PostDetail *PostDetail `json:"post"`
	UserDetail *UserDetail `json:"user"`
	Like       *Like       `json:"like"`
}

type LikeDetails

type LikeDetails struct {
	PostId           uint          `json:"postId"`
	LikeDetails      []*LikeDetail `json:"likeDetails"`
	VisitorLikeCount uint          `json:"visitorLikeCount"`
	IsLiked          bool          `json:"isLiked"`
}

type Media

type Media struct {
	Type      MediaType `json:"type"`
	Url       string    `json:"url"`
	Thumbnail string    `json:"thumbnail"`
	Title     *string   `json:"title"`
	Artist    *string   `json:"artist"`
	Album     *string   `json:"ablum"`
	Duration  int64     `json:"duration"`
}

type MediaType

type MediaType string
const (
	FileMediaType    MediaType = "file"
	VideoMediaType   MediaType = "video"
	MusicMediaType   MediaType = "music"
	ImageMediaType   MediaType = "image"
	UnknownMediaType MediaType = "unknown"
)

type Music163

type Music163 struct {
	MusicID string `json:"musicid" property:"musicid;音乐ID"`
}

func (*Music163) GetDisplayName

func (*Music163) GetDisplayName() string

func (*Music163) GetMediaType

func (*Music163) GetMediaType() MediaType

func (*Music163) GetName

func (*Music163) GetName() string

func (*Music163) Html

func (m *Music163) Html(isMobile bool) string

func (*Music163) Init

func (m *Music163) Init(config map[string]string)

type PageResult

type PageResult struct {
	Page     uint        `json:"page"`
	PageSize uint        `json:"pageSize"`
	Data     interface{} `json:"data"`
}

func NewPageResult

func NewPageResult(page, pageSize uint, data []interface{}) PageResult

type Post

type Post struct {
	gorm.Model

	UserID        uint           `gorm:"column:userId;index" json:"userId"`
	PostType      PostType       `gorm:"column:postType;not null" json:"postType"`
	Content       string         `gorm:"column:text;" json:"content"`
	Medias        []Media        `gorm:"column:medias;serializer:json" json:"medias"`
	Url           *Url           `gorm:"column:url;serializer:json" json:"url"`
	ExternalMedia *ExternalMedia `gorm:"column:externalMedia;serializer:json" json:"externalMedia"`
	Card          *Card          `gorm:"column:card;serializer:json" json:"card"`
	IsApproved    bool           `gorm:"column:isApproved;default:false" json:"isApproved"`
	Address       string         `gorm:"column:address;" json:"address"`
	Visibility    Visibility     `gorm:"column:visibility;" json:"visibility"`
	Priority      uint           `gorm:"column:priority;default:0" json:"priority"`
	IsUpdated     bool           `gorm:"column:isUpdated;default:false" json:"isUpdated"`
}

func (*Post) BeforeCreate

func (p *Post) BeforeCreate(tx *gorm.DB) (err error)

type PostDetail

type PostDetail struct {
	UserDetail *UserDetail `json:"user"`
	Post       *Post       `json:"post"`
}

type PostType

type PostType string
const (
	TextPostType     PostType = "text"
	ImagePostType    PostType = "image"
	FilePostType     PostType = "file"
	UrlPostType      PostType = "url"
	MusicPostType    PostType = "music"
	VideoPostType    PostType = "video"
	ExternalPostType PostType = "external"
	CardPostType     PostType = "card"
)

type QQMusic

type QQMusic struct {
	SongID string `json:"songid" property:"songid;音乐ID"`
}

func (*QQMusic) GetDisplayName

func (*QQMusic) GetDisplayName() string

func (*QQMusic) GetMediaType

func (*QQMusic) GetMediaType() MediaType

func (*QQMusic) GetName

func (*QQMusic) GetName() string

func (*QQMusic) Html

func (m *QQMusic) Html(isMobile bool) string

func (*QQMusic) Init

func (m *QQMusic) Init(config map[string]string)

type ReplyTo

type ReplyTo struct {
	Uid uint `json:"uid"`
	Cid uint `json:"cid"`
}

type Role

type Role string
const (
	AdminRole   Role = "admin"
	UserRole    Role = "user"
	VisitorRole Role = "visitor"
)

type SimpleUser

type SimpleUser struct {
	ID       uint   `json:"id"`
	Email    string `json:"email"`
	Role     Role   `json:"role"`
	Username string `json:"username"`
	Avatar   string `json:"avatar"`
	Enable   bool   `json:"enable"`
}

type SupportPlatform

type SupportPlatform struct {
	Name        string                `json:"name"`
	Displayname string                `json:"displayname"`
	Props       *SupportPlatformProps `json:"props"`
}

type SupportPlatformProp

type SupportPlatformProp struct {
	Name        string `json:"name"`
	Displayname string `json:"displayname"`
}

type SupportPlatformProps

type SupportPlatformProps []*SupportPlatformProp

type SupportPlatforms

type SupportPlatforms map[string][]*SupportPlatform

func GetSupportPlatforms

func GetSupportPlatforms() SupportPlatforms

type TencentVideo

type TencentVideo struct {
	VideoID string `json:"videoid" property:"videoid;视频ID"`
}

func (*TencentVideo) GetDisplayName

func (*TencentVideo) GetDisplayName() string

func (*TencentVideo) GetMediaType

func (*TencentVideo) GetMediaType() MediaType

func (*TencentVideo) GetName

func (*TencentVideo) GetName() string

func (*TencentVideo) Html

func (t *TencentVideo) Html(isMobile bool) string

func (*TencentVideo) Init

func (t *TencentVideo) Init(config map[string]string)

type Url

type Url struct {
	Title    string `json:"title"`
	Abstract string `json:"abstract"`
	Url      string `json:"url"`
}

type User

type User struct {
	gorm.Model

	Email    string `gorm:"uniqueIndex;not null;size:30" json:"email"`
	Role     Role   `gorm:"role;not null" json:"role"`
	Username string `gorm:"column:uname;not null;size:20" json:"username"`
	Password string `gorm:"not null" json:"password"`
	Enable   bool   `gorm:"not null;default:true" json:"enable"`
}

func (*User) BeforeCreate

func (u *User) BeforeCreate(tx *gorm.DB) (err error)

func (*User) MarshalJSON

func (u *User) MarshalJSON() ([]byte, error)

type UserDetail

type UserDetail struct {
	ID      uint         `json:"id"`
	User    *User        `json:"user"`
	Profile *UserProfile `json:"profile"`
}

type UserProfile

type UserProfile struct {
	gorm.Model

	UserID    uint   `gorm:"column:userId;uniqueIndex;not null"  json:"userId"`
	Avatar    string `gorm:"column:avatar"   json:"avatar"`
	Signature string `gorm:"column:signature;size:50"   json:"signature"`
	Cover     string `gorm:"column:cover"   json:"cover"`
}

type Visibility

type Visibility string
const (
	PublicVisibility  Visibility = "public"
	PrivateVisibility Visibility = "private"
)

type YouTuBeVideo

type YouTuBeVideo struct {
	VideoID string `json:"videoid" property:"videoid;视频ID"`
}

func (*YouTuBeVideo) GetDisplayName

func (*YouTuBeVideo) GetDisplayName() string

func (*YouTuBeVideo) GetMediaType

func (*YouTuBeVideo) GetMediaType() MediaType

func (*YouTuBeVideo) GetName

func (*YouTuBeVideo) GetName() string

func (*YouTuBeVideo) Html

func (y *YouTuBeVideo) Html(isMobile bool) string

func (*YouTuBeVideo) Init

func (y *YouTuBeVideo) Init(config map[string]string)

type YoukuVideo

type YoukuVideo struct {
	VideoID string `json:"videoid" property:"videoid;视频ID"`
}

func (*YoukuVideo) GetDisplayName

func (*YoukuVideo) GetDisplayName() string

func (*YoukuVideo) GetMediaType

func (*YoukuVideo) GetMediaType() MediaType

func (*YoukuVideo) GetName

func (*YoukuVideo) GetName() string

func (*YoukuVideo) Html

func (y *YoukuVideo) Html(isMobile bool) string

func (*YoukuVideo) Init

func (y *YoukuVideo) Init(config map[string]string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL