Ver código fonte

用数据库调度maxId

y595705120 1 ano atrás
pai
commit
8efeb219ef
1 arquivos alterados com 6 adições e 2 exclusões
  1. 6 2
      main.go

+ 6 - 2
main.go

@@ -44,12 +44,12 @@ func main() {
 }
 
 func loopMaxId(maxId int) int {
-	list, err := db.New("t_news").Attr("id,content,url").
-		Where("status", "Brief").WhereF("id > ?", 4000).Order("ORDER BY id asc").Limit(0, 100).GetAll()
+	list, err := db.New("t_news").Attr("id,content,url").WhereF("id > ?", maxId).Order("ORDER BY id asc").Limit(0, 100).GetAll()
 	fmt.Println("loopLen", len(list), err)
 	for _, record := range list {
 		update := map[string]interface{}{}
 		id := record["id"].(int64)
+		idInt := int(id)
 		content := record["content"].(string)
 		url := record["url"].(string)
 		brief := ""
@@ -69,6 +69,10 @@ func loopMaxId(maxId int) int {
 				}
 			}
 		}
+		// maxId更新
+		if maxId < idInt {
+			maxId = idInt
+		}
 		//
 		if brief == "" {
 			update["status"] = "Delete"