Documentation ¶
Index ¶
- Constants
- func AddActivityThumbUp(db *gorm.DB, activityID int64, userID int64) error
- func DeleteActivity(db *gorm.DB, execID int64, activityID int64) error
- func DeleteActivityComment(db *gorm.DB, execID int64, commentID int64) error
- func DeleteActivityThumbUp(db *gorm.DB, activityID int64, userID int64) error
- type Activity
- func CreateActivity(db *gorm.DB, userID int64, text string, media []MediumCapsule) (*Activity, error)
- func GetActivitiesAfter(db *gorm.DB, userID int64, activityID int64, count int64) ([]Activity, error)
- func GetActivitiesBefore(db *gorm.DB, userID int64, activityID int64, count int64) ([]Activity, error)
- func GetActivity(db *gorm.DB, activityID int64) (*Activity, error)
- type ActivityComment
- type ActivityMedium
- type ActivityThumbUp
- type MediumCapsule
- type MediumType
Constants ¶
View Source
const ( // MediumTypeImageURL 图片类型 url MediumTypeImageURL = 0 // MediumTypeVideoURL 视频类型 url MediumTypeVideoURL = 1 // MediumTypeGeo 地理位置 url MediumTypeGeo = 2 )
Variables ¶
This section is empty.
Functions ¶
func AddActivityThumbUp ¶
AddActivityThumbUp 动态点赞
func DeleteActivity ¶
DeleteActivity 删除动态
func DeleteActivityComment ¶
DeleteActivityComment 删除动态评论,只有动态主人和评论主人可以删除
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 为零值,则获取所有
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 MediumCapsule ¶
type MediumCapsule struct { Type MediumType `json:"type" validate:"required,gte=0"` Content string `json:"content" validate:"required"` }
type MediumType ¶
type MediumType int64
Click to show internal directories.
Click to hide internal directories.