package logic

import (
	"context"
	"github.com/zeromicro/go-zero/core/logx"
	"jyBXSubscribe/rpc/internal/svc"
	"jyBXSubscribe/rpc/model/service"
	"jyBXSubscribe/rpc/type/bxsubscribe"
	"jyBXSubscribe/rpc/util"
)

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

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

// 用户推送设置查看
func (l *GetPushSetLogic) GetPushSet(in *bxsubscribe.GetPushSetReq) (*bxsubscribe.GetPushSetResp, error) {
	// todo: add your logic here and delete this line
	subService := &service.PushSetService{
		UserId:       in.UserId,
		PositionType: in.PositionType,
		EntUserId:    in.EntUserId,
		EntId:        in.EntId,
		AccountId:    in.AccountId,
		BaseUserId:   in.BaseUserId,
		PositionId:   in.PositionId,
		MgoUserId:    in.MgoUserId,
	}
	TimeData := map[int64]*bxsubscribe.TimeJson{}
	for k, v := range util.TimeMap {
		TimeData[int64(k)] = &bxsubscribe.TimeJson{ATimes: v}
	}
	pushSet := subService.Find()
	return &bxsubscribe.GetPushSetResp{
		Data:     pushSet,
		TimeData: TimeData,
	}, nil

}
