package logic import ( "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXBase/rpc/bxbase" IC "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXBase/rpc/init" "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXBase/rpc/util" "context" "log" "strings" "time" "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/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.Keywords = strings.Replace(in.Keywords, " ", ",", -1) switch in.SearchGroup { case util.SearchGroupBidding: if ValueSort(util.TopTypesBidding) == in.Subtype { in.Subtype = "" } case util.SearchGroupLeadingProject: if ValueSort(util.TopTypesLeadingProject) == in.Subtype { in.Subtype = "" } case util.SearchGroupAnnouncementProject: if in.Subtype == "" { in.Subtype = "招标公告" } case util.SearchGroupForetellProject: if in.Subtype == "" { in.Subtype = "招标预告" } case util.SearchGroupResultProject: if in.Subtype == "" { in.Subtype = "招标结果" } } newData["keywords"] = in.Keywords newData["type"] = in.Type newData["publish_time"] = in.PublishTime newData["area"] = in.Area newData["city"] = in.City newData["buyer"] = in.Buyer newData["winner"] = in.Winner newData["agency"] = in.Agency 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"] = in.SearchGroup newData["searchMode"] = in.SearchMode newData["wordsMode"] = in.WordsMode newData["additionalWords"] = in.AdditionalWords region := map[string]map[string][]string{} if in.RegionMap != nil { for k, v := range in.RegionMap { areaMap := map[string][]string{} for k1, v1 := range v.Area { areaMap[k1] = v1.District } region[k] = areaMap } } newData["regionMap"] = region if in.BidField != "" { newData["bidField"] = in.BidField } IC.Mgo.Save("search_condition", newData) return }