image
This commit is contained in:
		
							
								
								
									
										23
									
								
								bin/main.go
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								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:")
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user