|
@@ -30,18 +30,21 @@ func Collect(r *GinRouter) {
|
|
return &model.Collect{}
|
|
return &model.Collect{}
|
|
},
|
|
},
|
|
JWT: true,
|
|
JWT: true,
|
|
- SearchFilter: func(c *gin.Context, apictx *ApiSession, query map[string]interface{}) map[string]interface{} {
|
|
|
|
|
|
+ SearchFilter: func(_ *gin.Context, apictx *ApiSession, query map[string]interface{}) map[string]interface{} {
|
|
_userId := apictx.User.ID
|
|
_userId := apictx.User.ID
|
|
userId, err := primitive.ObjectIDFromHex(_userId)
|
|
userId, err := primitive.ObjectIDFromHex(_userId)
|
|
if err != nil {
|
|
if err != nil {
|
|
|
|
+
|
|
// 6369f4b028c4bf8b14f47a6b
|
|
// 6369f4b028c4bf8b14f47a6b
|
|
invalidId, _ := primitive.ObjectIDFromHex("6369f4b028c4bf8b14f47a6b")
|
|
invalidId, _ := primitive.ObjectIDFromHex("6369f4b028c4bf8b14f47a6b")
|
|
- return repo.Map{"userId": invalidId}
|
|
|
|
|
|
+ query["userId"] = invalidId
|
|
|
|
+ return query
|
|
}
|
|
}
|
|
|
|
|
|
- return repo.Map{"userId": userId}
|
|
|
|
|
|
+ query["userId"] = userId
|
|
|
|
+ return query
|
|
},
|
|
},
|
|
- SearchPostProcess: func(page *repo.PageResult, c *gin.Context, apictx *ApiSession, query map[string]interface{}) (interface{}, error) {
|
|
|
|
|
|
+ SearchPostProcess: func(page *repo.PageResult, _ *gin.Context, apictx *ApiSession, _ map[string]interface{}) (interface{}, error) {
|
|
// 查询组装数据
|
|
// 查询组装数据
|
|
if len(page.List) > 0 {
|
|
if len(page.List) > 0 {
|
|
for _, v := range page.List {
|
|
for _, v := range page.List {
|
|
@@ -55,6 +58,7 @@ func Collect(r *GinRouter) {
|
|
Query: repo.Map{"_id": productId},
|
|
Query: repo.Map{"_id": productId},
|
|
Project: []string{"name", "unit", "cover"},
|
|
Project: []string{"name", "unit", "cover"},
|
|
}, &product)
|
|
}, &product)
|
|
|
|
+ // 供应商信息
|
|
repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
|
|
repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
|
|
CollectName: repo.CollectionSupply,
|
|
CollectName: repo.CollectionSupply,
|
|
Query: repo.Map{"_id": supplyId},
|
|
Query: repo.Map{"_id": supplyId},
|
|
@@ -64,6 +68,8 @@ func Collect(r *GinRouter) {
|
|
v["productUnit"] = product.Unit
|
|
v["productUnit"] = product.Unit
|
|
v["productCover"] = product.Cover
|
|
v["productCover"] = product.Cover
|
|
v["supplyName"] = supply.Name
|
|
v["supplyName"] = supply.Name
|
|
|
|
+ v["supplyAvatar"] = supply.Avatar
|
|
|
|
+ v["supplyContact"] = supply.Contact
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|