csx il y a 4 ans
Parent
révision
404c01b26a
1 fichiers modifiés avec 26 ajouts et 37 suppressions
  1. 26 37
      controllers/sg/his_api_controller.go

+ 26 - 37
controllers/sg/his_api_controller.go Voir le fichier

@@ -77,49 +77,38 @@ func (c *HisApiController) TestPay() {
77 77
 
78 78
 func (c *HisApiController) TestGetBasBaseInfo() {
79 79
 
80
-	result := C.Init(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
81
-	fmt.Println(result)
82 80
 	cs1 := C.CString("")
83 81
 	cs2 := C.CString("")
84
-	C.ReadCardBas(cs1, IntPtr(1024), cs2, IntPtr(1024))
85
-	fmt.Println(cs1)
86
-	fmt.Println(cs2)
87
-	C.free(unsafe.Pointer(cs1))
88
-	C.free(unsafe.Pointer(cs2))
89 82
 
90 83
 	//
91
-	//DllDef := syscall.MustLoadDLL("SSCard.dll")
92
-	//Iinit := DllDef.MustFindProc("Init")
93
-	//readCard := DllDef.MustFindProc("ReadCardBas")
94
-	//ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
95
-	//if ret != 0 {
96
-	//	fmt.Println("SSCard的报错原因:", err)
97
-	//	fmt.Println("SSCard的运算结果为:", ret)
98
-	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
99
-	//	return
100
-	//}
101
-	//
102
-	//result := int(ret)
103
-	//fmt.Println("SSCard的运算结果为1:", result)
84
+	DllDef := syscall.MustLoadDLL("SSCard.dll")
85
+	Iinit := DllDef.MustFindProc("Init")
86
+	readCard := DllDef.MustFindProc("ReadCardBas")
87
+	ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
88
+	if ret != 0 {
89
+		fmt.Println("SSCard的报错原因:", err)
90
+		fmt.Println("SSCard的运算结果为:", ret)
91
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
92
+		return
93
+	}
104 94
 
105
-	//if readCard == nil {
106
-	//	fmt.Println("readcard is nil")
107
-	//	readCard = DllDef.MustFindProc("ReadCardBas")
108
-	//}
109
-	//if readCard == nil {
110
-	//	fmt.Println("readcard reload  is nil")
111
-	//	return
112
-	//}
113
-	//ret2, _, err2 := readCard.Call((uintptr)(unsafe.Pointer(str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(str1[0])), IntPtr(1024))
114
-	//fmt.Println(" Add(4,5)的结果为:", ret2)
115
-	//fmt.Println(" str:", str)
116
-	//fmt.Println(" str1:", str1)
117
-	//if err2 != nil {
118
-	//	fmt.Println("SSCard的运算结果为:", ret2)
119
-	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
120
-	//	return
121
-	//}
95
+	result := int(ret)
96
+	fmt.Println("SSCard的运算结果为1:", result)
122 97
 
98
+	ret2, _, err2 := readCard.Call(cs1, IntPtr(1024), cs2, IntPtr(1024))
99
+	fmt.Println(" Add(4,5)的结果为:", ret2)
100
+	fmt.Println(" str:", cs1)
101
+	fmt.Println(" str1:", cs2)
102
+	if err2 != nil {
103
+		fmt.Println("SSCard的运算结果为:", ret2)
104
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
105
+		return
106
+	}
107
+
108
+	C.free(unsafe.Pointer(cs1))
109
+	C.free(unsafe.Pointer(cs2))
110
+
111
+	//
123 112
 }
124 113
 
125 114
 func (c *HisApiController) GetOrgInfo() {