|
@@ -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: ¬Ack})
|
|
|
+ // }
|
|
|
+ // 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: ¬Ack})
|
|
|
+ // }
|
|
|
+ // 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: ¬Ack})
|
|
|
}
|
|
|
- c1 <- n
|
|
|
- wg.Done()
|
|
|
+ return purchases, nil
|
|
|
+
|
|
|
}
|