package logic import ( "app.yhyue.com/moapp/jybase/common" "context" "jyBXSubscribe/api/internal/svc" "jyBXSubscribe/api/internal/types" "jyBXSubscribe/rpc/type/bxsubscribe" "net/http" "strings" "github.com/zeromicro/go-zero/core/logx" ) type SubscribeListLogic struct { logx.Logger ctx context.Context svcCtx *svc.ServiceContext r *http.Request } func NewSubscribeListLogic(ctx context.Context, svcCtx *svc.ServiceContext, r *http.Request) *SubscribeListLogic { return &SubscribeListLogic{ Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx, r: r, } } func (l *SubscribeListLogic) SubscribeList(req *types.SubscribeReq) (resp *types.CommonResp, err error) { //关键词处理 //分类 matchitemsArr := []string{} matchitems := "" //关键词 matchkeysArr := []string{} matchkeys := "" if req.PositionType == 0 { for k, v := range req.Item { if common.InterfaceToStr(v) == "" { matchitemsArr = append(matchitemsArr, common.InterfaceToStr(v)) } else { matchkeysArr = append(matchkeysArr, common.InterfaceToStr(k)) } } if len(matchitemsArr) == 0 { matchkeys = strings.Join(matchkeysArr, ",") } else { matchitems = strings.Join(matchitemsArr, ",") } } else { matchkeys = req.KeyWords } res, err := l.svcCtx.Suscribe.GetSubList(l.ctx, &bxsubscribe.SubscribeInfosReq{ PageNum: req.PageNum, PageSize: req.PageSize, SelectTime: req.SelectTime, Area: req.Area, City: req.City, Industry: req.Industry, BuyerClass: req.BuyerClass, KeyWords: matchkeys, Subtype: req.Subtype, UserType: req.UserType, Price: req.Price, FileExists: req.FileExists, IsRead: req.IsRead, Source: req.Source, Staffs: req.Staffs, UserId: req.UserId, EntId: req.EntId, EntUserId: req.EntUserId, DeptId: req.DeptId, NewUserId: req.NewUserId, IsEnt: req.IsEnt, PositionType: req.PositionType, NotReturnCount: req.NotReturnCount, Item: matchitems, }) if err != nil { return &types.CommonResp{ Err_code: res.ErrCode, Err_msg: res.ErrMsg, Data: nil, }, nil } return &types.CommonResp{ Err_code: res.ErrCode, Err_msg: res.ErrMsg, Data: res.Data, }, nil }