service

package
v0.0.0-...-67ab1fb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateAppRequest

type CreateAppRequest struct {
	AppName     string `json:"appName" v:"required#应用名称不能为空"`
	Description string `json:"description"`
}

CreateAppRequest 创建应用请求结构

type CreateAppResponse

type CreateAppResponse struct {
	AppId      string `json:"appId"`
	AppSecret  string `json:"appSecret"`
	PublicKey  string `json:"publicKey"`
	PrivateKey string `json:"privateKey"`
}

CreateAppResponse 创建应用响应结构

type OpenapiSignService

type OpenapiSignService struct {
	*v.Service
	// contains filtered or unexported fields
}

OpenapiSignService 开放平台签名服务

func NewOpenapiSignService

func NewOpenapiSignService() *OpenapiSignService

NewOpenapiSignService 创建开放平台签名服务实例 功能: 创建并初始化开放平台签名服务 返回值: *OpenapiSignService - 签名服务实例

func (*OpenapiSignService) CreateApp

CreateApp 创建应用 功能: 创建新的开放平台应用,生成RSA密钥对和应用密钥 参数: ctx - 上下文, req - 创建应用请求 返回值: *CreateAppResponse - 创建应用响应, error - 错误信息

func (*OpenapiSignService) GenerateSign

func (s *OpenapiSignService) GenerateSign(ctx context.Context, req *SignRequest, clientIp, userAgent string) (*SignResponse, error)

GenerateSign 生成签名 功能: 为指定应用生成RSA签名,并记录签名日志 参数: ctx - 上下文, req - 签名请求, clientIp - 客户端IP, userAgent - 用户代理 返回值: *SignResponse - 签名响应, error - 错误信息

func (*OpenapiSignService) GetAppInfo

func (s *OpenapiSignService) GetAppInfo(ctx context.Context, appId string) (g.Map, error)

GetAppInfo 获取应用信息 功能: 根据应用ID获取应用的基本信息(不包含私钥) 参数: ctx - 上下文, appId - 应用ID 返回值: g.Map - 应用信息映射, error - 错误信息

func (*OpenapiSignService) VerifySign

func (s *OpenapiSignService) VerifySign(ctx context.Context, req *SignRequest, signature string) (bool, error)

VerifySign 验证签名 功能: 验证RSA签名是否正确,包括时间戳验证和签名验证 参数: ctx - 上下文, req - 签名请求, signature - 待验证的签名 返回值: bool - 验证结果, error - 错误信息

type SignRequest

type SignRequest struct {
	AppId     string      `json:"appId" v:"required#应用ID不能为空"`
	Timestamp int64       `json:"timestamp" v:"required#时间戳不能为空"`
	Nonce     string      `json:"nonce" v:"required#随机数不能为空"`
	Data      interface{} `json:"data"`
}

SignRequest 签名请求结构

type SignResponse

type SignResponse struct {
	Signature string `json:"signature"`
	RequestId string `json:"requestId"`
}

SignResponse 签名响应结构

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL