activity

package
v0.0.0-...-73ddb9c Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MediumTypeImageURL 图片类型 url
	MediumTypeImageURL = 0
	// MediumTypeVideoURL 视频类型 url
	MediumTypeVideoURL = 1
	// MediumTypeGeo 地理位置 url
	MediumTypeGeo = 2
)

Variables

This section is empty.

Functions

func AddActivityThumbUp

func AddActivityThumbUp(db *gorm.DB, activityID int64, userID int64) error

AddActivityThumbUp 动态点赞

func DeleteActivity

func DeleteActivity(db *gorm.DB, execID int64, activityID int64) error

DeleteActivity 删除动态

func DeleteActivityComment

func DeleteActivityComment(db *gorm.DB, execID int64, commentID int64) error

DeleteActivityComment 删除动态评论,只有动态主人和评论主人可以删除

func DeleteActivityThumbUp

func DeleteActivityThumbUp(db *gorm.DB, activityID int64, userID int64) error

DeleteActivityThumbUp 取消动态点赞

Types

type Activity

type Activity struct {
	ID       int64  `gorm:"primarykey" json:"id"`
	Text     string `gorm:"type:text not null" json:"text"`
	SenderID int64  `json:"sender_id"`

	Media    []ActivityMedium  `gorm:"foreignKey:ActivityID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE" json:"media"`
	Comments []ActivityComment `gorm:"foreignKey:ActivityID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE" json:"comments"`
	// ThumbUps 点赞者
	ThumbUps []ActivityThumbUp `gorm:"foreignKey:ActivityID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE" json:"thumb_ups"`
	Sender   user.User         `gorm:"foreignKey:SenderID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE" json:"-"`

	CreatedAt time.Time             `json:"created_at"`
	UpdatedAt time.Time             `json:"-"`
	DeletedAt soft_delete.DeletedAt `gorm:"index" json:"deleted_at"`
}

func CreateActivity

func CreateActivity(db *gorm.DB, userID int64, text string, media []MediumCapsule) (*Activity, error)

CreateActivity 创建新动态,media 可以为 nil

func GetActivitiesAfter

func GetActivitiesAfter(db *gorm.DB, userID int64, activityID int64, count int64) ([]Activity, error)

GetActivitiesAfter 获得某个用户能够接受到的,在某个 ID 之后的所有动态,如果 count 为零值,则获取所有

func GetActivitiesBefore

func GetActivitiesBefore(db *gorm.DB, userID int64, activityID int64, count int64) ([]Activity, error)

GetActivitiesBefore 获得某个用户能够接受到的,在某个 startID 之前的所有动态,如果 count 为零值,则获取所有

func GetActivity

func GetActivity(db *gorm.DB, activityID int64) (*Activity, error)

GetActivity 获得动态,并且 preload 评论和 media

type ActivityComment

type ActivityComment struct {
	ID          int64  `gorm:"primarykey" json:"id"`
	ActivityID  int64  `json:"activity_id"`
	CommenterID int64  `json:"commenter_id"`
	Content     string `gorm:"type:text not null" json:"content"`

	Commenter user.User `gorm:"foreignKey:CommenterID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE" json:"-"`

	CreatedAt time.Time             `json:"created_at"`
	UpdatedAt time.Time             `json:"-"`
	DeletedAt soft_delete.DeletedAt `gorm:"index" json:"deleted_at"`
}

func CreateActivityComment

func CreateActivityComment(db *gorm.DB, userID int64, content string, activityID int64) (*ActivityComment, error)

CreateActivityComment 创建新的动态评论

func GetActivityCommentByID

func GetActivityCommentByID(db *gorm.DB, commentID int64) (*ActivityComment, error)

GetActivityCommentByID 根据 id 获得动态

func GetActivityComments

func GetActivityComments(db *gorm.DB, activityID int64) ([]ActivityComment, error)

GetActivityComments 获得动态的所有评论,至少返回一个空数组

type ActivityMedium

type ActivityMedium struct {
	ID         int64      `gorm:"primarykey" json:"id"`
	ActivityID int64      `json:"activity_id"`
	Type       MediumType `gorm:"type:smallint not null" json:"type"`
	Content    string     `gorm:"type:text not null" json:"content"`

	CreatedAt time.Time             `json:"created_at"`
	UpdatedAt time.Time             `json:"-"`
	DeletedAt soft_delete.DeletedAt `gorm:"index" json:"deleted_at"`
}

type ActivityThumbUp

type ActivityThumbUp struct {
	ActivityID int64      `gorm:"primaryKey" json:"activity_id"`
	UserID     int64      `gorm:"primaryKey" json:"user_id"`
	User       *user.User `gorm:"foreignKey:UserID" json:"-"`
}

type MediumCapsule

type MediumCapsule struct {
	Type    MediumType `json:"type" validate:"required,gte=0"`
	Content string     `json:"content" validate:"required"`
}

type MediumType

type MediumType int64

Jump to

Keyboard shortcuts

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