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 EmpowerListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

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

// 授权列表
func (l *EmpowerListLogic) EmpowerList(in *pb.EmpowerListReq) (*pb.EmpowerListResp, error) {
	resp := &pb.EmpowerListResp{}
	count, list, err := EmpowerList(in.Appid, in.FunctionCode, in.EntId, in.PageNum, in.PageSize)
	if err != nil {
		l.Error(fmt.Sprintf("%+v", in), err)
	}
	resp.Count, resp.List = count, list
	return resp, nil
}
