package logic

import (
	"context"
	"jyBXSubscribe/rpc/internal/svc"
	"jyBXSubscribe/rpc/model"
	"jyBXSubscribe/rpc/type/bxsubscribe"

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

type GetKeyLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGetKeyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetKeyLogic {
	return &GetKeyLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 关键词获取
func (l *GetKeyLogic) GetKey(in *bxsubscribe.GetKeyReq) (*bxsubscribe.KeyResp, error) {
	// todo: add your logic here and delete this line
	spqp := &model.KeyParam{
		UserId:       in.UserId,    //用户id
		EntId:        in.EntId,     //商机管理企业id
		EntUserId:    in.EntUserId, //商机管理用户id
		NewUserId:    in.NewUserId,
		IsEnt:        in.IsEnt,
		VipPower:     in.VipPower,
		MemberPower:  in.MemberPower,
		PowerSource:  in.PowerSource,
		UserPower:    in.UserPower,
		DeptId:       in.DeptId,
		PositionType: in.PositionType,
	}
	data := model.NewSubscribePush(in.UserType).Keys(spqp)
	return &bxsubscribe.KeyResp{
		ErrCode: 0,
		ErrMsg:  "",
		Items:   data,
	}, nil
}
