🎨change Photos string -> []string

This commit is contained in:
Havoc412 2024-10-23 01:33:34 +08:00
parent 0e96b3ca84
commit 4649b697f1
3 changed files with 12 additions and 7 deletions

View File

@ -30,6 +30,7 @@ type Encounter struct { // Encounter 或者称为 post指的就是 Human 单
AvatarHeight uint16 `json:"avatar_height,omitempty"` // 为了方便前端在加载图像前的骨架图 & 瀑布流展示。
AvatarWidth uint16 `json:"avatar_width,omitempty"`
Photos string `gorm:"type:varchar(100)" json:"photos,omitempty"` // 图片数组
PhotosSlice []string `gorm:"-" json:"photos_list,omitempty"` // TIP GORM 忽略
// POI
Latitude float64 `json:"latitude,omitempty"` // POI 位置相关
Longitude float64 `json:"longitude,omitempty"`

View File

@ -18,7 +18,7 @@ type EncounterList struct {
}
type EncounterDetail struct {
Encounter Encounter
Encounter Encounter `json:"encounter"`
UsersModel UsersModel `json:"user"`
Animals []Animal `json:"animals"`
}

View File

@ -34,8 +34,12 @@ func (e *EncounterCurd) Detail(id string) *model.EncounterDetail {
return nil
}
// 1.1 处理 Photos 为 []string同时忽略原本的 Photos 字段。
encounter.PhotosSlice = query_handler.StringToStringArray(encounter.Photos)
encounter.Photos = ""
// 2. user data
user, err := model.CreateUserFactory("").ShowByID(encounter.UsersModelId, "user_avatar", "user_name")
user, err := model.CreateUserFactory("").ShowByID(encounter.UsersModelId, "user_avatar", "user_name", "id")
if err != nil {
return nil
}
@ -43,7 +47,7 @@ func (e *EncounterCurd) Detail(id string) *model.EncounterDetail {
// 3. animals data
animals_id := query_handler.StringToint64Array(encounter.AnimalsId)
animals := model.CreateAnimalFactory("").ShowByIDs(animals_id, "avatar", "name")
animals := model.CreateAnimalFactory("").ShowByIDs(animals_id, "avatar", "name", "id")
_ = animals
// 4. 合并