package logic import ( "context" "jyBXBase/rpc/bxbase" IC "jyBXBase/rpc/init" "log" "strings" "time" "jyBXBase/rpc/internal/svc" "github.com/zeromicro/go-zero/core/logx" ) type AddSearchLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } func NewAddSearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddSearchLogic { return &AddSearchLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } // 添加搜索列表 func (l *AddSearchLogic) AddSearch(in *bxbase.AddSearchReq) (res *bxbase.CommonRes, err error) { // todo: add your logic here and delete this line res = new(bxbase.CommonRes) newData := make(map[string]interface{}) if in.UserId == "" { res.ErrCode = 1 res.ErrMsg = "用户未登录" return } log.Println("添加搜索列表:", in) in.NotKey = strings.Replace(in.NotKey, " ", ",", -1) in.Keywords = strings.Replace(in.Keywords, " ", ",", -1) newData["keywords"] = in.Keywords newData["type"] = in.Type newData["publish_time"] = in.PublishTime newData["area"] = in.Area newData["city"] = in.City newData["subtype"] = in.Subtype newData["min_price"] = in.MinPrice newData["max_price"] = in.MaxPrice newData["industry"] = in.Industry newData["select_type"] = in.SelectType newData["buyer_class"] = in.BuyerClass newData["buyer_tel"] = in.HasBuyerTel newData["winner_tel"] = in.HasWinnerTel newData["file_exists"] = in.FileExists newData["not_key"] = in.NotKey newData["tabular_flag"] = in.TabularFlag newData["creation_time"] = time.Now().Unix() newData["user_id"] = in.UserId IC.Mgo.Save("search_condition", newData) return }