add color
This commit is contained in:
parent
da2ecf2eba
commit
4d3238e230
@ -8,6 +8,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
"gorm.io/plugin/soft_delete"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BaseModel struct {
|
type BaseModel struct {
|
||||||
@ -24,6 +25,16 @@ type BriefModel struct {
|
|||||||
NameEn string `json:"name_en"`
|
NameEn string `json:"name_en"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Color struct {
|
||||||
|
ColorFont string `json:"color_font" gorm:"type:char(10)"`
|
||||||
|
ColorBackground string `json:"color_background" gorm:"type:char(10)"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeletedAt struct {
|
||||||
|
DeletedAt *time.Time `json:"deleted_at" gorm:"defalt:NULL"`
|
||||||
|
IsDel soft_delete.DeletedAt `gorm:"softDelete:flag"`
|
||||||
|
}
|
||||||
|
|
||||||
func UseDbConn(sqlType string) *gorm.DB {
|
func UseDbConn(sqlType string) *gorm.DB {
|
||||||
var db *gorm.DB
|
var db *gorm.DB
|
||||||
sqlType = strings.Trim(sqlType, " ")
|
sqlType = strings.Trim(sqlType, " ")
|
||||||
|
@ -23,7 +23,7 @@ type Encounter struct { // Encounter 或者称为 post,指的就是 Human 单
|
|||||||
|
|
||||||
Title string `gorm:"size:20;column:title" json:"title"`
|
Title string `gorm:"size:20;column:title" json:"title"`
|
||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
Level uint8 `json:"level" gorm:"level;default:1"`
|
Level uint8 `json:"level" gorm:"column:level;default:1"`
|
||||||
// Time 从 CreatedAt 中解析
|
// Time 从 CreatedAt 中解析
|
||||||
|
|
||||||
// TAG Avatar 最好是压缩后的备份图像
|
// TAG Avatar 最好是压缩后的备份图像
|
||||||
|
@ -2,4 +2,5 @@ package model
|
|||||||
|
|
||||||
type EncounerLevel struct {
|
type EncounerLevel struct {
|
||||||
BriefModel
|
BriefModel
|
||||||
|
Color
|
||||||
}
|
}
|
||||||
|
@ -6,4 +6,5 @@ type EncounterLike struct {
|
|||||||
UsersModel UsersModel
|
UsersModel UsersModel
|
||||||
EncounterId int `gorm:"column:encounter_id" json:"encounter_id"`
|
EncounterId int `gorm:"column:encounter_id" json:"encounter_id"`
|
||||||
Encounter Encounter
|
Encounter Encounter
|
||||||
|
DeletedAt
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,8 @@ func TestEncounterLevel(t *testing.T) {
|
|||||||
|
|
||||||
ZH := []string{"日常", "重大", "标志", "代办", "日程"}
|
ZH := []string{"日常", "重大", "标志", "代办", "日程"}
|
||||||
EN := []string{"daily", "serious", "flag", "todo", "schedule"}
|
EN := []string{"daily", "serious", "flag", "todo", "schedule"}
|
||||||
|
colorbg := []string{"#F0F0F0", "#FFD700", "#FF69B4", "#87CEFA", "#32CD32"}
|
||||||
|
colorfont := []string{"#333333", "#000000", "#FFFFFF", "#000000", "#FFFFFF"}
|
||||||
|
|
||||||
for i := 0; i < len(ZH); i++ {
|
for i := 0; i < len(ZH); i++ {
|
||||||
encounterLevel := model.EncounerLevel{
|
encounterLevel := model.EncounerLevel{
|
||||||
@ -54,6 +56,10 @@ func TestEncounterLevel(t *testing.T) {
|
|||||||
NameZh: ZH[i],
|
NameZh: ZH[i],
|
||||||
NameEn: EN[i],
|
NameEn: EN[i],
|
||||||
},
|
},
|
||||||
|
Color: model.Color{
|
||||||
|
ColorBackground: colorbg[i],
|
||||||
|
ColorFont: colorfont[i],
|
||||||
|
},
|
||||||
}
|
}
|
||||||
DB.Create(&encounterLevel)
|
DB.Create(&encounterLevel)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user