|
|
@@ -1,7 +1,9 @@
|
|
|
package asign
|
|
|
|
|
|
import (
|
|
|
+ "bytes"
|
|
|
"encoding/json"
|
|
|
+ "fmt"
|
|
|
"mtp20access/global"
|
|
|
"os/exec"
|
|
|
"strings"
|
|
|
@@ -9,9 +11,6 @@ import (
|
|
|
"go.uber.org/zap"
|
|
|
)
|
|
|
|
|
|
-var appId = global.M2A_CONFIG.Asign.AppId
|
|
|
-var privateKey = global.M2A_CONFIG.Asign.PrivateKey
|
|
|
-
|
|
|
// 签名规范:
|
|
|
//
|
|
|
// 1、表单提交方式:form-data
|
|
|
@@ -234,8 +233,8 @@ func AddPersonalUserBy(account, name, idCard, mobile string, idCardType *int) (r
|
|
|
}
|
|
|
|
|
|
reqData["api"] = "addPerson"
|
|
|
- reqData["appId"] = appId
|
|
|
- reqData["appKey"] = privateKey
|
|
|
+ reqData["appId"] = global.M2A_CONFIG.Asign.AppId
|
|
|
+ reqData["appKey"] = global.M2A_CONFIG.Asign.PrivateKey
|
|
|
reqData["apiUrl"] = apiUrl
|
|
|
|
|
|
// 将请求数据转换为JSON字符串
|
|
|
@@ -248,17 +247,27 @@ func AddPersonalUserBy(account, name, idCard, mobile string, idCardType *int) (r
|
|
|
pythonScriptPath := "./py/Enter.py"
|
|
|
// 创建一个命令对象
|
|
|
cmd := exec.Command("py", pythonScriptPath)
|
|
|
+
|
|
|
// 设置标准输入为JSON字符串
|
|
|
cmd.Stdin = strings.NewReader(string(reqJSON))
|
|
|
- // 获取标准输出
|
|
|
- output, err := cmd.CombinedOutput()
|
|
|
+
|
|
|
+ // 创建一个字节缓冲区来捕获命令的输出
|
|
|
+ var stdoutBuf, stderrBuf bytes.Buffer
|
|
|
+ cmd.Stdout = &stdoutBuf
|
|
|
+ cmd.Stderr = &stderrBuf
|
|
|
+
|
|
|
+ // 执行命令
|
|
|
+ err = cmd.Run()
|
|
|
+ // 输出标准输出和标准错误
|
|
|
+ fmt.Println("标准输出:", stdoutBuf.String())
|
|
|
+ fmt.Println("标准错误:", stderrBuf.String())
|
|
|
if err != nil {
|
|
|
global.M2A_LOG.Error("[AddPersonalUserBy] 请求失败", zap.Error(err))
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 结果
|
|
|
- rspBody := string(output)
|
|
|
+ rspBody := stdoutBuf.String()
|
|
|
if err = json.Unmarshal([]byte(rspBody), &rspData); err != nil {
|
|
|
global.M2A_LOG.Error("[AddPersonalUserBy] 反序列化body失败", zap.Error(err))
|
|
|
return
|
|
|
@@ -294,8 +303,8 @@ func CreateContract(contractNo, contractName, templateNo string) (rspData AsignR
|
|
|
reqData["notifyUrl"] = ""
|
|
|
|
|
|
reqData["api"] = "createContract"
|
|
|
- reqData["appId"] = appId
|
|
|
- reqData["appKey"] = privateKey
|
|
|
+ reqData["appId"] = global.M2A_CONFIG.Asign.AppId
|
|
|
+ reqData["appKey"] = global.M2A_CONFIG.Asign.PrivateKey
|
|
|
reqData["apiUrl"] = apiUrl
|
|
|
|
|
|
// 将请求数据转换为JSON字符串
|
|
|
@@ -365,8 +374,8 @@ func AddSigner(contractNo, account string) (rspData AsignRsp[AddSignerData], err
|
|
|
{"attachNo": 1, "locationMode": 4}}
|
|
|
|
|
|
reqData["api"] = "addSigner"
|
|
|
- reqData["appId"] = appId
|
|
|
- reqData["appKey"] = privateKey
|
|
|
+ reqData["appId"] = global.M2A_CONFIG.Asign.AppId
|
|
|
+ reqData["appKey"] = global.M2A_CONFIG.Asign.PrivateKey
|
|
|
reqData["apiUrl"] = apiUrl
|
|
|
|
|
|
// 将请求数据转换为JSON字符串
|