package logic

import (
	"app.yhyue.com/moapp/jybase/encrypt"
	"context"
	"fmt"
	"net/http"

	"jyBXSubscribe/api/internal/svc"
	"jyBXSubscribe/api/internal/types"
	"jyBXSubscribe/rpc/type/bxsubscribe"

	"github.com/zeromicro/go-zero/core/logx"
)

type SomeInfoLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
	r      *http.Request
}

func NewSomeInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext, r *http.Request) *SomeInfoLogic {
	return &SomeInfoLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
		r:      r,
	}
}

func (l *SomeInfoLogic) SomeInfo(req *types.SomeInfoReq) (resp *types.CommonResp, err error) {
	res, err := l.svcCtx.Suscribe.GetSubSomeInfo(l.ctx, &bxsubscribe.SomeInfoReq{
		AppId:        req.AppId,
		UserType:     req.UserType,
		UserId:       req.UserId,
		NewUserId:    req.NewUserId,
		EntId:        req.EntId,
		PositionId:   req.PositionId,
		AccountId:    req.AccountId,
		PositionType: req.PositionType,
	})
	if err != nil {
		return &types.CommonResp{
			Err_code: res.ErrCode,
			Err_msg:  res.ErrMsg,
			Data:     nil,
		}, nil
	}
	logx.Info("-----------:", res.Data)
	res.Data.UserId = encrypt.EncodeArticleId2ByCheck(fmt.Sprint(req.NewUserId))
	return &types.CommonResp{
		Err_code: res.ErrCode,
		Err_msg:  res.ErrMsg,
		Data:     res.Data,
	}, nil
}
