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

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

// 先根据功能分类把人的权益清空，再给人授权新的权益
func (l *CrReEmpowerLogic) CrReEmpower(in *pb.CrReEmpowerReq) (*pb.Resp, error) {
	resp := &pb.Resp{}
	status, err := CrReEmpower(in.Appid, in.FunctionModule, in.FunctionCode, in.EntId, in.EntUserId)
	if err != nil {
		l.Error(fmt.Sprintf("%+v", in), err)
	}
	resp.Status = status
	return resp, nil
}
