model

package
v0.0.0-...-9ee4844 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NewPost = iota
	NewComment
	NewCommentReply
)

Variables

This section is empty.

Functions

func DBMigrate

func DBMigrate(db *gorm.DB) *gorm.DB

DBMigrate will create and migrate the boards, and then make the some relationships if necessary

Types

type Board

type Board struct {
	gorm.Model
	Name       string `gorm:"unique;not null"`
	CategoryID uint   `gorm:"not null"`
	Category   Category
	CreatorID  *uint
	Creator    User
}

type BoardRepository

type BoardRepository interface {
	GetBoardsByCategoryID(categoryID, currentUserID uint) ([]view.BoardView, error)
	GetBoardsByUserID(userID uint) ([]view.BoardView, error)
	GetBoardByID(boardID, currentUserID uint) (view.BoardView, error)
	CreateBoard(board view.BoardCreate) error
}

type Category

type Category struct {
	gorm.Model
	Name   string `gorm:"unique;not null"`
	Boards []Board
}

type CategoryRepository

type CategoryRepository interface {
	GetAllCategories() ([]view.Category, error)
}

type Comment

type Comment struct {
	gorm.Model
	Content  []byte
	AuthorID uint
	Author   User
	ParentID uint
	PostID   uint
	Post     Post
}

type CommentRepository

type CommentRepository interface {
	CreateComment(comment view.CommentCreate) (uint, error)
	GetCommentsByPost(commentID, currentUserID uint) ([]view.CommentPreview, error)
	UpdateComment(post view.CommentUpdate) error
	GetCommentAuthorID(postID uint) (uint, error)
	DeleteComment(commentID uint) error
	GetCommentsByUser(currentUserID uint) ([]view.CommentPreview, error)
}

type File

type File struct {
	gorm.Model
	FileID   string `gorm:"not null"`
	Filename string `gorm:"not null"`
}

type FileRepository

type FileRepository interface {
	CreateFile(file view.File) error
	GetFile(fileID string) (view.File, error)
}

type Notification

type Notification struct {
	gorm.Model
	UserID  uint `gorm:"not null"`
	User    User
	PostID  uint
	Post    Post
	BoardID uint
	Board   Board
	Type    NotificationType `gorm:"not null"`
}

type NotificationRepository

type NotificationRepository interface {
	CreateNewPostNotifications(notificatioin view.NotificationCreate, currentUserID uint) error
	GetNotificationByUser(userID uint) ([]view.NotificationPreview, error)
	DeleteNotification(notificationID, currentUserID uint) error
	DeleteNotificationByPost(postID, currentUserID uint) error
}

type NotificationType

type NotificationType uint

func (NotificationType) String

func (n NotificationType) String() string

type Post

type Post struct {
	gorm.Model
	Title    string `gorm:"not null"`
	Content  []byte `gorm:"not null"`
	AuthorID uint   `gorm:"not null"`
	Author   User
	BoardID  uint `gorm:"not null"`
	Board    Board
	Comments []Comment `gorm:"ForeignKey:PostID"`
}

type PostRepository

type PostRepository interface {
	CreatePost(post view.PostCreate) (uint, error)
	GetAllPosts(currentUserID uint) ([]view.PostPreview, error)
	GetPostByID(postID, currentUserID uint) (view.PostView, error)
	GetPostsByBoard(boardID, currentUserID uint) ([]view.PostPreview, error)
	GetPostsBySusbcriptions(currentUserID uint) ([]view.PostPreview, error)
	GetPostsByUser(userID uint) ([]view.PostPreview, error)
	UpdatePost(post view.PostUpdate) error
	GetPostAuthorID(postID uint) (uint, error)
	DeletePost(postID uint) error
}

type Reaction

type Reaction struct {
	gorm.Model
	PostID    *uint
	CommentID *uint
	AuthorID  uint         `gorm:"not null"`
	Type      ReactionType `gorm:"not null"`
}

type ReactionRepository

type ReactionRepository interface {
	ReactionPost(reaction view.ReactionPost, authorID uint) error
	ReactionComment(reaction view.ReactionComment, authorID uint) error
}

type ReactionType

type ReactionType uint
const (
	Like ReactionType = iota + 1
	Dislike
)

type Role

type Role struct {
	gorm.Model
	Name string `gorm:"unique;not null"`
}

type Subscription

type Subscription struct {
	gorm.Model
	UserID  uint `gorm:"not null"`
	BoardID uint `gorm:"not null"`
}

type SubscriptionRepository

type SubscriptionRepository interface {
	Subscribe(boardID, currentUserID uint) error
	Unsubscribe(boardID, currentUserID uint) error
}

type User

type User struct {
	gorm.Model
	Username string `gorm:"unique;not null"`
	Avatar   string `gorm:"not null"`
	Login    string `gorm:"unique;not null"`
	Email    string `gorm:"unique;not null"`
	RoleID   uint
	Role     Role
}

type UserRepository

type UserRepository interface {
	RegisterUser(user view.UserCreate) error
	GetUser(id uint) (view.UserInfo, error)
	GetUserProfile(id uint) (view.UserProfile, error)
}

Jump to

Keyboard shortcuts

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