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) { res = new(bxbase.CommonRes) newData := make(map[string]interface{}) if in.UserId == "" { res.ErrCode = 1 res.ErrMsg = "用户未登录" return } if in.InKey == "" { res.ErrCode = 1 res.ErrMsg = "保存失败" return } log.Println("添加搜索列表:", in) in.NotKey = strings.Replace(in.NotKey, " ", ",", -1) in.Keywords = strings.Replace(in.Keywords, " ", ",", -1) in.AdditionalWords = strings.Replace(in.AdditionalWords, " ", ",", -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["creation_time"] = time.Now().Unix() newData["user_id"] = in.UserId newData["in_key"] = in.InKey newData["searchGroup"] = int(in.SearchGroup) newData["searchMode"] = int(in.SearchMode) newData["wordsMode"] = int(in.WordsMode) newData["additionalWords"] = in.AdditionalWords IC.Mgo.Save("search_condition", newData) return }