123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- package logic
- import (
- "context"
- "fmt"
- "log"
- IC "jyBXSubscribe/rpc/init"
- "jyBXSubscribe/rpc/internal/svc"
- "jyBXSubscribe/rpc/model/service"
- "jyBXSubscribe/rpc/type/bxsubscribe"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type UpdateSubScribeInfoLogic struct {
- ctx context.Context
- svcCtx *svc.ServiceContext
- logx.Logger
- }
- func NewUpdateSubScribeInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateSubScribeInfoLogic {
- return &UpdateSubScribeInfoLogic{
- ctx: ctx,
- svcCtx: svcCtx,
- Logger: logx.WithContext(ctx),
- }
- }
- // 修改订阅信息接口
- func (l *UpdateSubScribeInfoLogic) UpdateSubScribeInfo(in *bxsubscribe.UpdateSubScribeInfoReq) (*bxsubscribe.StatusResp, error) {
- // todo: add your logic here and delete this line
- resp := &bxsubscribe.StatusResp{}
- subService := &service.SubseribeService{
- UserId: in.UserId,
- }
- log.Println("@@@@@@@@@", in.Area == nil, in.Area)
- if in.Area != nil {
- //格式转换 地区
- areaMap := map[string]interface{}{}
- for k, v := range in.Area {
- areaMap[k] = v.City
- }
- subService.Area = areaMap
- }
- //关键词转换
- if in.Items != nil {
- items := []map[string]interface{}{}
- item := map[string]interface{}{}
- for _, v := range in.Items {
- item["s_item"] = v.SItem
- item["updatetime"] = v.UpdateTime
- akey := []map[string]interface{}{}
- for _, vv := range v.AKey {
- akey = append(akey, map[string]interface{}{
- "key": vv.Key,
- "matchway": vv.Matchway,
- "appendkey": vv.AppendKey,
- "notkey": vv.Notkey,
- })
- }
- item["a_key"] = akey
- items = append(items)
- }
- subService.Items = items
- }
- //
- if in.Apppush != "" {
- subService.Apppush = in.Apppush
- }
- if in.Buyerclass != nil {
- subService.Buyerclass = in.Buyerclass
- }
- if in.Infotype != nil {
- subService.Infotype = in.Infotype
- }
- if in.Mail != "" {
- subService.Mail = in.Mail
- }
- if in.Mailpush != "" {
- subService.Mailpush = in.Mailpush
- }
- if in.Matchway != "" {
- subService.Matchway = in.Matchway
- }
- if in.Ratemode != "" {
- subService.Ratemode = in.Ratemode
- }
- if in.Projectmatch != "" {
- subService.Projectmatch = in.Projectmatch
- }
- if in.Otherbuyerclass != "" {
- subService.Otherbuyerclass = in.Otherbuyerclass
- }
- subService.Mgo = IC.Mgo
- status, err := subService.Update()
- if err != nil || status == 0 {
- l.Error(fmt.Sprintf("%+v", in), err.Error())
- resp.ErrorMsg = err.Error()
- resp.ErrorCode = -1
- } else {
- resp.Status = status
- }
- return resp, nil
- }
|