|
@@ -8,6 +8,7 @@ import (
|
|
|
"time"
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
+ "go.mongodb.org/mongo-driver/bson"
|
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
|
)
|
|
|
|
|
@@ -28,6 +29,18 @@ func Product(r *GinRouter) {
|
|
|
EmtyModel: func(c *gin.Context, apictx *ApiSession) interface{} {
|
|
|
return &model.Product{}
|
|
|
},
|
|
|
+ SearchFilter: func(c *gin.Context, apictx *ApiSession, query map[string]interface{}) map[string]interface{} {
|
|
|
+ if _name, ok := query["name"]; ok {
|
|
|
+ delete(query, "name")
|
|
|
+ query["name"] = bson.M{"$regex": _name.(string)}
|
|
|
+ }
|
|
|
+ if _norm, ok := query["norm"]; ok {
|
|
|
+ delete(query, "norm")
|
|
|
+ query["name"] = bson.M{"$regex": _norm.(string)}
|
|
|
+ }
|
|
|
+
|
|
|
+ return query
|
|
|
+ },
|
|
|
|
|
|
JWT: true,
|
|
|
OnUpdate: func(c *gin.Context, apictx *ApiSession, entity interface{}) {
|