package logic

import (
	"context"
	"jyBXSubscribe/rpc/model/service"

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

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

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

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

// 用户推送设置修改
func (l *SetPushSetLogic) SetPushSet(in *bxsubscribe.SetPushSetReq) (*bxsubscribe.StatusResp, 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,
	}
	fool := subService.Update(in.Item, in.SetType, in.PushType, in.Ratemode, in.PushValue, in.Interested, in.Times)
	if fool {
		return &bxsubscribe.StatusResp{
			ErrorCode: 0,
		}, nil
	} else {
		return &bxsubscribe.StatusResp{
			ErrorCode: -1,
		}, nil
	}

}
