123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- package logic
- import (
- "context"
- IC "jyBXBase/rpc/init"
- "log"
- "strings"
- "jyBXBase/rpc/bxbase"
- "jyBXBase/rpc/internal/svc"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type CheckSearchLogic struct {
- ctx context.Context
- svcCtx *svc.ServiceContext
- logx.Logger
- }
- func NewCheckSearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CheckSearchLogic {
- return &CheckSearchLogic{
- ctx: ctx,
- svcCtx: svcCtx,
- Logger: logx.WithContext(ctx),
- }
- }
- // 修改筛选列表
- func (l *CheckSearchLogic) CheckSearch(in *bxbase.AddSearchReq) (res *bxbase.CommonRes, err error) {
- // todo: add your logic here and delete this line
- res = new(bxbase.CommonRes)
- if in.UserId == "" {
- res.ErrCode = 1
- res.ErrMsg = "用户未登录"
- return
- }
- if in.Keywords == "" {
- res.ErrCode = 1
- res.ErrMsg = "请先输入关键词"
- return
- }
- log.Println("校验收藏列表:", in)
- in.NotKey = strings.Replace(in.NotKey, " ", ",", -1)
- in.Keywords = strings.Replace(in.Keywords, " ", ",", -1)
- query := map[string]interface{}{
- "user_id": in.UserId,
- }
- if IC.Mgo.Count("search_condition", query) >= 10 {
- res.ErrCode = 1
- res.ErrMsg = "对不起,最多可保存10个筛选条件。"
- return
- }
- query["keywords"] = in.Keywords
- query["type"] = in.Type
- query["publish_time"] = in.PublishTime
- query["area"] = in.Area
- query["city"] = in.City
- query["subtype"] = in.Subtype
- query["min_price"] = in.MinPrice
- query["max_price"] = in.MaxPrice
- query["industry"] = in.Industry
- query["select_type"] = in.SelectType
- query["buyer_class"] = in.BuyerClass
- query["buyer_tel"] = in.HasBuyerTel
- query["winner_tel"] = in.HasWinnerTel
- query["file_exists"] = in.FileExists
- query["not_key"] = in.NotKey
- query["tabular_flag"] = in.TabularFlag
- if IC.Mgo.Count("search_condition", query) > 0 {
- res.ErrCode = 1
- res.ErrMsg = "该条件已保存,无需重复添加。"
- }
- return
- }
|