diff --git a/app/model/encounter.go b/app/model/encounter.go index 9791eb0..8f43cb8 100644 --- a/app/model/encounter.go +++ b/app/model/encounter.go @@ -53,7 +53,7 @@ func (e *Encounter) InsertDate(c *gin.Context) bool { } func (e *Encounter) Show(num, skip int) (temp []EncounterList) { - sql := `SELECT user_id, title, avatar, avatar_height, avatar_width, e.updated_at, + sql := `SELECT e.id, user_id, title, avatar, avatar_height, avatar_width, e.updated_at, user_name, user_avatar FROM encounters e JOIN tb_users u ON e.user_id = u.id LIMIT ? OFFSET ? ` diff --git a/app/model/encounter_result.go b/app/model/encounter_result.go index 8f51cb8..b35c1bb 100644 --- a/app/model/encounter_result.go +++ b/app/model/encounter_result.go @@ -4,12 +4,14 @@ import "time" // TIP 用这种方式绑定 GORM 的 Raw 就会比较有效了。 type EncounterList struct { - UserId int `form:"user_id" json:"user_id"` - Title string - Avatar string - AvatarHeight int `form:"avatar_height" json:"avatar_height"` - AvatarWidth int `form:"avatar_width" json:"avatar_width"` - UpdatedAt *time.Time `json:"updated_at,omitempty"` // TIP 设为 *time.Time,omitempty 和 autoUpdated 就都可以生效 + Id int `form:"id" json:"id"` + UserId int `form:"user_id" json:"user_id"` + Title string `form:"title" json:"title"` + Avatar string `form:"avatar" json:"url"` + AvatarHeight int `form:"avatar_height" json:"height"` + AvatarWidth int `form:"avatar_width" json:"width"` + UpdatedAt *time.Time `form:"updated_at" json:"time"` // TIP 设为 *time.Time,omitempty 和 autoUpdated 就都可以生效 - UserName string `form:"user_name" json:"user_name"` + UserName string `form:"user_name" json:"userName"` + UserAvatar string `form:"user_avatar" json:"userAvatar"` }