oapi

package
v0.0.0-...-48fb7be Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeString

func DecodeString(message string) ([]byte, error)

func EncodeToString

func EncodeToString(data []byte) string

func GenGetSign

func GenGetSign(req GetOrderReq) ([]byte, error)

func GenSign

func GenSign(req OrderReq) ([]byte, error)

func GenerateRsaKey

func GenerateRsaKey(len int) (publicKey []byte, privateKey []byte, err error)

GenerateRsaKey 生成密钥对

func GenerateRsaKeyStr

func GenerateRsaKeyStr(len int) (publicKey string, privateKey string, err error)

GenerateRsaKeyStr 生成密钥对

func ParsePriKey

func ParsePriKey(privateKey []byte) (*rsa.PrivateKey, error)

ParsePriKey 将byte转为私钥

func ParsePubKey

func ParsePubKey(publicKey []byte) (*rsa.PublicKey, error)

ParsePubKey 将byte转换为RSA公钥

func PrivateKeyToPem

func PrivateKeyToPem(privateKey *rsa.PrivateKey) []byte

PrivateKeyToPem 将RSA私钥转换为byte

func PublicKeyToPem

func PublicKeyToPem(publicKey *rsa.PublicKey) ([]byte, error)

PublicKeyToPem 将RSA公钥转换为byte

func RSA_Decrypt

func RSA_Decrypt(encryptedMsg, priKey string) ([]byte, error)

私钥解密

func RSA_Encrypt

func RSA_Encrypt(message []byte, pubKey string) (string, error)

公钥加密

func RSA_Sign

func RSA_Sign(priKey string, message []byte) ([]byte, error)

RSA_Sign RsaSign 私钥加签

func RSA_Verify

func RSA_Verify(publicKeyPEM string, message []byte, signature []byte) error

RsaVerify 公钥验签

func RsaDecrypt

func RsaDecrypt(encryptedMsg, priKey []byte) ([]byte, error)

私钥解密

func RsaEncrypt

func RsaEncrypt(message []byte, pubKey []byte) ([]byte, error)

公钥加密

func RsaSign

func RsaSign(priKey, message []byte) ([]byte, error)

RsaSign 私钥加签

func RsaVerify

func RsaVerify(publicKeyPEM, message []byte, signature []byte) error

RsaVerify 公钥验签

Types

type AppVersionRes

type AppVersionRes struct {
	Code int                   `json:"code"`
	Msg  string                `json:"msg"`
	Data dto.GetAppVersionResp `json:"data"`
}

type CommonRes

type CommonRes struct {
	ReqId string `json:"reqId,omitempty"` //`json:"请求id"`
	Code  int    `json:"code"`            //返回码
	Msg   string `json:"msg,omitempty"`   //消息
	Data  any    `json:"data,omitempty"`  //数据
}

type CreateFingerReq

type CreateFingerReq struct {
	System    string `json:"system" form:"system"`       //
	UAversion string `json:"uAversion" form:"uAversion"` //
	PublicIp  string `json:"publicIp" form:"publicIp"`   //
	IpChannel string `json:"ipChannel" form:"ipChannel"` //
	Kernel    string `json:"kernel" form:"kernel"`       //
}

type CreateFingerResp

type CreateFingerResp struct {
	ReqId string `json:"reqId,omitempty"` //`json:"请求id"`
	Code  int    `json:"code"`            //返回码
	Msg   string `json:"msg,omitempty"`   //消息
	Data  struct {
		DefaultConfig any `json:"defaultConfig"`
		FingerInfo    any `json:"fingerInfo"`
	} `json:"data,omitempty"` //数据
}

type GetOrderReq

type GetOrderReq struct {
	AppId      string `json:"appId" `      //商户Appid(终端号)
	MerchantNo string `json:"merchantNo"`  //商户号
	AppTraceNo string `json:"appTraceNo" ` //终端流水号(终端订单号)
	OutTradeNo string `json:"outTradeNo" ` //系统平台唯一订单号
	ReqTime    int    `json:"reqTime" `    //请求时间
	Sign       string `json:"sign"`        //签名 Rsa appTraceNo=%s&merchantNo=%s&outTradeNo=%s&ReqTime=%d
}

GetOrderReq 查询订单请求

type OApi

type OApi struct {
	// contains filtered or unexported fields
}

func New

func New(baseUrl string) *OApi

func NewFingerOApi

func NewFingerOApi(baseUrl string) *OApi

func (*OApi) AddHeader

func (e *OApi) AddHeader(k, v string) *OApi

func (*OApi) AppVersion

func (e *OApi) AppVersion() (*dto.GetAppVersionResp, error)

func (*OApi) CreateFinger

func (x *OApi) CreateFinger(req, resp any) error

func (*OApi) Get

func (e *OApi) Get(url string) (resp []byte, err error)

func (*OApi) GetUserInfo

func (e *OApi) GetUserInfo(userId string, user *Userinfo) error

func (*OApi) GetUserInfoUpdate

func (e *OApi) GetUserInfoUpdate(userId string, user *Userinfo) error

func (*OApi) Header

func (e *OApi) Header(m map[string]string) *OApi

func (*OApi) Post

func (e *OApi) Post(url string, data []byte) (resp []byte, err error)

type OpenTypeEnum

type OpenTypeEnum int
const (
	OpenPlatform OpenTypeEnum = 1
)

type OrderInfoResp

type OrderInfoResp struct {
	OutTradeNo  string      `json:"outTradeNo" ` //支付系统平台唯一订单号
	AppTraceNo  string      `json:"appTraceNo" ` //终端流水号(终端订单号) 本系统订单号
	OrderStatus OrderStatus `json:"orderStatus"` //订单状态 例如1待付款,2已付款,3已取消等 4异常
	PayOrderNo  string      `json:"payOrderNo" ` //支付平台订单号 第三方
	MerchantNo  string      `json:"merchantNo" ` //商户号
	AppId       string      `json:"appId" `      //商户Appid(终端号)
	Currency    string      `json:"currency" `   //货币类型 RMB
	PayType     string      `json:"payType"`     //支付方式
	PayTrace    string      `json:"payTrace" `   //实际支付金额(小数点18位)
	PayTime     int64       `json:"payTime" `    //支付平台 支付时间
}

OrderInfoResp 回调订单信息

func GetOrder

func GetOrder(ctx context.Context, orderNo string) (orderFindResp OrderInfoResp, err error)

type OrderPreResp

type OrderPreResp struct {
	OutTradeNo  string `json:"outTradeNo" ` //系统平台唯一订单号
	AppTraceNo  string `json:"appTraceNo" ` //终端流水号(终端订单号)
	OrderStatus int    `json:"orderStatus"` //订单状态 例如1待付款,2已付款,3已取消等 4异常
	Currency    string `json:"currency" `   //货币类型 RMB
	PayType     string `json:"payType"`     //支付方式
	PayTrace    string `json:"payTrace" `   //实际支付金额(小数点18位)
	PayUrl      string `json:"payUrl" `     //支付链接
	Ext         any    `json:"ext"`         //扩张
}

OrderPreResp 预付订单返回

func CreatePay

func CreatePay(orderNo, payType, subject, user, redirectUrl, payer string, totalFee decimal.Decimal) (orderPreResp OrderPreResp, err error)

type OrderReq

type OrderReq struct {
	AppId        string `json:"appId" `        //商户Appid(终端号)
	MerchantNo   string `json:"merchantNo"`    //商户号
	AppTraceNo   string `json:"appTraceNo" `   //终端流水号(终端订单号)
	AppTraceTime int    `json:"appTraceTime" ` //终端交易时间
	TotalFee     string `json:"totalFee" `     //订单金额共36位,小数点18位
	Currency     string `json:"currency" `     //订单货币类型 RMB
	PayCurrency  string `json:"payCurrency" `  //支付货币类型 预留
	PayType      string `json:"payType" `      //支付方式
	OrderBody    string `json:"orderBody" `    //订单描述
	GoodsDetail  string `json:"goodsDetail" `  //订单包含的商品列表信息
	NotifyUrl    string `json:"notifyUrl"`     //回调地址
	RedirectUrl  string `json:"redirectUrl"`   //订单显示页
	Code         string `json:"code"`          //获取微信openId的code
	Payer        string `json:"payer"`         //支付人 wxjs支付openId
	DevType      string `json:"devType"`       //设备类型 h5支付
	Sign         string `json:"sign"`          //签名
	Locale       string `json:"locale"`        //语言
}

OrderReq 统一下单接口

type OrderResp

type OrderResp struct {
	MerchantNo string `json:"merchantNo" ` //商户号
	AppId      string `json:"appId" `      //商户Appid(终端号)
	PayType    string `json:"payType"`     //支付方式
	Body       string `json:"body"`        //订单信息 OrderInfoResp
}

OrderResp 订单回调信息

type OrderRsp

type OrderRsp struct {
	ReqId string
	Code  int
	Msg   string
	Data  interface{}
}

type OrderStatus

type OrderStatus int
const (
	OrderStatusWaitPay    OrderStatus = 1
	OrderStatusPaySuccess OrderStatus = 2
	OrderStatusCancel     OrderStatus = 3
	OrderStatusException  OrderStatus = 4
)

type Res

type Res struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

type Userinfo

type Userinfo struct {
	UserId     string       `json:"userId" comment:"用户id"`
	Username   string       `json:"username" comment:"用户名"`
	Mobile     string       `json:"mobile" comment:"手机号"`
	Email      string       `json:"email" comment:"邮箱"`
	FirstName  string       `json:"firstName" comment:"名"`
	LastName   string       `json:"lastName" comment:"姓"`
	Nickname   string       `json:"nickname" comment:"昵称"`
	Avatar     string       `json:"avatar" comment:"头像"`
	Bio        string       `json:"bio" comment:"签名"`
	Gender     string       `json:"gender" comment:"性别 0 女 1 男 2 未知"`
	Birthday   time.Time    `json:"birthday" comment:"生日"`
	Inviter    string       `json:"inviter" gorm:"type:varchar(32);default:(-);comment:邀请人"` //邀请人
	InviteType int          `json:"inviteType" gorm:"type:tinyint;comment:邀请类型"`             //邀请类型
	OpenType   OpenTypeEnum `json:"openType" gorm:"type:tinyint;comment:开放类型"`               //开放类型
	CreatedAt  time.Time    `json:"createdAt" gorm:"comment:创建时间"`                           //创建时间
	Source     string       `json:"source" gorm:"type:varchar(32);default:(-);comment:来源"`   //来源
}

func (Userinfo) GetName

func (u Userinfo) GetName() string

Jump to

Keyboard shortcuts

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