标签:片段 string 代码 request Golang json LivenessRecognitionRequest omitempty name
Struct to JsonString
type BaseRequest struct {
httpMethod string
domain string
path string
params map[string]string
formParams map[string]string
service string
version string
action string
}
type LivenessRecognitionRequest struct {
*BaseRequest
// 身份证号
IdCard *string `json:"IdCard,omitempty" name:"IdCard"`
// 姓名。中文请使用UTF-8编码。
Name *string `json:"Name,omitempty" name:"Name"`
// 用于活体检测的视频,视频的BASE64值;
// BASE64编码后的大小不超过5M,支持mp4、avi、flv格式。
VideoBase64 *string `json:"VideoBase64,omitempty" name:"VideoBase64"`
// 活体检测类型,取值:LIP/ACTION/SILENT。
// LIP为数字模式,ACTION为动作模式,SILENT为静默模式,三种模式选择一种传入。
LivenessType *string `json:"LivenessType,omitempty" name:"LivenessType"`
// 数字模式传参:数字验证码(1234),需先调用接口获取数字验证码;
// 动作模式传参:传动作顺序(2,1 or 1,2),需先调用接口获取动作顺序;
// 静默模式传参:空。
ValidateData *string `json:"ValidateData,omitempty" name:"ValidateData"`
// 本接口不需要传递此参数。
Optional *string `json:"Optional,omitempty" name:"Optional"`
}
func (r *LivenessRecognitionRequest) ToJsonString() string {
b, _ := json.Marshal(r)
return string(b)
}
func (r *LivenessRecognitionRequest) FromJsonString(s string) error {
return json.Unmarshal([]byte(s), &r)
}
func StringPtr(v string) *string {
return &v
}
func NewLivenessRecognitionRequest() (request *LivenessRecognitionRequest) {
request = &LivenessRecognitionRequest{
BaseRequest: &tchttp.BaseRequest{},
}
request.Init().WithApiInfo("faceid", APIVersion, "LivenessRecognition")
return
}
func (l *LivenessRecognitionRequest)DoLivenessCompare() {
request := NewLivenessRecognitionRequest()
request.IdCard = StringPtr(l.IdCard)
request.Name = StringPtr(l.Name)
request.VideoBase64 = StringPtr(l.VideoBase64)
request.LivenessType = StringPtr(l.LivenessType)
requestData:=request.ToJsonString() //转strurct to jsonstring
err := request.FromJsonString(requestData) //转jsonstring to strurct
if err != nil {
panic(err)
}
}
func LivenessCompare(ctx *gin.Context) {
fmt.Println("LivenessCompare")
l.IdCard=""
l.Name="haima"
l.VideoBase64=""
l.LivenessType="ACTION"
l.DoLivenessCompare()
}
标签:片段,string,代码,request,Golang,json,LivenessRecognitionRequest,omitempty,name 来源: https://www.cnblogs.com/haima/p/12586561.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。