image
This commit is contained in:
		
							
								
								
									
										23
									
								
								bin/main.go
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								bin/main.go
									
									
									
									
									
								
							@@ -53,14 +53,17 @@ type Article struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Image struct {
 | 
					type Image struct {
 | 
				
			||||||
	Id         int       `json:"id"`
 | 
						Id                   int       `json:"id"`
 | 
				
			||||||
	Width      int       `json:"width"`
 | 
						Width                int       `json:"width"`
 | 
				
			||||||
	Height     int       `json:"height"`
 | 
						Height               int       `json:"height"`
 | 
				
			||||||
	Content    string    `json:"content"`
 | 
						Content              string    `json:"content"`
 | 
				
			||||||
	CreateTime time.Time `json:"create_time"`
 | 
						ArticleCategoryTopId int       `json:"article_category_top_id"`
 | 
				
			||||||
	UpdateTime time.Time `json:"update_time"`
 | 
						PraiseCount          int       `json:"praise_count"`
 | 
				
			||||||
	User       User      `json:"user"`
 | 
						CollectCount         int       `json:"collect_count"`
 | 
				
			||||||
	Article    Article   `json:"article"`
 | 
						CreateTime           time.Time `json:"createTime"`
 | 
				
			||||||
 | 
						UpdateTime           time.Time `json:"updateTime"`
 | 
				
			||||||
 | 
						User                 User      `json:"user"`
 | 
				
			||||||
 | 
						Article              Article   `json:"article"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Tag struct {
 | 
					type Tag struct {
 | 
				
			||||||
@@ -248,7 +251,7 @@ func main() {
 | 
				
			|||||||
		var images ListView
 | 
							var images ListView
 | 
				
			||||||
		var image_list []Image
 | 
							var image_list []Image
 | 
				
			||||||
		images.Page, images.PageSize = stringToInt(r.URL.Query().Get("page"), 1), stringToInt(r.URL.Query().Get("pageSize"), 10)
 | 
							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 {
 | 
							if err != nil {
 | 
				
			||||||
			log.Println("获取图片列表失败", err)
 | 
								log.Println("获取图片列表失败", err)
 | 
				
			||||||
			http.Error(w, err.Error(), http.StatusBadRequest)
 | 
								http.Error(w, err.Error(), http.StatusBadRequest)
 | 
				
			||||||
@@ -257,7 +260,7 @@ func main() {
 | 
				
			|||||||
		defer rows.Close()
 | 
							defer rows.Close()
 | 
				
			||||||
		for rows.Next() {
 | 
							for rows.Next() {
 | 
				
			||||||
			var image Image
 | 
								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.UpdateTime = image.UpdateTime.UTC()
 | 
				
			||||||
			image.CreateTime = image.CreateTime.UTC()
 | 
								image.CreateTime = image.CreateTime.UTC()
 | 
				
			||||||
			image.Content = regexp.MustCompile(`http:`).ReplaceAllString(image.Content, "https:")
 | 
								image.Content = regexp.MustCompile(`http:`).ReplaceAllString(image.Content, "https:")
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user