fix(internal): 删除cateage部分,修复repo和service部分

This commit is contained in:
2025-11-17 18:08:42 +08:00
parent 5bb025c1aa
commit 907befeb55
11 changed files with 57 additions and 95 deletions

View File

@@ -1,16 +0,0 @@
package model
import (
"time"
)
type Cateage struct {
ID uint `gorm:"primaryKey" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `gorm:"index" json:"-"`
AnchorId string `gorm:"size:100;not null;unique" json:"anchor_id"`
Name string `gorm:"size:100;not null;unique" json:"name"`
Sites []Site `gorm:"foreignKey:CateageID" json:"sites"` // 方便获取分类下所有网站
}

View File

@@ -8,7 +8,7 @@ import (
func Init() {
err := db.GetDB().AutoMigrate(
new(User), new(Cateage), new(Site),
new(User),
)
if err != nil {
logger.Error("database migrate error", zap.Stack("migrate"))

View File

@@ -1,18 +0,0 @@
package model
import "time"
type Site struct {
ID uint `gorm:"primaryKey" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `gorm:"index" json:"-"`
Name string `gorm:"size:100;not null;unique" json:"name"`
Describe string `gorm:"size:100" json:"describe"`
CateageID uint `gorm:"not null;index" json:"cateage_id"`
Cateage Cateage `gorm:"foreignKey:CateageID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"cateage"` // 外键关联
Url string `gorm:"size:500;not null" json:"url"`
Cors bool `gorm:"default:false" json:"cors"`
Icon string `gorm:"size:500;default:'https://cos.kmux.cn/md/20251115174627218.png'" json:"icon"`
}