Files
nysoure/server/model/activity.go

32 lines
749 B
Go

package model
import (
"gorm.io/gorm"
"time"
)
type ActivityType uint
const (
ActivityTypeUnknown ActivityType = iota
ActivityTypeNewResource
ActivityTypeUpdateResource
ActivityTypeNewComment
)
type Activity struct {
gorm.Model
UserID uint `gorm:"not null"`
Type ActivityType `gorm:"not null;index:idx_type_refid"`
RefID uint `gorm:"not null;index:idx_type_refid"`
}
type ActivityView struct {
ID uint `json:"id"`
Time time.Time `json:"time"`
Type ActivityType `json:"type"`
User UserView `json:"user"`
Comment *CommentWithResourceView `json:"comment,omitempty"`
Resource *ResourceView `json:"resource,omitempty"`
}