fix: fix the error

This commit is contained in:
luhaoling 2024-01-17 14:54:46 +08:00
parent f386b11267
commit cd77fed132

View File

@ -461,33 +461,33 @@ func (m *MessageApi) CallbackExample(c *gin.Context) {
return return
} }
content := make(map[string]any, 1) content := make(map[string]any, 10)
text := apistruct.TextElem{}
picture := apistruct.PictureElem{}
if req.ContentType == constant.Text { if req.ContentType == constant.Text {
con := apistruct.TextElem{} err = json.Unmarshal([]byte(req.Content), &text)
err = json.Unmarshal([]byte(req.Content), &con)
if err != nil { if err != nil {
log.ZError(c, "CallbackExample unmarshal failed", err) log.ZError(c, "CallbackExample unmarshal failed", err)
apiresp.GinError(c, errs.ErrInternalServer.WithDetail(err.Error()).Wrap()) apiresp.GinError(c, errs.ErrInternalServer.WithDetail(err.Error()).Wrap())
return return
} }
log.ZDebug(c, "CallbackExample TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT ", con) log.ZDebug(c, "CallbackExample TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT ", text)
content["content"] = con.Content content["content"] = text.Content
} else { } else {
//"req.Content": "{\"sourcePath\":\"/screenshot1705471793324.png\",\"sourcePicture\":{\"uuid\":\"6f9660f9-6c8b-42e2-a38b-773f67466772/screenshot1705471793324.png\",\"type\":\"image/png\",\"size\":654,\"width\":167,\"height\":196,\"url\":\"http://150.109.93.151:10002/object/3097485888/msg_picture_b09c0b7b433a050fa84a563d7b82c576.png\"},\"bigPicture\":{\"uuid\":\"6f9660f9-6c8b-42e2-a38b-773f67466772/screenshot1705471793324.png\",\"type\":\"image/png\",\"size\":654,\"width\":167,\"height\":196,\"url\":\"http://150.109.93.151:10002/object/3097485888/msg_picture_b09c0b7b433a050fa84a563d7b82c576.png\"},\"snapshotPicture\":{\"size\":0,\"width\":640,\"height\":640,\"url\":\"http://150.109.93.151:10002/object/3097485888/msg_picture_b09c0b7b433a050fa84a563d7b82c576.png?height=640\\u0026type=image\\u0026width=640\"}}" //"req.Content": "{\"sourcePath\":\"/screenshot1705471793324.png\",\"sourcePicture\":{\"uuid\":\"6f9660f9-6c8b-42e2-a38b-773f67466772/screenshot1705471793324.png\",\"type\":\"image/png\",\"size\":654,\"width\":167,\"height\":196,\"url\":\"http://150.109.93.151:10002/object/3097485888/msg_picture_b09c0b7b433a050fa84a563d7b82c576.png\"},\"bigPicture\":{\"uuid\":\"6f9660f9-6c8b-42e2-a38b-773f67466772/screenshot1705471793324.png\",\"type\":\"image/png\",\"size\":654,\"width\":167,\"height\":196,\"url\":\"http://150.109.93.151:10002/object/3097485888/msg_picture_b09c0b7b433a050fa84a563d7b82c576.png\"},\"snapshotPicture\":{\"size\":0,\"width\":640,\"height\":640,\"url\":\"http://150.109.93.151:10002/object/3097485888/msg_picture_b09c0b7b433a050fa84a563d7b82c576.png?height=640\\u0026type=image\\u0026width=640\"}}"
con := apistruct.PictureElem{} err = json.Unmarshal([]byte(req.Content), &picture)
err = json.Unmarshal([]byte(req.Content), &con)
if err != nil { if err != nil {
log.ZError(c, "picktureStruct unmarshal failed", err) log.ZError(c, "picktureStruct unmarshal failed", err)
apiresp.GinError(c, errs.ErrInternalServer.WithDetail(err.Error()).Wrap()) apiresp.GinError(c, errs.ErrInternalServer.WithDetail(err.Error()).Wrap())
return return
} }
log.ZDebug(c, "CallbackExample PICKTURE PICKTURE PICKTURE PICKTURE PICKTURE PICKTURE PICKTURE PICKTURE PICKTURE PICKTURE PICKTURE PICKTURE ", con) log.ZDebug(c, "CallbackExample PICKTURE PICKTURE PICKTURE PICKTURE PICKTURE PICKTURE PICKTURE PICKTURE PICKTURE PICKTURE PICKTURE PICKTURE ", picture)
content["sourcePath"] = con.SourcePath content["sourcePath"] = picture.SourcePath
content["sourcePicture"] = con.SourcePicture content["sourcePicture"] = picture.SourcePicture
content["bigPicture"] = con.BigPicture content["bigPicture"] = picture.BigPicture
content["snapshotPicture"] = con.SnapshotPicture content["snapshotPicture"] = picture.SnapshotPicture
} }
log.ZDebug(c, "CallbackExample CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT ", content) log.ZDebug(c, "CallbackExample CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT CONTENT ", content)