微信红包
This commit is contained in:
parent
afd93c8c74
commit
f25d88828c
|
|
@ -16,6 +16,10 @@ func transConfig(config []byte) (*Wechat, error) {
|
|||
return nil, proto.ErrorConfigFail(err.Error())
|
||||
}
|
||||
|
||||
if err := c.Validate(); err != nil {
|
||||
return nil, proto.ErrorConfigFail(err.Error())
|
||||
}
|
||||
|
||||
return &c, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package internal
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"gitea.cdlsxd.cn/sdk/plugin/proto"
|
||||
"github.com/go-playground/validator/v10"
|
||||
"os"
|
||||
"plugins/utils/helper"
|
||||
"plugins/wechat_redpack_v2/internal/wechat/srv/transfer"
|
||||
|
|
@ -24,10 +26,20 @@ func init() {
|
|||
}
|
||||
|
||||
type Wechat struct {
|
||||
MchID string `json:"mch_id"`
|
||||
MchCertificateSerialNumber string `json:"mch_certificate_serial_number"`
|
||||
WechatPayPublicKeyID string `json:"wechat_pay_public_key_id"`
|
||||
MchApiV3Key string `json:"mch_api_v3_key"`
|
||||
MchID string `json:"mch_id" validate:"required"`
|
||||
MchCertificateSerialNumber string `json:"mch_certificate_serial_number" validate:"required"`
|
||||
WechatPayPublicKeyID string `json:"wechat_pay_public_key_id" validate:"required"`
|
||||
MchApiV3Key string `json:"mch_api_v3_key" validate:"required"`
|
||||
}
|
||||
|
||||
func (c *Wechat) Validate() error {
|
||||
err := validator.New().Struct(c)
|
||||
if err != nil {
|
||||
for _, err = range err.(validator.ValidationErrors) {
|
||||
return proto.ErrorConfigFail("配置有误:" + err.Error())
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Client(wx *Wechat) (*transfer.Transfer, error) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue