csx 4 년 전
부모
커밋
8ae72ac2da
1개의 변경된 파일19개의 추가작업 그리고 15개의 파일을 삭제
  1. 19 15
      controllers/sg/his_api_controller.go

+ 19 - 15
controllers/sg/his_api_controller.go 파일 보기

@@ -1,9 +1,6 @@
1 1
 package sg
2 2
 
3
-// #include <stdio.h>
4
-// #include <stdlib.h>
5 3
 import "C"
6
-
7 4
 import (
8 5
 	"archive/zip"
9 6
 	"bytes"
@@ -23,7 +20,7 @@ import (
23 20
 	"net/http"
24 21
 	"os"
25 22
 	"path/filepath"
26
-	//"runtime/cgo"
23
+	_ "runtime/cgo"
27 24
 	"strconv"
28 25
 	"strings"
29 26
 	"syscall"
@@ -58,8 +55,8 @@ func HisManagerApiRegistRouters() {
58 55
 }
59 56
 
60 57
 var (
61
-	str  = make([]*byte, 1024)
62
-	str1 = make([]*byte, 1024)
58
+	str  = make([]byte, 0)
59
+	str1 = make([]byte, 0)
63 60
 )
64 61
 
65 62
 func (c *HisApiController) TestPay() {
@@ -78,8 +75,15 @@ func (c *HisApiController) TestPay() {
78 75
 
79 76
 func (c *HisApiController) TestGetBasBaseInfo() {
80 77
 
81
-	cs1 := C.CString("")
82
-	cs2 := C.CString("")
78
+	//result := C.Init(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
79
+	//fmt.Println(result)
80
+	//cs1 := C.CString("")
81
+	//cs2 := C.CString("")
82
+	//C.ReadCardBas(cs1, IntPtr(1024), cs2, IntPtr(1024))
83
+	//fmt.Println(cs1)
84
+	//fmt.Println(cs2)
85
+	//C.free(unsafe.Pointer(cs1))
86
+	//C.free(unsafe.Pointer(cs2))
83 87
 
84 88
 	//
85 89
 	DllDef := syscall.MustLoadDLL("SSCard.dll")
@@ -96,20 +100,20 @@ func (c *HisApiController) TestGetBasBaseInfo() {
96 100
 	result := int(ret)
97 101
 	fmt.Println("SSCard的运算结果为1:", result)
98 102
 
99
-	ret2, _, err2 := readCard.Call((uintptr)(unsafe.Pointer(&cs1)), IntPtr(1024), (uintptr)(unsafe.Pointer(&cs2)), IntPtr(1024))
103
+	path := ""
104
+	bytePath := []byte(path + "\x00")
105
+	bytePath2 := []byte(path + "\x00")
106
+
107
+	ret2, _, err2 := readCard.Call((uintptr)(unsafe.Pointer(&bytePath[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&bytePath2[0])), IntPtr(1024))
100 108
 	fmt.Println(" Add(4,5)的结果为:", ret2)
101
-	fmt.Println(" str:", cs1)
102
-	fmt.Println(" str1:", cs2)
109
+	fmt.Println(" str:", bytePath)
110
+	fmt.Println(" str1:", bytePath2)
103 111
 	if err2 != nil {
104 112
 		fmt.Println("SSCard的运算结果为:", ret2)
105 113
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
106 114
 		return
107 115
 	}
108 116
 
109
-	C.free(unsafe.Pointer(cs1))
110
-	C.free(unsafe.Pointer(cs2))
111
-
112
-	//
113 117
 }
114 118
 
115 119
 func (c *HisApiController) GetOrgInfo() {