新增查看推文模块
This commit is contained in:
25
services/twitter_post_service.go
Normal file
25
services/twitter_post_service.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"go-account-register/models"
|
||||
"go-account-register/utils"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type TwitterPostService struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func InitTwitterPostService() *TwitterPostService {
|
||||
db := utils.GetDB()
|
||||
return &TwitterPostService{db: db}
|
||||
}
|
||||
|
||||
func (s *TwitterPostService) GetAll() []models.TwitterPost {
|
||||
var post []models.TwitterPost
|
||||
res := s.db.Model(&models.TwitterPost{}).Where(`status = ? `, 1)
|
||||
|
||||
res.Order("id DESC").Find(&post)
|
||||
return post
|
||||
}
|
||||
Reference in New Issue
Block a user