v0.1
This commit is contained in:
@@ -2,18 +2,43 @@ package esign
|
||||
|
||||
import "fmt"
|
||||
|
||||
type EsignContractConfig struct {
|
||||
Name string `json:"name" yaml:"name"`
|
||||
ExpireDays int `json:"expireDays" yaml:"expire_days"`
|
||||
RetryCount int `json:"retryCount" yaml:"retry_count"`
|
||||
}
|
||||
|
||||
type EsignAuthConfig struct {
|
||||
OrgAuthModes []string `json:"orgAuthModes" yaml:"org_auth_modes"`
|
||||
DefaultAuthMode string `json:"defaultAuthMode" yaml:"default_auth_mode"`
|
||||
PsnAuthModes []string `json:"psnAuthModes" yaml:"psn_auth_modes"`
|
||||
WillingnessAuthModes []string `json:"willingnessAuthModes" yaml:"willingness_auth_modes"`
|
||||
RedirectUrl string `json:"redirectUrl" yaml:"redirect_url"`
|
||||
}
|
||||
|
||||
type EsignSignConfig struct {
|
||||
AutoFinish bool `json:"autoFinish" yaml:"auto_finish"`
|
||||
SignFieldStyle int `json:"signFieldStyle" yaml:"sign_field_style"`
|
||||
ClientType string `json:"clientType" yaml:"client_type"`
|
||||
RedirectUrl string `json:"redirectUrl" yaml:"redirect_url"`
|
||||
}
|
||||
|
||||
// Config e签宝服务配置结构体
|
||||
// 包含应用ID、密钥、服务器URL和模板ID等基础配置信息
|
||||
// 新增Contract、Auth、Sign配置
|
||||
type Config struct {
|
||||
AppID string `json:"appId"` // 应用ID
|
||||
AppSecret string `json:"appSecret"` // 应用密钥
|
||||
ServerURL string `json:"serverUrl"` // 服务器URL
|
||||
TemplateID string `json:"templateId"` // 模板ID
|
||||
AppID string `json:"appId" yaml:"app_id"`
|
||||
AppSecret string `json:"appSecret" yaml:"app_secret"`
|
||||
ServerURL string `json:"serverUrl" yaml:"server_url"`
|
||||
TemplateID string `json:"templateId" yaml:"template_id"`
|
||||
Contract *EsignContractConfig `json:"contract" yaml:"contract"`
|
||||
Auth *EsignAuthConfig `json:"auth" yaml:"auth"`
|
||||
Sign *EsignSignConfig `json:"sign" yaml:"sign"`
|
||||
}
|
||||
|
||||
// NewConfig 创建新的配置实例
|
||||
// 提供配置验证和默认值设置
|
||||
func NewConfig(appID, appSecret, serverURL, templateID string) (*Config, error) {
|
||||
func NewConfig(appID, appSecret, serverURL, templateID string, contract *EsignContractConfig, auth *EsignAuthConfig, sign *EsignSignConfig) (*Config, error) {
|
||||
if appID == "" {
|
||||
return nil, fmt.Errorf("应用ID不能为空")
|
||||
}
|
||||
@@ -26,12 +51,15 @@ func NewConfig(appID, appSecret, serverURL, templateID string) (*Config, error)
|
||||
if templateID == "" {
|
||||
return nil, fmt.Errorf("模板ID不能为空")
|
||||
}
|
||||
|
||||
|
||||
return &Config{
|
||||
AppID: appID,
|
||||
AppSecret: appSecret,
|
||||
ServerURL: serverURL,
|
||||
TemplateID: templateID,
|
||||
Contract: contract,
|
||||
Auth: auth,
|
||||
Sign: sign,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -60,7 +88,7 @@ const (
|
||||
AuthModeBank = "PSN_BANK" // 银行卡认证
|
||||
|
||||
// 意愿认证模式
|
||||
WillingnessAuthSMS = "CODE_SMS" // 短信验证码
|
||||
WillingnessAuthSMS = "CODE_SMS" // 短信验证码
|
||||
WillingnessAuthEmail = "CODE_EMAIL" // 邮箱验证码
|
||||
|
||||
// 证件类型常量
|
||||
@@ -69,7 +97,7 @@ const (
|
||||
|
||||
// 签署区样式常量
|
||||
SignFieldStyleNormal = 1 // 普通签章
|
||||
SignFieldStyleSeam = 2 // 骑缝签章
|
||||
SignFieldStyleSeam = 2 // 骑缝签章
|
||||
|
||||
// 签署人类型常量
|
||||
SignerTypePerson = 0 // 个人
|
||||
@@ -80,4 +108,4 @@ const (
|
||||
|
||||
// 客户端类型常量
|
||||
ClientTypeAll = "ALL" // 所有客户端
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user