1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- 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)
- // todo 待测试
- 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"] = in.SearchGroup
- newData["searchMode"] = in.SearchMode
- newData["wordsMode"] = in.WordsMode
- newData["additionalWords"] = in.AdditionalWords
- IC.Mgo.Save("search_condition", newData)
- return
- }
|