🎨change Photos string -> []string
This commit is contained in:
parent
0e96b3ca84
commit
4649b697f1
@ -30,6 +30,7 @@ type Encounter struct { // Encounter 或者称为 post,指的就是 Human 单
|
|||||||
AvatarHeight uint16 `json:"avatar_height,omitempty"` // 为了方便前端在加载图像前的骨架图 & 瀑布流展示。
|
AvatarHeight uint16 `json:"avatar_height,omitempty"` // 为了方便前端在加载图像前的骨架图 & 瀑布流展示。
|
||||||
AvatarWidth uint16 `json:"avatar_width,omitempty"`
|
AvatarWidth uint16 `json:"avatar_width,omitempty"`
|
||||||
Photos string `gorm:"type:varchar(100)" json:"photos,omitempty"` // 图片数组
|
Photos string `gorm:"type:varchar(100)" json:"photos,omitempty"` // 图片数组
|
||||||
|
PhotosSlice []string `gorm:"-" json:"photos_list,omitempty"` // TIP GORM 忽略
|
||||||
// POI
|
// POI
|
||||||
Latitude float64 `json:"latitude,omitempty"` // POI 位置相关
|
Latitude float64 `json:"latitude,omitempty"` // POI 位置相关
|
||||||
Longitude float64 `json:"longitude,omitempty"`
|
Longitude float64 `json:"longitude,omitempty"`
|
||||||
|
@ -18,7 +18,7 @@ type EncounterList struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type EncounterDetail struct {
|
type EncounterDetail struct {
|
||||||
Encounter Encounter
|
Encounter Encounter `json:"encounter"`
|
||||||
UsersModel UsersModel `json:"user"`
|
UsersModel UsersModel `json:"user"`
|
||||||
Animals []Animal `json:"animals"`
|
Animals []Animal `json:"animals"`
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,12 @@ func (e *EncounterCurd) Detail(id string) *model.EncounterDetail {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 1.1 处理 Photos 为 []string,同时忽略原本的 Photos 字段。
|
||||||
|
encounter.PhotosSlice = query_handler.StringToStringArray(encounter.Photos)
|
||||||
|
encounter.Photos = ""
|
||||||
|
|
||||||
// 2. user data
|
// 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 {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -43,7 +47,7 @@ func (e *EncounterCurd) Detail(id string) *model.EncounterDetail {
|
|||||||
|
|
||||||
// 3. animals data
|
// 3. animals data
|
||||||
animals_id := query_handler.StringToint64Array(encounter.AnimalsId)
|
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
|
_ = animals
|
||||||
|
|
||||||
// 4. 合并
|
// 4. 合并
|
||||||
|
Loading…
x
Reference in New Issue
Block a user