update encounter List

This commit is contained in:
Havoc412 2024-10-21 00:24:48 +08:00
parent e1f169f793
commit 127ef0722b
2 changed files with 10 additions and 8 deletions

View File

@ -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 ?
`

View File

@ -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.Timeomitempty 和 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.Timeomitempty 和 autoUpdated 就都可以生效
UserName string `form:"user_name" json:"user_name"`
UserName string `form:"user_name" json:"userName"`
UserAvatar string `form:"user_avatar" json:"userAvatar"`
}