美化排版前端管理后台
This commit is contained in:
@@ -2,6 +2,7 @@ package storage
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
@@ -9,6 +10,28 @@ import (
|
||||
"mengyastore-backend/internal/database"
|
||||
)
|
||||
|
||||
type Announcement struct {
|
||||
Content string `json:"content"`
|
||||
Version string `json:"version"`
|
||||
}
|
||||
|
||||
func (s *SiteStore) GetAnnouncement() (Announcement, error) {
|
||||
content, err := s.get("announcementContent")
|
||||
if err != nil {
|
||||
return Announcement{}, err
|
||||
}
|
||||
version, _ := s.get("announcementVersion")
|
||||
return Announcement{Content: content, Version: version}, nil
|
||||
}
|
||||
|
||||
func (s *SiteStore) SetAnnouncement(content string) error {
|
||||
version := strconv.FormatInt(time.Now().UnixMilli(), 10)
|
||||
if err := s.set("announcementContent", content); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.set("announcementVersion", version)
|
||||
}
|
||||
|
||||
type SiteStore struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user