diff-logs.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package api
  2. import (
  3. "box-cost/db/repo"
  4. "errors"
  5. "github.com/gin-gonic/gin"
  6. "go.mongodb.org/mongo-driver/bson"
  7. )
  8. func PrintDiff(c *gin.Context, apictx *ApiSession) (interface{}, error) {
  9. // id := c.Query("id")
  10. // CollectionMaterial = "material"
  11. // CollectionCraft = "craft"
  12. // CollectionProduct = "product"
  13. // CollectionSupplier = "supplier"
  14. // CollectionSupplierPrice = "supplier-price"
  15. // CollectionPack = "pack"
  16. // CollectionProductPlan = "product-plan" // 计划
  17. // CollectionBillPurchase = "bill-purchase" // 材料采购单
  18. // CollectionBillProduce = "bill-produce" // 工艺采购单
  19. // CollectionBillProduct = "bill-product" // 成品采购单
  20. // CollectionSupplierMatprice = "supplier-mats"
  21. // CollectionSupplierCraftprice = "supplier-crafts"
  22. // CollectionSupplierProductprice = "supplier-product" // 成品采购
  23. // CollectionIncrement = "increment"
  24. // CollectionSignature = "signature"
  25. // CollectionUsers = "users"
  26. // // 更改日志记录
  27. // CollectionLogs = "logs"
  28. // CollectionRequestLogs = "request-logs"
  29. // CollectionPlanTrack = "plan-track"
  30. // ?query={"targetId":"","collection":""}
  31. page, size, query := UtilQueryPageSize(c)
  32. if _, ok := query["targetId"]; !ok {
  33. return errors.New("目标id不能为空"), nil
  34. }
  35. if _, ok := query["collection"]; !ok {
  36. return errors.New("目标类型不能为空"), nil
  37. }
  38. return repo.RepoPageSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
  39. CollectName: repo.CollectionLogs,
  40. Query: query,
  41. Page: page,
  42. Size: size,
  43. Sort: bson.M{"createTime": -1},
  44. })
  45. }