瀏覽代碼

同步数据库isAck,设置默认值为false

animeic 1 年之前
父節點
當前提交
bf7d21531c
共有 2 個文件被更改,包括 50 次插入25 次删除
  1. 50 23
      boxcost/api/print.go
  2. 0 2
      boxcost/api/router.go

+ 50 - 23
boxcost/api/print.go

@@ -1,39 +1,66 @@
 package api
 
 import (
+	"box-cost/db/model"
+	"box-cost/db/repo"
 	"fmt"
-	"sync"
-	"time"
 
 	"github.com/gin-gonic/gin"
 )
 
 func Printr(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-	c1 := make(chan int)
-	var wg sync.WaitGroup
+	// products := []*model.ProductBill{}
+	// repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
+	// 	CollectName: repo.CollectionBillProduct,
+	// 	Query:       repo.Map{"isAck": nil},
+	// 	Project:     []string{"isAck"},
+	// }, &products)
 
-	for i := 0; i < 3; i++ {
-		wg.Add(1)
-		go work(&wg, c1, i)
-	}
+	// for _, product := range products {
+	// 	fmt.Println(product.Id.Hex())
+	// 	fmt.Println(product.IsAck)
+	// 	notAck := false
+	// 	repo.RepoUpdateSetDocsProps(apictx.CreateRepoCtx(), &repo.DocFilterOptions{
+	// 		CollectName: repo.CollectionBillProduct,
+	// 		Query:       repo.Map{"isAck": nil},
+	// 	}, &model.ProductBill{IsAck: &notAck})
+	// }
+	// return products, nil
 
-	go func() {
-		wg.Wait()
-		close(c1)
-	}()
+	// produces := []*model.ProduceBill{}
+	// repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
+	// 	CollectName: repo.CollectionBillProduce,
+	// 	Query:       repo.Map{"isAck": nil},
+	// 	Project:     []string{"isAck"},
+	// }, &produces)
 
-	for n := range c1 {
-		fmt.Println(n)
-	}
+	// for _, produce := range produces {
+	// 	fmt.Println(produce.Id.Hex())
+	// 	fmt.Println(produce.IsAck)
+	// 	notAck := false
+	// 	repo.RepoUpdateSetDocsProps(apictx.CreateRepoCtx(), &repo.DocFilterOptions{
+	// 		CollectName: repo.CollectionBillProduce,
+	// 		Query:       repo.Map{"isAck": nil},
+	// 	}, &model.ProduceBill{IsAck: &notAck})
+	// }
+	// return produces, nil
 
-	return nil, nil
+	purchases := []*model.PurchaseBill{}
+	repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
+		CollectName: repo.CollectionBillPurchase,
+		Query:       repo.Map{"isAck": nil},
+		Project:     []string{"isAck"},
+	}, &purchases)
 
-}
-
-func work(wg *sync.WaitGroup, c1 chan<- int, n int) {
-	if n == 1 {
-		time.Sleep(1 * time.Second)
+	for _, purchase := range purchases {
+		fmt.Println(purchase.Id.Hex())
+		fmt.Println(purchase.IsAck)
+		notAck := false
+		repo.RepoUpdateSetDocsProps(apictx.CreateRepoCtx(), &repo.DocFilterOptions{
+			CollectName: repo.CollectionBillPurchase,
+			Query:       repo.Map{"isAck": nil},
+		}, &model.PurchaseBill{IsAck: &notAck})
 	}
-	c1 <- n
-	wg.Done()
+	return purchases, nil
+
 }

+ 0 - 2
boxcost/api/router.go

@@ -16,8 +16,6 @@ func RegRouters(svc *Service) {
 	//数据存储
 	boxcost.POST("/save/policy", ServiceObsUploadPolicy)
 	boxcost.GET("/printr", Printr)
-	// boxcost.GET("/genData", GenData)
-	// boxcost.GET("/searchData", SearchData)
 
 	// 材料管理
 	Material(boxcost)