2025-02-05 18:45:49 +08:00
|
|
|
package logic
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"gitea.youtukeji.com.cn/xiabin/youtu_grpc/auth_service/auth_service"
|
|
|
|
"gitea.youtukeji.com.cn/xiabin/youtu_grpc/auth_service/internal/svc"
|
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
|
)
|
|
|
|
|
|
|
|
type GetAccessTokenLogic struct {
|
|
|
|
ctx context.Context
|
|
|
|
svcCtx *svc.ServiceContext
|
|
|
|
logx.Logger
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewGetAccessTokenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAccessTokenLogic {
|
|
|
|
return &GetAccessTokenLogic{
|
|
|
|
ctx: ctx,
|
|
|
|
svcCtx: svcCtx,
|
|
|
|
Logger: logx.WithContext(ctx),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *GetAccessTokenLogic) GetAccessToken(in *auth_service.GetAccessTokenRequest) (*auth_service.GetAccessTokenResponse, error) {
|
2025-02-06 15:35:23 +08:00
|
|
|
cli, err := l.svcCtx.Cli.Get(in.AppId)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
accessToken, err := cli.GetAccessToken(l.ctx)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &auth_service.GetAccessTokenResponse{Access: accessToken}, nil
|
2025-02-05 18:45:49 +08:00
|
|
|
}
|