package logic

import (
	"context"
	"fmt"

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

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

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

func (l *HaspowersLogic) Haspowers(req *types.Req) (resp *types.Reply, err error) {
	resp = &types.Reply{}
	powers, err := HasPowers(req.AppId, req.Account_id, req.Ent_account_id, req.Ent_id, req.Ent_user_id)
	if err != nil {
		resp.Error_msg = err.Error()
		l.Error(fmt.Sprintf("%+v", req), err)
	}
	resp.Error_code = 0
	resp.Data = powers
	return
}
