From 01dfd9dc8de7b19f9dfa4284722e01bbd5837801 Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期五, 19 一月 2024 09:10:30 +0800 Subject: [PATCH] replace json to json-iterator --- licenseApi.go | 37 +++++++++++++++++++------------------ 1 files changed, 19 insertions(+), 18 deletions(-) diff --git a/licenseApi.go b/licenseApi.go index fd6176f..1494f16 100644 --- a/licenseApi.go +++ b/licenseApi.go @@ -1,61 +1,62 @@ package bhomedbapi import ( - json "github.com/json-iterator/go" + jsoniter "github.com/json-iterator/go" ) -type LicenseApi struct{ - +type LicenseApi struct { } - -func (api LicenseApi) GetRegisterCode(paramBody map[string]interface{}) (bool,interface{}){ +func (api LicenseApi) GetRegisterCode(paramBody map[string]interface{}) (bool, interface{}) { url := DATA_URL_PREFIX + "/license/getRegisterCode" netNode := getNetNode(url2Topic(Topic_System_Service, url)) client := NewClient(WithNodes(netNode)) - body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil) + body, err := client.DoPostRequest(url, CONTENT_TYPE_JSON, paramBody, nil, nil) if err != nil { - return false,nil + return false, nil } + var json = jsoniter.ConfigCompatibleWithStandardLibrary var res Result if err = json.Unmarshal(body, &res); err != nil { - return false,nil + return false, nil } - return res.Success,res.Data + return res.Success, res.Data } -func (api LicenseApi) Save(paramBody map[string]interface{}) (bool,interface{}){ +func (api LicenseApi) Save(paramBody map[string]interface{}) (bool, interface{}) { url := DATA_URL_PREFIX + "/license/save" netNode := getNetNode(url2Topic(Topic_System_Service, url)) client := NewClient(WithNodes(netNode)) - body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil) + body, err := client.DoPostRequest(url, CONTENT_TYPE_JSON, paramBody, nil, nil) if err != nil { - return false,nil + return false, nil } + var json = jsoniter.ConfigCompatibleWithStandardLibrary var res Result if err = json.Unmarshal(body, &res); err != nil { - return false,nil + return false, nil } - return res.Success,res.Data + return res.Success, res.Data } -func (api LicenseApi) Show() (int,bool,interface{}){ +func (api LicenseApi) Show() (int, bool, interface{}) { url := DATA_URL_PREFIX + "/license/show" netNode := getNetNode(url2Topic(Topic_System_Service, url)) client := NewClient(WithNodes(netNode)) body, err := client.DoGetRequest(url, nil, nil) if err != nil { - return 500,false,nil + return 500, false, nil } + var json = jsoniter.ConfigCompatibleWithStandardLibrary var res Result if err = json.Unmarshal(body, &res); err != nil { - return 500,false,nil + return 500, false, nil } - return res.Code,res.Success,res.Data + return res.Code, res.Success, res.Data } -- Gitblit v1.8.0