package logic

import (
	"context"
	"fmt"

	. "bp.jydev.jianyu360.cn/BaseService/resourceCenter/public/service"
	"bp.jydev.jianyu360.cn/BaseService/resourceCenter/rpc/internal/svc"
	"bp.jydev.jianyu360.cn/BaseService/resourceCenter/rpc/pb"
	"github.com/zeromicro/go-zero/core/logx"
)

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

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

// 所有的权益
func (l *HaspowersLogic) Haspowers(in *pb.HaspowersReq) (*pb.HaspowersResp, error) {
	resp := &pb.HaspowersResp{}
	powers, err := HasPowers(in.Appid, in.AccountId, in.EntAccountId, in.EntId, in.EntUserId)
	if err != nil {
		l.Error(fmt.Sprintf("%+v", in), err)
	}
	resp.Powers = powers
	return resp, nil
}
