temp
This commit is contained in:
83
internal/shared/esign/config.go
Normal file
83
internal/shared/esign/config.go
Normal file
@@ -0,0 +1,83 @@
|
||||
package esign
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Config e签宝服务配置结构体
|
||||
// 包含应用ID、密钥、服务器URL和模板ID等基础配置信息
|
||||
type Config struct {
|
||||
AppID string `json:"appId"` // 应用ID
|
||||
AppSecret string `json:"appSecret"` // 应用密钥
|
||||
ServerURL string `json:"serverUrl"` // 服务器URL
|
||||
TemplateID string `json:"templateId"` // 模板ID
|
||||
}
|
||||
|
||||
// NewConfig 创建新的配置实例
|
||||
// 提供配置验证和默认值设置
|
||||
func NewConfig(appID, appSecret, serverURL, templateID string) (*Config, error) {
|
||||
if appID == "" {
|
||||
return nil, fmt.Errorf("应用ID不能为空")
|
||||
}
|
||||
if appSecret == "" {
|
||||
return nil, fmt.Errorf("应用密钥不能为空")
|
||||
}
|
||||
if serverURL == "" {
|
||||
return nil, fmt.Errorf("服务器URL不能为空")
|
||||
}
|
||||
if templateID == "" {
|
||||
return nil, fmt.Errorf("模板ID不能为空")
|
||||
}
|
||||
|
||||
return &Config{
|
||||
AppID: appID,
|
||||
AppSecret: appSecret,
|
||||
ServerURL: serverURL,
|
||||
TemplateID: templateID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Validate 验证配置的完整性
|
||||
func (c *Config) Validate() error {
|
||||
if c.AppID == "" {
|
||||
return fmt.Errorf("应用ID不能为空")
|
||||
}
|
||||
if c.AppSecret == "" {
|
||||
return fmt.Errorf("应用密钥不能为空")
|
||||
}
|
||||
if c.ServerURL == "" {
|
||||
return fmt.Errorf("服务器URL不能为空")
|
||||
}
|
||||
if c.TemplateID == "" {
|
||||
return fmt.Errorf("模板ID不能为空")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 认证模式常量
|
||||
const (
|
||||
// 个人认证模式
|
||||
AuthModeMobile3 = "PSN_MOBILE3" // 手机号三要素认证
|
||||
AuthModeIDCard = "PSN_IDCARD" // 身份证认证
|
||||
AuthModeBank = "PSN_BANK" // 银行卡认证
|
||||
|
||||
// 意愿认证模式
|
||||
WillingnessAuthSMS = "CODE_SMS" // 短信验证码
|
||||
WillingnessAuthEmail = "CODE_EMAIL" // 邮箱验证码
|
||||
|
||||
// 证件类型常量
|
||||
IDCardTypeChina = "CRED_PSN_CH_IDCARD" // 中国大陆居民身份证
|
||||
OrgCardTypeUSCC = "CRED_ORG_USCC" // 统一社会信用代码
|
||||
|
||||
// 签署区样式常量
|
||||
SignFieldStyleNormal = 1 // 普通签章
|
||||
SignFieldStyleSeam = 2 // 骑缝签章
|
||||
|
||||
// 签署人类型常量
|
||||
SignerTypePerson = 0 // 个人
|
||||
SignerTypeOrg = 1 // 机构
|
||||
|
||||
// URL类型常量
|
||||
UrlTypeSign = 2 // 签署链接
|
||||
|
||||
// 客户端类型常量
|
||||
ClientTypeAll = "ALL" // 所有客户端
|
||||
)
|
||||
Reference in New Issue
Block a user