add Encounter Level

This commit is contained in:
Havoc412 2024-10-23 02:08:36 +08:00
parent 4649b697f1
commit da2ecf2eba
4 changed files with 30 additions and 0 deletions

1
app/model/TODO.md Normal file
View File

@ -0,0 +1 @@
[ ] 之后 model 下的子文件还是再多增一层包的区分。

View File

@ -23,6 +23,7 @@ type Encounter struct { // Encounter 或者称为 post指的就是 Human 单
Title string `gorm:"size:20;column:title" json:"title"`
Content string `json:"content"`
Level uint8 `json:"level" gorm:"level;default:1"`
// Time 从 CreatedAt 中解析
// TAG Avatar 最好是压缩后的备份图像

View File

@ -0,0 +1,5 @@
package model
type EncounerLevel struct {
BriefModel
}

View File

@ -35,3 +35,26 @@ func TestEncounterLike(t *testing.T) {
t.Error(err)
}
}
func TestEncounterLevel(t *testing.T) {
Init()
encounterLevel := model.EncounerLevel{}
err := DB.AutoMigrate(&encounterLevel)
if err != nil {
t.Error(err)
}
ZH := []string{"日常", "重大", "标志", "代办", "日程"}
EN := []string{"daily", "serious", "flag", "todo", "schedule"}
for i := 0; i < len(ZH); i++ {
encounterLevel := model.EncounerLevel{
BriefModel: model.BriefModel{
NameZh: ZH[i],
NameEn: EN[i],
},
}
DB.Create(&encounterLevel)
}
}