修正空列表
This commit is contained in:
		
							
								
								
									
										15
									
								
								bin/main.go
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								bin/main.go
									
									
									
									
									
								
							@@ -289,6 +289,19 @@ func main() {
 | 
			
		||||
			if len(text_ids) > 0 {
 | 
			
		||||
				conditions.WriteString(fmt.Sprintf(" WHERE id IN (%s)", strings.Trim(strings.Replace(fmt.Sprint(text_ids), " ", ",", -1), "[]")))
 | 
			
		||||
				fmt.Println("conditions", conditions.String())
 | 
			
		||||
			} else {
 | 
			
		||||
				// 直接返回空列表
 | 
			
		||||
				var images ListView
 | 
			
		||||
				images.Page, images.PageSize = stringToInt(r.URL.Query().Get("page"), 1), stringToInt(r.URL.Query().Get("pageSize"), 20)
 | 
			
		||||
				images.Total = 0
 | 
			
		||||
				images.Next = false
 | 
			
		||||
				images.List = make([]interface{}, 0)
 | 
			
		||||
 | 
			
		||||
				// 将对象转换为有缩进的JSON输出
 | 
			
		||||
				data, _ := json.MarshalIndent(images, "", "  ")
 | 
			
		||||
				w.Header().Set("Content-Type", "application/json; charset=UTF-8")
 | 
			
		||||
				w.Write(data)
 | 
			
		||||
				return
 | 
			
		||||
			}
 | 
			
		||||
			if conditions.Len() > 1024 {
 | 
			
		||||
				log.Println("查询条件过长")
 | 
			
		||||
@@ -353,6 +366,7 @@ func main() {
 | 
			
		||||
		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, &image.ArticleCategoryTopId, &image.PraiseCount, &image.CollectCount)
 | 
			
		||||
			fmt.Println("image", image.User.Id, image.Article.Id)
 | 
			
		||||
			image.UpdateTime = image.UpdateTime.UTC()
 | 
			
		||||
			image.CreateTime = image.CreateTime.UTC()
 | 
			
		||||
			image.Content = regexp.MustCompile(`http:`).ReplaceAllString(image.Content, "https:")
 | 
			
		||||
@@ -389,6 +403,7 @@ func main() {
 | 
			
		||||
		var user_ids []int
 | 
			
		||||
		var article_ids []int
 | 
			
		||||
		for _, image := range image_list {
 | 
			
		||||
			fmt.Println("image", image)
 | 
			
		||||
			user_ids = append(user_ids, image.User.Id)
 | 
			
		||||
			article_ids = append(article_ids, image.Article.Id)
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user