update api.go, config.yml, handler.go, middleware.go, repository.go

This commit is contained in:
redtea committed 2024-10-22 12:00:00 +03:00
1 parent 43505548f7
commit f99ac8ffb4
5 files changed
+415

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
package repository
import (
"esforum"
"gorm.io/gorm"
)
type Post interface {
CreatePost(title string, content string, thread int64) (*esforum.Post, error)
GetPost(id int64) (*esforum.Post, error)
DeletePost(id int64) error
GetPosts(start, limit int) []int64
FindPostsByThread(thread int64, start, limit int) []int64
GetPostsCount() int64
}
type Thread interface {
CreateThread(title string) (*esforum.Thread, error)
GetThread(id int64) (*esforum.Thread, error)
FindThread(title string) (*esforum.Thread, error)
DeleteThread(id int64) error
GetThreads(start, limit int) []int64
GetThreadsCount() int64
}
type Repository struct {
Post
Thread
}
func NewRepository(db *gorm.DB) *Repository {
return &Repository{
Post: NewPostSchema(db),
Thread: NewThreadSchema(db),
}
}