package logic import ( "app.yhyue.com/moapp/jybase/common" "context" "jyBXBase/rpc/bxbase" IC "jyBXBase/rpc/init" "jyBXBase/rpc/internal/svc" "log" "github.com/zeromicro/go-zero/core/logx" ) type ShowSearchLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } func NewShowSearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowSearchLogic { return &ShowSearchLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } // 获取收藏列表 func (l *ShowSearchLogic) ShowSearch(in *bxbase.ShowSearchReq) (res *bxbase.ShowSearchRes, err error) { // todo: add your logic here and delete this line var ( data []*bxbase.ListSearchRes ) log.Println("获取搜索列表:", in) res = new(bxbase.ShowSearchRes) if in.UserId == "" { res.ErrCode = 1 res.ErrMsg = "用户未登录" return res, nil } query := map[string]interface{}{ "user_id": in.UserId, "type": in.Type, } allSearch, b := IC.Mgo.Find("search_condition", query, `{"creation_time":-1}`, "", false, -1, -1) if !b { res.ErrCode = 1 res.ErrMsg = "用户搜索信息查询失败" return res, nil } if allSearch != nil { for _, vlu := range *allSearch { var listSearch bxbase.ListSearchRes listSearch.Id = common.InterfaceToStr(vlu["_id"]) listSearch.Searchvalue = common.InterfaceToStr(vlu["keywords"]) listSearch.Publishtime = common.InterfaceToStr(vlu["publish_time"]) listSearch.Area = common.InterfaceToStr(vlu["area"]) listSearch.City = common.InterfaceToStr(vlu["city"]) listSearch.Subtype = common.InterfaceToStr(vlu["subtype"]) listSearch.Minprice = common.InterfaceToStr(vlu["min_price"]) listSearch.Maxprice = common.InterfaceToStr(vlu["max_price"]) listSearch.Industry = common.InterfaceToStr(vlu["industry"]) listSearch.SelectType = common.InterfaceToStr(vlu["select_type"]) listSearch.Buyerclass = common.InterfaceToStr(vlu["buyer_class"]) listSearch.Buyertel = common.InterfaceToStr(vlu["buyer_tel"]) listSearch.Winnertel = common.InterfaceToStr(vlu["winner_tel"]) listSearch.FileExists = common.InterfaceToStr(vlu["file_exists"]) listSearch.Notkey = common.InterfaceToStr(vlu["not_key"]) listSearch.Tabularflag = common.InterfaceToStr(vlu["tabular_flag"]) //ppa,buyer,winner,agency if (listSearch.SelectType != "title,content" && listSearch.SelectType != "title" && listSearch.SelectType != "content" && listSearch.SelectType != "content,title") || (listSearch.Publishtime != "lately-7" && listSearch.Publishtime != "lately-30" && listSearch.Publishtime != "thisyear") || listSearch.City != "" || listSearch.Notkey != "" || listSearch.Winnertel != "" || listSearch.Buyertel != "" || listSearch.Buyerclass != "" { listSearch.IsPay = true } data = append(data, &listSearch) } } res.Data = data return res, nil }