Browse Source

dockerFile

y595705120 1 year ago
parent
commit
6cc18ba9a6
3 changed files with 17 additions and 5 deletions
  1. 5 0
      Dockerfile
  2. 7 0
      db/query.go
  3. 5 5
      main.go

+ 5 - 0
Dockerfile

@@ -1,6 +1,11 @@
 
 FROM debian:buster-slim
 # Copy the binary to the production image from the builder stage.
+
+RUN set -x && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
+        ca-certificates && \
+        rm -rf /var/lib/apt/lists/*
+        
 WORKDIR /app
 
 COPY ./main /app/main

+ 7 - 0
db/query.go

@@ -71,6 +71,13 @@ func (sl *Query) Where(attr string, value interface{}) *Query {
 	return sl
 }
 
+func (sl *Query) WhereF(attr string, value ...interface{}) *Query {
+	sl.init_where()
+	sl.where += attr
+	sl.args = append(sl.args, value...)
+	return sl
+}
+
 func (sl *Query) Like(attr string, value interface{}) *Query {
 	sl.init_where()
 	sl.where += sl.quote + attr + sl.quote + " like ?"

+ 5 - 5
main.go

@@ -39,9 +39,9 @@ func main() {
 }
 
 func loopMaxId(maxId int) int {
-	// var list []model.TNew
-	list, _ := db.New("t_news").Attr("id,content,url").
-		Where("status=?", "Pending").Where("id>?", 4000).Order("ORDER BY id asc").Limit(0, 100).GetAll()
+	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()
+	fmt.Println("loopLen", len(list), err)
 	for _, record := range list {
 		update := map[string]interface{}{}
 		id := record["content"].(int)
@@ -66,9 +66,9 @@ func loopMaxId(maxId int) int {
 		}
 		//
 		if brief == "" {
-			update["status"] = "Deactivated"
+			update["status"] = "Delete"
 		} else {
-			update["status"] = "Activated"
+			update["status"] = "Picture"
 		}
 		fmt.Println("finish", id, brief)
 		if _, err := db.Pool().Update("t_news", update, map[string]interface{}{"id": id}); err != nil {