From f0fca2291c36931d7bd621c40fd9ae1bdcdc798a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=9C=E8=8F=AF?= Date: Thu, 13 Apr 2023 03:58:46 +0800 Subject: [PATCH] image --- bin/main.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/bin/main.go b/bin/main.go index 4905768..92c26a8 100644 --- a/bin/main.go +++ b/bin/main.go @@ -53,14 +53,17 @@ type Article struct { } type Image struct { - Id int `json:"id"` - Width int `json:"width"` - Height int `json:"height"` - Content string `json:"content"` - CreateTime time.Time `json:"create_time"` - UpdateTime time.Time `json:"update_time"` - User User `json:"user"` - Article Article `json:"article"` + Id int `json:"id"` + Width int `json:"width"` + Height int `json:"height"` + Content string `json:"content"` + ArticleCategoryTopId int `json:"article_category_top_id"` + PraiseCount int `json:"praise_count"` + CollectCount int `json:"collect_count"` + CreateTime time.Time `json:"createTime"` + UpdateTime time.Time `json:"updateTime"` + User User `json:"user"` + Article Article `json:"article"` } type Tag struct { @@ -248,7 +251,7 @@ func main() { var images ListView var image_list []Image images.Page, images.PageSize = stringToInt(r.URL.Query().Get("page"), 1), stringToInt(r.URL.Query().Get("pageSize"), 10) - rows, err := mysqlConnection.Database.Query("SELECT id, width, height, content, update_time, create_time, user_id, article_id FROM web_images"+conditions+" LIMIT ?, ?", (images.Page-1)*images.PageSize, images.PageSize) + rows, err := mysqlConnection.Database.Query("SELECT id, width, height, content, update_time, create_time, user_id, article_id, article_category_top_id, praise_count, collect_count FROM web_images"+conditions+" LIMIT ?, ?", (images.Page-1)*images.PageSize, images.PageSize) if err != nil { log.Println("获取图片列表失败", err) http.Error(w, err.Error(), http.StatusBadRequest) @@ -257,7 +260,7 @@ func main() { defer rows.Close() for rows.Next() { var image Image - rows.Scan(&image.Id, &image.Width, &image.Height, &image.Content, &image.UpdateTime, &image.CreateTime, &image.User.Id, &image.Article.Id) + rows.Scan(&image.Id, &image.Width, &image.Height, &image.Content, &image.UpdateTime, &image.CreateTime, &image.User.Id, &image.Article.Id, &image.ArticleCategoryTopId, &image.PraiseCount, &image.CollectCount) image.UpdateTime = image.UpdateTime.UTC() image.CreateTime = image.CreateTime.UTC() image.Content = regexp.MustCompile(`http:`).ReplaceAllString(image.Content, "https:")