LittleSheep ab0a87106b Read news basis
 Able to read wordpress site

btw the 10 yrs ago package still work properly, amazing...
means the wordpress api did not change a lot and the golang backward
compability is amazing!
2025-01-25 22:05:38 +08:00

33 lines
649 B
Go

package models
import (
"crypto/md5"
"encoding/hex"
"git.solsynth.dev/hypernet/nexus/pkg/nex/cruda"
"github.com/google/uuid"
)
type NewsArticle struct {
cruda.BaseModel
Thumbnail string `json:"thumbnail"`
Title string `json:"title"`
Description string `json:"description"`
Content string `json:"content"`
URL string `json:"url"`
Hash string `json:"hash" gorm:"uniqueIndex"`
Source string `json:"source"`
}
func (v *NewsArticle) GenHash() *NewsArticle {
if len(v.URL) == 0 {
v.Hash = uuid.NewString()
return v
}
hash := md5.Sum([]byte(v.URL))
v.Hash = hex.EncodeToString(hash[:])
return v
}