初始化
This commit is contained in:
commit
b0adf3aa49
|
|
@ -0,0 +1 @@
|
|||
/logs/*.log
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Datasource local storage ignored files
|
||||
/../../../../../../:\Code\old\deesCloud\deescloud\.idea/dataSources/
|
||||
/dataSources.local.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/deescloud.iml" filepath="$PROJECT_DIR$/.idea/deescloud.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package ModulePath
|
||||
|
||||
import (
|
||||
// "errors"
|
||||
// "fmt"
|
||||
"os"
|
||||
// "os/exec"
|
||||
"path/filepath"
|
||||
// "strings"
|
||||
)
|
||||
|
||||
func GetModuleCurrentPath() (string, error) {
|
||||
|
||||
file, err := os.Executable()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
exPath := filepath.Dir(file)
|
||||
return exPath, nil
|
||||
|
||||
/*file, err := exec.LookPath(os.Args[0])
|
||||
if err != nil {
|
||||
fmt.Println("lookpath err:", err.Error())
|
||||
return "", err
|
||||
}
|
||||
path, err := filepath.Abs(file)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
i := strings.LastIndex(path, "/")
|
||||
if i < 0 {
|
||||
i = strings.LastIndex(path, "\\")
|
||||
}
|
||||
if i < 0 {
|
||||
return "", errors.New(`error: Can't find "/" or "\".`)
|
||||
}
|
||||
return string(path[0 : i+1]), nil*/
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,5 @@
|
|||
server = 127.0.0.1
|
||||
port = 1433
|
||||
user = sa
|
||||
password = lh123456
|
||||
database = WellNameInformation
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
package main
|
||||
|
||||
type Dev_manage struct {
|
||||
ID int `json:"id"`
|
||||
Wellname string `json:"wellname"`
|
||||
Sid string `json:"sid"`
|
||||
Iid string `json:"iid"`
|
||||
Ver string `json:"ver"`
|
||||
P_date string `json:"p_date"`
|
||||
Cal_date string `json:"cal_date"`
|
||||
Total_wt string `json:"total_wt"`
|
||||
Cur_wt string `json:"cur_wt"`
|
||||
Repair_cnt string `json:"repair_cnt"`
|
||||
Region string `json:"region"`
|
||||
Location string `json:"location"`
|
||||
Responsible string `json:"responsible"`
|
||||
Flag bool `json:"flag"`
|
||||
}
|
||||
|
||||
// type Tool_warning struct {
|
||||
// Time string `json:"time"`
|
||||
// Err_level string `json:"err_level"`
|
||||
// Context string `json:"context"`
|
||||
// }
|
||||
|
||||
type Tool_warning struct {
|
||||
Time string `json:"time"`
|
||||
Err_level string `json:"err_level"`
|
||||
Series string `json:"series_num"`
|
||||
Instrument string `json:"instrument_id"`
|
||||
Context string `json:"context"`
|
||||
Flag int `json:"flag"`
|
||||
}
|
||||
|
||||
type Srr_event struct {
|
||||
Bt string `json:"bt"`
|
||||
Et string `json:"et"`
|
||||
Event_name string `json:"ename"`
|
||||
}
|
||||
|
||||
type Srr_state struct {
|
||||
Bt string `json:"bt"`
|
||||
Et string `json:"et"`
|
||||
Servicer string `json:"servicer"`
|
||||
State string `json:"state"`
|
||||
Drilling_time string `json:"drilling_time"`
|
||||
}
|
||||
|
||||
type Cmr struct {
|
||||
Wellname string `json:"wellname"`
|
||||
Upload_user string `json:"upload_user"`
|
||||
|
||||
//------------------------------------------------------------//
|
||||
Total_work_time string `json:"Total_work_time"`
|
||||
Total_wait_time string `json:"Total_wait_time"`
|
||||
Well_captain string `json:"well_captain"`
|
||||
Safety_officer_name string `json:"safety_officer_name"`
|
||||
Safety_officer_phone string `json:"safety_officer_phone"`
|
||||
Hosp_phone string `json:"hosp_phone"`
|
||||
Fire_phone string `json:"fire_phone"`
|
||||
Police_phone string `json:"police_phone"`
|
||||
Lon_lat string `json:"lon_lat"`
|
||||
Gl string `json:"gl"` //地理位置
|
||||
Device_data []Device `json:"Device_data"`
|
||||
|
||||
Well_device string `json:"well_device"`
|
||||
|
||||
//设计数据
|
||||
X string `json:"x"`
|
||||
Y string `json:"y"`
|
||||
Declination string `json:"declination"`
|
||||
DIP string `json:"DIP"`
|
||||
MT string `json:"MT"`
|
||||
CLsA string `json:"CLsA"` //设计闭合方位
|
||||
TVD string `json:"TVD"` //设计垂深
|
||||
Design_depth string `json:"design_depth"` //设计最大井深
|
||||
Design_deviation string `json:"design_deviation"` //设计最大井斜
|
||||
Design_hlength string `json:"design_hlength"` //设计水平段长度
|
||||
|
||||
//地质信息
|
||||
Target_stratum string `json:"Target_stratum"` //目的层
|
||||
Reservoir_thickness string `json:"Reservoir_thickness"` //储层厚度
|
||||
Gamma_range string `json:"Gamma_range"` //伽马范围
|
||||
CHFR string `json:"CHFR"` //地层电阻率
|
||||
|
||||
//钻次
|
||||
Drilling_data []Drilling `json:"Drilling_data"`
|
||||
|
||||
//工况信息
|
||||
Max_depth string `json:"Max_depth"`
|
||||
T1 string `json:"t1"`
|
||||
Max_tvd string `json:"Max_tvd"`
|
||||
T2 string `json:"t2"`
|
||||
Max_temp float32 `json:"Max_temp"`
|
||||
T3 string `json:"t3"`
|
||||
Max_vibrate string `json:"Max_vibrate"` //最大振动
|
||||
T4 string `json:"t4"`
|
||||
|
||||
Next_state string `json:"next_state"` //下一步工况
|
||||
|
||||
//完钻信息
|
||||
Hlength string `json:"Hlength"` //实际水平段长度
|
||||
Tool_work_time string `json:"Tool_work_time"`
|
||||
Total_footage string `json:"Total_footage"`
|
||||
Rate string `json:"Rate"`
|
||||
|
||||
Well_report string `json:"well_report"` //完井总结
|
||||
|
||||
//参考信息
|
||||
IP string `json:"IP"`
|
||||
IP_addr string `json:"IP_addr"`
|
||||
Refer_Drilling_data []Drilling `json:"Refer_Drilling_data"`
|
||||
}
|
||||
|
||||
type Device struct {
|
||||
Location string `json:"Location"`
|
||||
Director string `json:"Director"`
|
||||
Sid string `json:"sid"`
|
||||
Iid string `json:"iid"`
|
||||
Accrued_work_time string `json:"Accrued_work_time"` //出场累计工时
|
||||
}
|
||||
|
||||
type Drilling struct {
|
||||
Drilling_num string `json:"Drilling_num"` //钻次
|
||||
Servicer string `json:"Servicer"`
|
||||
BHA string `json:"BHA"` //钻具组合
|
||||
ToolCombination string `json:"ToolCombination"` //仪器组合
|
||||
Wait_time string `json:"Wait_time"`
|
||||
Work_time string `json:"Work_time"`
|
||||
Reason string `json:"Reason"`
|
||||
In_depth string `json:"In_depth"`
|
||||
Out_depth string `json:"Out_depth"`
|
||||
Footage string `json:"Footage"`
|
||||
Next_step string `json:"Next_step"`
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,24 @@
|
|||
module deescloud
|
||||
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
github.com/LukeMauldin/lodbc v0.0.0-20130219161755-59316a7de9d4 // indirect
|
||||
github.com/OwnLocal/goes v1.0.0 // indirect
|
||||
github.com/alexbrainman/odbc v0.0.0-20210605012845-39f8520b0d5f // indirect
|
||||
github.com/astaxie/beego v1.12.3
|
||||
github.com/denisenkom/go-mssqldb v0.11.0 // indirect
|
||||
github.com/go-ole/go-ole v1.2.6 // indirect
|
||||
github.com/lionsoul2014/ip2region/binding/golang v0.0.0-20230415042440-a5e3d8259ae0 // indirect
|
||||
github.com/mattn/go-adodb v0.0.1
|
||||
github.com/mattn/go-sqlite3 v2.0.3+incompatible
|
||||
github.com/satori/go.uuid v1.2.0
|
||||
github.com/shopspring/decimal v1.3.1 // indirect
|
||||
github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726 // indirect
|
||||
github.com/siddontang/ledisdb v0.0.0-20181029004158-becf5f38d373 // indirect
|
||||
github.com/signintech/gopdf v0.17.1 // indirect
|
||||
github.com/tealeg/xlsx v1.0.5 // indirect
|
||||
github.com/weigj/go-odbc v0.0.0-20120414035027-f09eefba7e19 // indirect
|
||||
gitlab.com/stone.code/odbc3-go v0.0.0-20140130212748-f9bdfa0350f2 // indirect
|
||||
golang.org/x/net v0.0.0-20211020060615-d418f374d309
|
||||
)
|
||||
|
|
@ -0,0 +1,215 @@
|
|||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
|
||||
github.com/LukeMauldin/lodbc v0.0.0-20130219161755-59316a7de9d4 h1:MNptLl+J1e/11fmvv5sC47Kc6pJh336HGhEa4ga81IQ=
|
||||
github.com/LukeMauldin/lodbc v0.0.0-20130219161755-59316a7de9d4/go.mod h1:wVRoKWzJl1ZecJg0GW+iCvOyWUHSE87uCCxWaF9WMzw=
|
||||
github.com/OwnLocal/goes v1.0.0/go.mod h1:8rIFjBGTue3lCU0wplczcUgt9Gxgrkkrw7etMIcn8TM=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alexbrainman/odbc v0.0.0-20210605012845-39f8520b0d5f h1:qJp6jWdG+PBNCDtIwRpspahMaZ3hlfde/25ExBORKso=
|
||||
github.com/alexbrainman/odbc v0.0.0-20210605012845-39f8520b0d5f/go.mod h1:c5eyz5amZqTKvY3ipqerFO/74a/8CYmXOahSr40c+Ww=
|
||||
github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
|
||||
github.com/alicebob/miniredis v2.5.0+incompatible/go.mod h1:8HZjEj4yU0dwhYHky+DxYx+6BMjkBbe5ONFIF1MXffk=
|
||||
github.com/astaxie/beego v1.12.3 h1:SAQkdD2ePye+v8Gn1r4X6IKZM1wd28EyUOVQ3PDSOOQ=
|
||||
github.com/astaxie/beego v1.12.3/go.mod h1:p3qIm0Ryx7zeBHLljmd7omloyca1s4yu1a8kM1FkpIA=
|
||||
github.com/beego/goyaml2 v0.0.0-20130207012346-5545475820dd/go.mod h1:1b+Y/CofkYwXMUU0OhQqGvsY2Bvgr4j6jfT699wyZKQ=
|
||||
github.com/beego/x2j v0.0.0-20131220205130-a0352aadc542/go.mod h1:kSeGC/p1AbBiEp5kat81+DSQrZenVBZXklMLaELspWU=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bradfitz/gomemcache v0.0.0-20180710155616-bc664df96737/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60=
|
||||
github.com/casbin/casbin v1.7.0/go.mod h1:c67qKN6Oum3UF5Q1+BByfFxkwKvhwW57ITjqwtzR1KE=
|
||||
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80=
|
||||
github.com/couchbase/go-couchbase v0.0.0-20200519150804-63f3cdb75e0d/go.mod h1:TWI8EKQMs5u5jLKW/tsb9VwauIrMIxQG1r5fMsswK5U=
|
||||
github.com/couchbase/gomemcached v0.0.0-20200526233749-ec430f949808/go.mod h1:srVSlQLB8iXBVXHgnqemxUXqN6FCvClgCMPCsjBDR7c=
|
||||
github.com/couchbase/goutils v0.0.0-20180530154633-e865a1461c8a/go.mod h1:BQwMFlJzDjFDG3DJUdU0KORxn88UlsOULuxLExMh3Hs=
|
||||
github.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76/go.mod h1:vYwsqCOLxGiisLwp9rITslkFNpZD5rz43tf41QFkTWY=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/denisenkom/go-mssqldb v0.11.0 h1:9rHa233rhdOyrz2GcP9NM+gi2psgJZ4GWDpL/7ND8HI=
|
||||
github.com/denisenkom/go-mssqldb v0.11.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
|
||||
github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
|
||||
github.com/elastic/go-elasticsearch/v6 v6.8.5/go.mod h1:UwaDJsD3rWLM5rKNFzv9hgox93HoX8utj1kxD9aFUcI=
|
||||
github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/glendc/gopher-json v0.0.0-20170414221815-dc4743023d0c/go.mod h1:Gja1A+xZ9BoviGJNA2E9vFkPjjsl+CoJxSXiQM1UXtw=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
||||
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
|
||||
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
||||
github.com/go-redis/redis v6.14.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
|
||||
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
|
||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
|
||||
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/ledisdb/ledisdb v0.0.0-20200510135210-d35789ec47e6/go.mod h1:n931TsDuKuq+uX4v1fulaMbA/7ZLLhjc85h7chZGBCQ=
|
||||
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lionsoul2014/ip2region/binding/golang v0.0.0-20230415042440-a5e3d8259ae0 h1:LgmjED/yQILqmUED4GaXjrINWe7YJh4HM6z2EvEINPs=
|
||||
github.com/lionsoul2014/ip2region/binding/golang v0.0.0-20230415042440-a5e3d8259ae0/go.mod h1:C5LA5UO2ZXJrLaPLYtE1wUJMiyd/nwWaCO5cw/2pSHs=
|
||||
github.com/mattn/go-adodb v0.0.1 h1:g/pk3V8m/WFX2IQRI58wAC24OQUFFXEiNsvs7dQ1WKg=
|
||||
github.com/mattn/go-adodb v0.0.1/go.mod h1:jaSTRde4bohMuQgYQPxW3xRTPtX/cZKyxPrFVseJULo=
|
||||
github.com/mattn/go-sqlite3 v1.14.9 h1:10HX2Td0ocZpYEjhilsuo6WWtUqttj2Kb0KtD86/KYA=
|
||||
github.com/mattn/go-sqlite3 v1.14.9/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||
github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U=
|
||||
github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/pelletier/go-toml v1.0.1/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/peterh/liner v1.0.1-0.20171122030339-3681c2a91233/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc=
|
||||
github.com/phpdave11/gofpdi v1.0.14-0.20211212211723-1f10f9844311 h1:zyWXQ6vu27ETMpYsEMAsisQ+GqJ4e1TPvSNfdOPF0no=
|
||||
github.com/phpdave11/gofpdi v1.0.14-0.20211212211723-1f10f9844311/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||
github.com/prometheus/client_golang v1.7.0 h1:wCi7urQOGBsYcQROHqpUUX4ct84xp40t9R9JX0FuA/U=
|
||||
github.com/prometheus/client_golang v1.7.0/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
|
||||
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.10.0 h1:RyRA7RzGXQZiW+tGMr7sxa85G1z0yOpM1qq5c8lNawc=
|
||||
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8=
|
||||
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
|
||||
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
|
||||
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
|
||||
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 h1:X+yvsM2yrEktyI+b2qND5gpH8YhURn0k8OCaeRnkINo=
|
||||
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg=
|
||||
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
|
||||
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
||||
github.com/siddontang/go v0.0.0-20170517070808-cb568a3e5cc0/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=
|
||||
github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=
|
||||
github.com/siddontang/goredis v0.0.0-20150324035039-760763f78400/go.mod h1:DDcKzU3qCuvj/tPnimWSsZZzvk9qvkvrIL5naVBPh5s=
|
||||
github.com/siddontang/ledisdb v0.0.0-20181029004158-becf5f38d373/go.mod h1:mF1DpOSOUiJRMR+FDqaqu3EBqrybQtrDDszLUZ6oxPg=
|
||||
github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA=
|
||||
github.com/signintech/gopdf v0.17.1 h1:7g1JCz5XtdyARU3DmGcsyO/eRWM5C2KXGFQ/9+pUCOM=
|
||||
github.com/signintech/gopdf v0.17.1/go.mod h1:wrLtZoWaRNrS4hphED0oflFoa6IWkOu6M3nJjm4VbO4=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXctz3kmljlUCu/yB3GZ6oee+dUozsezQE=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/syndtr/goleveldb v0.0.0-20160425020131-cfa635847112/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
|
||||
github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
|
||||
github.com/tealeg/xlsx v1.0.5 h1:+f8oFmvY8Gw1iUXzPk+kz+4GpbDZPK1FhPiQRd+ypgE=
|
||||
github.com/tealeg/xlsx v1.0.5/go.mod h1:btRS8dz54TDnvKNosuAqxrM1QgN1udgk9O34bDCnORM=
|
||||
github.com/ugorji/go v0.0.0-20171122102828-84cb69a8af83/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ=
|
||||
github.com/weigj/go-odbc v0.0.0-20120414035027-f09eefba7e19 h1:0n3XLY0QrWER887wlRh9pzd0dmfsYak/WYwXYMEwVso=
|
||||
github.com/weigj/go-odbc v0.0.0-20120414035027-f09eefba7e19/go.mod h1:I2IXPqsCTidAXyoiDDMxw9dTlFyFvpv25SiZl2Xhbnw=
|
||||
github.com/wendal/errors v0.0.0-20130201093226-f66c77a7882b/go.mod h1:Q12BUT7DqIlHRmgv3RskH+UCM/4eqVMgI0EMmlSpAXc=
|
||||
github.com/yookoala/realpath v1.0.0/go.mod h1:gJJMA9wuX7AcqLy1+ffPatSCySA1FQ2S8Ya9AIoYBpE=
|
||||
github.com/yuin/gopher-lua v0.0.0-20171031051903-609c9cd26973/go.mod h1:aEV29XrmTYFr3CiRxZeGHpkvbwq+prZduBqMaascyCU=
|
||||
gitlab.com/stone.code/odbc3-go v0.0.0-20140130212748-f9bdfa0350f2 h1:euSt1+U+70sxHwOIiKaUthbzkuSWYDwDBO2FzK+6qec=
|
||||
gitlab.com/stone.code/odbc3-go v0.0.0-20140130212748-f9bdfa0350f2/go.mod h1:susDFwJTAkX5t89LhGIcv/+3ZXIPZCkpAg0s5QkoPw4=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20211020060615-d418f374d309 h1:A0lJIi+hcTR6aajJH4YqKWwohY4aW9RO7oRMcdv+HKI=
|
||||
golang.org/x/net v0.0.0-20211020060615-d418f374d309/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
Binary file not shown.
|
|
@ -0,0 +1,24 @@
|
|||
Copyright 2011 Wei guangjing. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
ODBC database driver for Go
|
||||
|
||||
Install:
|
||||
cd $GOPATH/src
|
||||
git clone git://github.com/weigj/go-odbc.git odbc
|
||||
cd odbc
|
||||
go install
|
||||
|
||||
Example:
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"odbc"
|
||||
)
|
||||
|
||||
func main() {
|
||||
conn, _ := odbc.Connect("DSN=dsn;UID=user;PWD=password")
|
||||
stmt, _ := conn.Prepare("select * from user where username = ?")
|
||||
stmt.Execute("admin")
|
||||
rows, _ := stmt.FetchAll()
|
||||
for i, row := range rows {
|
||||
println(i, row)
|
||||
}
|
||||
stmt.Close()
|
||||
conn.Close()
|
||||
}
|
||||
|
||||
Tested on:
|
||||
SQL Server 2005 and Windows 7
|
||||
SQL Server 2005 and Ubuntu 10.4 (UnixODBC+FreeTDS)
|
||||
Oracle 10g and Windows 7
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
// Copyright (c) 2011, Wei guangjing <vcc.163@gmail.com>. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package odbc
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
Driver for database/sql
|
||||
|
||||
Install:
|
||||
go install
|
||||
|
||||
Example:
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
_ "odbc/driver"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
db, err := sql.Open("odbc", "DSN=test;")
|
||||
defer db.Close()
|
||||
|
||||
stmt, err := db.Prepare("select name from table")
|
||||
defer stmt.Close()
|
||||
|
||||
rows, err := stmt.Query()
|
||||
defer rows.Close()
|
||||
|
||||
for rows.Next() {
|
||||
var name string
|
||||
|
||||
_ = rows.Scan(&name)
|
||||
fmt.Println(name)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,159 @@
|
|||
// Copyright (c) 2012, Wei guangjing <vcc.163@gmail.com>. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package driver
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"database/sql/driver"
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
"deescloud/odbc"
|
||||
)
|
||||
|
||||
func init() {
|
||||
d := &Driver{}
|
||||
sql.Register("odbc", d)
|
||||
}
|
||||
|
||||
type Driver struct {
|
||||
}
|
||||
|
||||
func (d *Driver) Open(dsn string) (driver.Conn, error) {
|
||||
c, err := odbc.Connect(dsn)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
conn := &conn{c: c}
|
||||
return conn, nil
|
||||
}
|
||||
|
||||
func (d *Driver) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type conn struct {
|
||||
c *odbc.Connection
|
||||
t *tx
|
||||
}
|
||||
|
||||
func (c *conn) Prepare(query string) (driver.Stmt, error) {
|
||||
st, err := c.c.Prepare(query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
stmt := &stmt{st: st}
|
||||
return stmt, nil
|
||||
}
|
||||
|
||||
func (c *conn) Begin() (driver.Tx, error) {
|
||||
if err := c.c.AutoCommit(false); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &tx{c: c}, nil
|
||||
}
|
||||
|
||||
func (c *conn) Close() error {
|
||||
if c.c != nil {
|
||||
return c.c.Close()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type tx struct {
|
||||
c *conn
|
||||
}
|
||||
|
||||
func (t *tx) Commit() error {
|
||||
err := t.c.c.Commit()
|
||||
return err
|
||||
}
|
||||
|
||||
func (t *tx) Rollback() error {
|
||||
err := t.c.c.Rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
type stmt struct {
|
||||
st *odbc.Statement
|
||||
}
|
||||
|
||||
func (s *stmt) Exec(args []driver.Value) (driver.Result, error) {
|
||||
if err := s.st.Execute2(args); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rowsAffected, err := s.st.RowsAffected()
|
||||
r := &result{rowsAffected: int64(rowsAffected)}
|
||||
return r, err
|
||||
}
|
||||
|
||||
func (s *stmt) NumInput() int {
|
||||
return s.st.NumParams()
|
||||
}
|
||||
|
||||
func (s *stmt) Query(args []driver.Value) (driver.Rows, error) {
|
||||
//println(args)
|
||||
if err := s.st.Execute2(args); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rows := &rows{s: s}
|
||||
|
||||
return rows, nil
|
||||
}
|
||||
|
||||
func (s *stmt) Close() error {
|
||||
s.st.Close()
|
||||
return nil
|
||||
}
|
||||
|
||||
type result struct {
|
||||
rowsAffected int64
|
||||
}
|
||||
|
||||
func (r *result) LastInsertId() (int64, error) {
|
||||
return 0, errors.New("not supported")
|
||||
}
|
||||
|
||||
func (r *result) RowsAffected() (int64, error) {
|
||||
return r.rowsAffected, nil
|
||||
}
|
||||
|
||||
type rows struct {
|
||||
s *stmt
|
||||
}
|
||||
|
||||
func (r *rows) Columns() []string {
|
||||
c, err := r.s.st.NumFields()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
columns := make([]string, c)
|
||||
for i, _ := range columns {
|
||||
f, err := r.s.st.FieldMetadata(i + 1)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
columns[i] = f.Name
|
||||
}
|
||||
return columns
|
||||
}
|
||||
|
||||
func (r *rows) Close() error {
|
||||
return r.s.Close()
|
||||
}
|
||||
|
||||
func (r *rows) Next(dest []driver.Value) error {
|
||||
eof, err := r.s.st.FetchOne2(dest)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if eof {
|
||||
return io.EOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
|
||||
export CGO_LDFLAGS=-lodbc
|
||||
go install
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
set CGO_LDFLAGS=-lodbc32
|
||||
go install
|
||||
|
|
@ -0,0 +1,765 @@
|
|||
// Copyright (c) 2011, Wei guangjing <vcc.163@gmail.com>. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package odbc
|
||||
|
||||
/*
|
||||
#cgo darwin LDFLAGS: -lodbc
|
||||
#cgo freebsd LDFLAGS: -lodbc
|
||||
#cgo linux LDFLAGS: -lodbc
|
||||
#cgo windows LDFLAGS: -lodbc32
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#include <windef.h>
|
||||
#else
|
||||
typedef void* HANDLE;
|
||||
#endif
|
||||
|
||||
#include <sql.h>
|
||||
#include <sqlext.h>
|
||||
#include <sqltypes.h>
|
||||
|
||||
SQLRETURN _SQLColAttribute (
|
||||
SQLHSTMT StatementHandle,
|
||||
SQLUSMALLINT ColumnNumber,
|
||||
SQLUSMALLINT FieldIdentifier,
|
||||
SQLPOINTER CharacterAttributePtr,
|
||||
SQLSMALLINT BufferLength,
|
||||
SQLSMALLINT * StringLengthPtr,
|
||||
void * NumericAttributePtr) {
|
||||
return SQLColAttribute(StatementHandle,
|
||||
ColumnNumber,
|
||||
FieldIdentifier,
|
||||
CharacterAttributePtr,
|
||||
BufferLength,
|
||||
StringLengthPtr,
|
||||
NumericAttributePtr);
|
||||
}
|
||||
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"time"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
BUFFER_SIZE = 10 * 1024
|
||||
INFO_BUFFER_LEN = 256
|
||||
)
|
||||
|
||||
var (
|
||||
Genv C.SQLHANDLE
|
||||
)
|
||||
|
||||
type Connection struct {
|
||||
Dbc C.SQLHANDLE
|
||||
connected bool
|
||||
}
|
||||
|
||||
type Statement struct {
|
||||
executed bool
|
||||
prepared bool
|
||||
scrollable bool
|
||||
|
||||
handle C.SQLHANDLE
|
||||
}
|
||||
|
||||
type ODBCError struct {
|
||||
SQLState string
|
||||
NativeError int
|
||||
ErrorMessage string
|
||||
}
|
||||
|
||||
func (e *ODBCError) Error() string {
|
||||
return e.String()
|
||||
}
|
||||
|
||||
func (e *ODBCError) String() string {
|
||||
if e != nil {
|
||||
return e.SQLState + " " + e.ErrorMessage
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func initEnv() (err *ODBCError) {
|
||||
ret := C.SQLAllocHandle(C.SQL_HANDLE_ENV, nil, &Genv)
|
||||
if !Success(ret) {
|
||||
err := FormatError(C.SQL_HANDLE_ENV, Genv)
|
||||
return err
|
||||
}
|
||||
ret = C.SQLSetEnvAttr(C.SQLHENV(Genv), C.SQL_ATTR_ODBC_VERSION, C.SQLPOINTER(unsafe.Pointer(uintptr(C.SQL_OV_ODBC3))), C.SQLINTEGER(0))
|
||||
if !Success(ret) {
|
||||
err := FormatError(C.SQL_HANDLE_ENV, Genv)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Connect(dsn string, params ...interface{}) (conn *Connection, err *ODBCError) {
|
||||
var h C.SQLHANDLE
|
||||
ret := C.SQLAllocHandle(C.SQL_HANDLE_DBC, Genv, &h)
|
||||
if !Success(ret) {
|
||||
err := FormatError(C.SQL_HANDLE_DBC, h)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var stringLength2 C.SQLSMALLINT
|
||||
outBuf := make([]byte, BUFFER_SIZE*2)
|
||||
outConnectionString := (*C.SQLWCHAR)(unsafe.Pointer(&outBuf[0]))
|
||||
|
||||
ret = C.SQLDriverConnectW(C.SQLHDBC(h),
|
||||
C.SQLHWND(unsafe.Pointer(uintptr(0))),
|
||||
(*C.SQLWCHAR)(unsafe.Pointer(StringToUTF16Ptr(dsn))),
|
||||
C.SQL_NTS,
|
||||
outConnectionString,
|
||||
BUFFER_SIZE,
|
||||
&stringLength2,
|
||||
C.SQL_DRIVER_NOPROMPT)
|
||||
|
||||
if !Success(ret) {
|
||||
err := FormatError(C.SQL_HANDLE_DBC, h)
|
||||
return nil, err
|
||||
}
|
||||
return &Connection{Dbc: h, connected: true}, nil
|
||||
}
|
||||
|
||||
func (conn *Connection) ExecDirect(sql string) (stmt *Statement, err *ODBCError) {
|
||||
if stmt, err = conn.newStmt(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
wsql := StringToUTF16Ptr(sql)
|
||||
ret := C.SQLExecDirectW(C.SQLHSTMT(stmt.handle), (*C.SQLWCHAR)(unsafe.Pointer(wsql)), C.SQL_NTS)
|
||||
if !Success(ret) {
|
||||
err := FormatError(C.SQL_HANDLE_STMT, stmt.handle)
|
||||
stmt.Close()
|
||||
return nil, err
|
||||
}
|
||||
stmt.executed = true
|
||||
return stmt, nil
|
||||
}
|
||||
|
||||
func (conn *Connection) newStmt() (*Statement, *ODBCError) {
|
||||
stmt := &Statement{}
|
||||
|
||||
ret := C.SQLAllocHandle(C.SQL_HANDLE_STMT, conn.Dbc, &stmt.handle)
|
||||
if !Success(ret) {
|
||||
err := FormatError(C.SQL_HANDLE_DBC, conn.Dbc)
|
||||
return nil, err
|
||||
}
|
||||
return stmt, nil
|
||||
}
|
||||
|
||||
func (conn *Connection) Prepare(sql string, params ...interface{}) (*Statement, *ODBCError) {
|
||||
wsql := StringToUTF16Ptr(sql)
|
||||
stmt, err := conn.newStmt()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := C.SQLPrepareW(C.SQLHSTMT(stmt.handle), (*C.SQLWCHAR)(unsafe.Pointer(wsql)), C.SQLINTEGER(len(sql)))
|
||||
if !Success(ret) {
|
||||
err := FormatError(C.SQL_HANDLE_STMT, stmt.handle)
|
||||
stmt.Close()
|
||||
return nil, err
|
||||
}
|
||||
stmt.prepared = true
|
||||
return stmt, nil
|
||||
}
|
||||
|
||||
func (conn *Connection) Commit() (err *ODBCError) {
|
||||
ret := C.SQLEndTran(C.SQL_HANDLE_DBC, conn.Dbc, C.SQL_COMMIT)
|
||||
if !Success(ret) {
|
||||
err = FormatError(C.SQL_HANDLE_DBC, conn.Dbc)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (conn *Connection) AutoCommit(b bool) (err *ODBCError) {
|
||||
var n C.int
|
||||
if b {
|
||||
n = C.SQL_AUTOCOMMIT_ON
|
||||
} else {
|
||||
n = C.SQL_AUTOCOMMIT_OFF
|
||||
}
|
||||
ret := C.SQLSetConnectAttr(C.SQLHDBC(conn.Dbc), C.SQL_ATTR_AUTOCOMMIT, C.SQLPOINTER(unsafe.Pointer(uintptr(n))), C.SQL_IS_UINTEGER)
|
||||
if !Success(ret) {
|
||||
err = FormatError(C.SQL_HANDLE_DBC, conn.Dbc)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (conn *Connection) BeginTransaction() (err *ODBCError) {
|
||||
ret := C.SQLSetConnectAttr(C.SQLHDBC(conn.Dbc), C.SQL_ATTR_AUTOCOMMIT, C.SQLPOINTER(unsafe.Pointer(uintptr(C.SQL_AUTOCOMMIT_OFF))), C.SQL_IS_UINTEGER)
|
||||
if !Success(ret) {
|
||||
err = FormatError(C.SQL_HANDLE_DBC, conn.Dbc)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (conn *Connection) Rollback() (err *ODBCError) {
|
||||
ret := C.SQLEndTran(C.SQL_HANDLE_DBC, conn.Dbc, C.SQL_ROLLBACK)
|
||||
if !Success(ret) {
|
||||
err = FormatError(C.SQL_HANDLE_DBC, conn.Dbc)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (conn *Connection) ServerInfo() (string, string, string, *ODBCError) {
|
||||
var info_len C.SQLSMALLINT
|
||||
p := make([]byte, INFO_BUFFER_LEN)
|
||||
ret := C.SQLGetInfo(C.SQLHDBC(conn.Dbc), C.SQL_DATABASE_NAME, C.SQLPOINTER(unsafe.Pointer(&p[0])), INFO_BUFFER_LEN, &info_len)
|
||||
if !Success(ret) {
|
||||
err := FormatError(C.SQL_HANDLE_DBC, conn.Dbc)
|
||||
return "", "", "", err
|
||||
}
|
||||
db := string(p[0:info_len])
|
||||
ret = C.SQLGetInfo(C.SQLHDBC(conn.Dbc), C.SQL_DBMS_VER, C.SQLPOINTER(unsafe.Pointer(&p[0])), INFO_BUFFER_LEN, &info_len)
|
||||
if !Success(ret) {
|
||||
err := FormatError(C.SQL_HANDLE_DBC, conn.Dbc)
|
||||
return db, "", "", err
|
||||
}
|
||||
ver := string(p[0:info_len])
|
||||
ret = C.SQLGetInfo(C.SQLHDBC(conn.Dbc), C.SQL_SERVER_NAME, C.SQLPOINTER(unsafe.Pointer(&p[0])), INFO_BUFFER_LEN, &info_len)
|
||||
if !Success(ret) {
|
||||
err := FormatError(C.SQL_HANDLE_DBC, conn.Dbc)
|
||||
return db, ver, "", err
|
||||
}
|
||||
server := string(p[0:info_len])
|
||||
return db, ver, server, nil
|
||||
}
|
||||
|
||||
func (conn *Connection) ClientInfo() (string, string, string, *ODBCError) {
|
||||
var info_len C.SQLSMALLINT
|
||||
p := make([]byte, INFO_BUFFER_LEN)
|
||||
ret := C.SQLGetInfo(C.SQLHDBC(conn.Dbc), C.SQL_DRIVER_NAME, C.SQLPOINTER(unsafe.Pointer(&p[0])), INFO_BUFFER_LEN, &info_len)
|
||||
if !Success(ret) {
|
||||
err := FormatError(C.SQL_HANDLE_DBC, conn.Dbc)
|
||||
return "", "", "", err
|
||||
}
|
||||
drv_name := string(p[0:info_len])
|
||||
ret = C.SQLGetInfo(C.SQLHDBC(conn.Dbc), C.SQL_DRIVER_ODBC_VER, C.SQLPOINTER(unsafe.Pointer(&p[0])), INFO_BUFFER_LEN, &info_len)
|
||||
if !Success(ret) {
|
||||
err := FormatError(C.SQL_HANDLE_DBC, conn.Dbc)
|
||||
return "", "", "", err
|
||||
}
|
||||
drv_odbc_ver := string(p[0:info_len])
|
||||
ret = C.SQLGetInfo(C.SQLHDBC(conn.Dbc), C.SQL_DRIVER_VER, C.SQLPOINTER(unsafe.Pointer(&p[0])), INFO_BUFFER_LEN, &info_len)
|
||||
if !Success(ret) {
|
||||
err := FormatError(C.SQL_HANDLE_DBC, conn.Dbc)
|
||||
return "", "", "", err
|
||||
}
|
||||
drv_ver := string(p[0:info_len])
|
||||
return drv_name, drv_odbc_ver, drv_ver, nil
|
||||
}
|
||||
|
||||
func (conn *Connection) Close() *ODBCError {
|
||||
if conn.connected {
|
||||
ret := C.SQLDisconnect(C.SQLHDBC(conn.Dbc))
|
||||
if !Success(ret) {
|
||||
err := FormatError(C.SQL_HANDLE_DBC, conn.Dbc)
|
||||
return err
|
||||
}
|
||||
ret = C.SQLFreeHandle(C.SQL_HANDLE_DBC, conn.Dbc)
|
||||
if !Success(ret) {
|
||||
err := FormatError(C.SQL_HANDLE_DBC, conn.Dbc)
|
||||
return err
|
||||
}
|
||||
conn.connected = false
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
/* func (stmt *Statement) RowsAffected() (int, *ODBCError)
|
||||
|
||||
修改成func (stmt *Statement) RowsAffected() (int, error)
|
||||
|
||||
*/
|
||||
func (stmt *Statement) RowsAffected() (int, error) {
|
||||
var nor C.SQLLEN
|
||||
ret := C.SQLRowCount(C.SQLHSTMT(stmt.handle), &nor)
|
||||
if !Success(ret) {
|
||||
err := FormatError(C.SQL_HANDLE_STMT, stmt.handle)
|
||||
return -1, err
|
||||
}
|
||||
return int(nor), nil
|
||||
}
|
||||
|
||||
func (stmt *Statement) Cancel() *ODBCError {
|
||||
ret := C.SQLCancel(C.SQLHSTMT(stmt.handle))
|
||||
if !Success(ret) {
|
||||
err := FormatError(C.SQL_HANDLE_STMT, stmt.handle)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (stmt *Statement) NumParams() int {
|
||||
var cParams C.SQLSMALLINT
|
||||
ret := C.SQLNumParams(C.SQLHSTMT(stmt.handle), &cParams)
|
||||
if !Success(ret) {
|
||||
return -1
|
||||
}
|
||||
return int(cParams)
|
||||
}
|
||||
|
||||
func (stmt *Statement) Execute(params ...interface{}) *ODBCError {
|
||||
if params != nil {
|
||||
var cParams C.SQLSMALLINT
|
||||
ret := C.SQLNumParams(C.SQLHSTMT(stmt.handle), &cParams)
|
||||
if !Success(ret) {
|
||||
err := FormatError(C.SQL_HANDLE_STMT, stmt.handle)
|
||||
return err
|
||||
}
|
||||
for i := 0; i < int(cParams); i++ {
|
||||
stmt.BindParam(i+1, params[i])
|
||||
}
|
||||
}
|
||||
ret := C.SQLExecute(C.SQLHSTMT(stmt.handle))
|
||||
if ret == C.SQL_NEED_DATA {
|
||||
// TODO
|
||||
// send_data(stmt)
|
||||
} else if ret == C.SQL_NO_DATA {
|
||||
// Execute NO DATA
|
||||
} else if !Success(ret) {
|
||||
err := FormatError(C.SQL_HANDLE_STMT, stmt.handle)
|
||||
return err
|
||||
}
|
||||
stmt.executed = true
|
||||
return nil
|
||||
}
|
||||
|
||||
func (stmt *Statement) Execute2(params []driver.Value) *ODBCError {
|
||||
if params != nil {
|
||||
var cParams C.SQLSMALLINT
|
||||
ret := C.SQLNumParams(C.SQLHSTMT(stmt.handle), &cParams)
|
||||
if !Success(ret) {
|
||||
err := FormatError(C.SQL_HANDLE_STMT, stmt.handle)
|
||||
return err
|
||||
}
|
||||
for i := 0; i < int(cParams); i++ {
|
||||
stmt.BindParam(i+1, params[i])
|
||||
}
|
||||
}
|
||||
ret := C.SQLExecute(C.SQLHSTMT(stmt.handle))
|
||||
if ret == C.SQL_NEED_DATA {
|
||||
// TODO
|
||||
// send_data(stmt)
|
||||
} else if ret == C.SQL_NO_DATA {
|
||||
// Execute NO DATA
|
||||
} else if !Success(ret) {
|
||||
err := FormatError(C.SQL_HANDLE_STMT, stmt.handle)
|
||||
return err
|
||||
}
|
||||
stmt.executed = true
|
||||
return nil
|
||||
}
|
||||
|
||||
func (stmt *Statement) Fetch() (bool, *ODBCError) {
|
||||
ret := C.SQLFetch(C.SQLHSTMT(stmt.handle))
|
||||
if ret == C.SQL_NO_DATA {
|
||||
return false, nil
|
||||
}
|
||||
if !Success(ret) {
|
||||
err := FormatError(C.SQL_HANDLE_STMT, stmt.handle)
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
type Row struct {
|
||||
Data []interface{}
|
||||
}
|
||||
|
||||
// Get(Columnindex)
|
||||
// TODO Get(ColumnName)
|
||||
func (r *Row) Get(a interface{}) interface{} {
|
||||
value := reflect.ValueOf(a)
|
||||
switch f := value; f.Kind() {
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
return r.Data[f.Int()]
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
|
||||
return r.Data[f.Uint()]
|
||||
// case *reflect.StringValue:
|
||||
// i := r.Meta[f.Get()]
|
||||
// return r.Data[i]
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *Row) GetInt(a interface{}) (ret int64) {
|
||||
v := r.Get(a)
|
||||
value := reflect.ValueOf(v)
|
||||
switch f := value; f.Kind() {
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
ret = int64(f.Int())
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
|
||||
ret = int64(f.Uint())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (r *Row) GetFloat(a interface{}) (ret float64) {
|
||||
v := r.Get(a)
|
||||
value := reflect.ValueOf(v)
|
||||
switch f := value; f.Kind() {
|
||||
case reflect.Float32, reflect.Float64:
|
||||
ret = float64(f.Float())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (r *Row) GetString(a interface{}) (ret string) {
|
||||
v := r.Get(a)
|
||||
value := reflect.ValueOf(v)
|
||||
switch f := value; f.Kind() {
|
||||
case reflect.String:
|
||||
ret = f.String()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (r *Row) Length() int {
|
||||
return len(r.Data)
|
||||
}
|
||||
|
||||
func (stmt *Statement) FetchAll() (rows []*Row, err *ODBCError) {
|
||||
for {
|
||||
row, err := stmt.FetchOne()
|
||||
if err != nil || row == nil {
|
||||
break
|
||||
}
|
||||
rows = append(rows, row)
|
||||
}
|
||||
|
||||
return rows, err
|
||||
}
|
||||
|
||||
func (stmt *Statement) FetchOne() (*Row, *ODBCError) {
|
||||
ok, err := stmt.Fetch()
|
||||
if !ok {
|
||||
return nil, err
|
||||
}
|
||||
n, _ := stmt.NumFields()
|
||||
row := new(Row)
|
||||
row.Data = make([]interface{}, n)
|
||||
for i := 0; i < n; i++ {
|
||||
v, _, _, _ := stmt.GetField(i)
|
||||
row.Data[i] = v
|
||||
}
|
||||
return row, nil
|
||||
}
|
||||
|
||||
func (stmt *Statement) FetchOne2(row []driver.Value) (eof bool, err *ODBCError) {
|
||||
ok, err := stmt.Fetch()
|
||||
if !ok && err == nil {
|
||||
return !ok, nil
|
||||
} else if err != nil {
|
||||
return false, err
|
||||
}
|
||||
n, _ := stmt.NumFields()
|
||||
for i := 0; i < n; i++ {
|
||||
v, _, _, _ := stmt.GetField(i)
|
||||
row[i] = v
|
||||
}
|
||||
|
||||
//fmt.Println("row:", row)
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func (stmt *Statement) GetField(field_index int) (v interface{}, ftype int, flen int, err *ODBCError) {
|
||||
var field_type C.int
|
||||
var field_len C.SQLLEN
|
||||
var ll C.SQLSMALLINT
|
||||
ret := C._SQLColAttribute(C.SQLHSTMT(stmt.handle), C.SQLUSMALLINT(field_index+1), C.SQL_DESC_CONCISE_TYPE, C.SQLPOINTER(unsafe.Pointer(uintptr(0))), C.SQLSMALLINT(0), &ll, unsafe.Pointer(&field_type))
|
||||
if !Success(ret) {
|
||||
// TODO return err
|
||||
}
|
||||
ret = C._SQLColAttribute(C.SQLHSTMT(stmt.handle), C.SQLUSMALLINT(field_index+1), C.SQL_DESC_LENGTH, C.SQLPOINTER(unsafe.Pointer(uintptr(0))), C.SQLSMALLINT(0), &ll, unsafe.Pointer(&field_len))
|
||||
if !Success(ret) {
|
||||
// TODO return err
|
||||
}
|
||||
var fl C.SQLLEN = C.SQLLEN(field_len)
|
||||
switch int(field_type) {
|
||||
case C.SQL_BIT:
|
||||
var value C.BYTE
|
||||
ret = C.SQLGetData(C.SQLHSTMT(stmt.handle), C.SQLUSMALLINT(field_index+1), C.SQL_C_BIT, C.SQLPOINTER(unsafe.Pointer(&value)), 0, &fl)
|
||||
if fl == -1 {
|
||||
v = byte(0)
|
||||
} else {
|
||||
v = byte(value)
|
||||
}
|
||||
case C.SQL_INTEGER, C.SQL_SMALLINT, C.SQL_TINYINT:
|
||||
var value C.long
|
||||
ret = C.SQLGetData(C.SQLHSTMT(stmt.handle), C.SQLUSMALLINT(field_index+1), C.SQL_C_LONG, C.SQLPOINTER(unsafe.Pointer(&value)), 0, &fl)
|
||||
if fl == -1 {
|
||||
v = byte(0)
|
||||
} else {
|
||||
v = int(value)
|
||||
}
|
||||
case C.SQL_BIGINT:
|
||||
var value C.longlong
|
||||
ret = C.SQLGetData(C.SQLHSTMT(stmt.handle), C.SQLUSMALLINT(field_index+1), C.SQL_C_SBIGINT, C.SQLPOINTER(unsafe.Pointer(&value)), 0, &fl)
|
||||
if fl == -1 {
|
||||
v = int64(0)
|
||||
} else {
|
||||
v = int64(value)
|
||||
}
|
||||
case C.SQL_FLOAT, C.SQL_REAL, C.SQL_DOUBLE:
|
||||
var value C.double
|
||||
ret = C.SQLGetData(C.SQLHSTMT(stmt.handle), C.SQLUSMALLINT(field_index+1), C.SQL_C_DOUBLE, C.SQLPOINTER(unsafe.Pointer(&value)), 0, &fl)
|
||||
if fl == -1 {
|
||||
v = float64(0)
|
||||
} else {
|
||||
v = float64(value)
|
||||
}
|
||||
case C.SQL_CHAR, C.SQL_VARCHAR, C.SQL_LONGVARCHAR, C.SQL_WCHAR, C.SQL_WVARCHAR, C.SQL_WLONGVARCHAR:
|
||||
value := make([]uint16, int(field_len)+8)
|
||||
ret = C.SQLGetData(C.SQLHSTMT(stmt.handle), C.SQLUSMALLINT(field_index+1), C.SQL_C_WCHAR, C.SQLPOINTER(unsafe.Pointer(&value[0])), field_len+4, &fl)
|
||||
s := UTF16ToString(value)
|
||||
v = s
|
||||
case C.SQL_TYPE_TIMESTAMP, C.SQL_TYPE_DATE, C.SQL_TYPE_TIME, C.SQL_DATETIME:
|
||||
var value C.TIMESTAMP_STRUCT
|
||||
ret = C.SQLGetData(C.SQLHSTMT(stmt.handle), C.SQLUSMALLINT(field_index+1), C.SQL_C_TYPE_TIMESTAMP, C.SQLPOINTER(unsafe.Pointer(&value)), C.SQLLEN(unsafe.Sizeof(value)), &fl)
|
||||
if fl == -1 {
|
||||
v = nil
|
||||
} else {
|
||||
v = time.Date(int(value.year), time.Month(value.month), int(value.day), int(value.hour), int(value.minute), int(value.second), int(value.fraction), time.UTC)
|
||||
}
|
||||
case C.SQL_BINARY, C.SQL_VARBINARY, C.SQL_LONGVARBINARY:
|
||||
var vv int
|
||||
ret = C.SQLGetData(C.SQLHSTMT(stmt.handle), C.SQLUSMALLINT(field_index+1), C.SQL_C_BINARY, C.SQLPOINTER(unsafe.Pointer(&vv)), 0, &fl)
|
||||
if fl == -1 {
|
||||
v = nil
|
||||
} else {
|
||||
value := make([]byte, fl)
|
||||
ret = C.SQLGetData(C.SQLHSTMT(stmt.handle), C.SQLUSMALLINT(field_index+1), C.SQL_C_BINARY, C.SQLPOINTER(unsafe.Pointer(&value[0])), C.SQLLEN(fl), &fl)
|
||||
v = value
|
||||
}
|
||||
default:
|
||||
value := make([]byte, field_len)
|
||||
ret = C.SQLGetData(C.SQLHSTMT(stmt.handle), C.SQLUSMALLINT(field_index+1), C.SQL_C_BINARY, C.SQLPOINTER(unsafe.Pointer(&value[0])), field_len, &fl)
|
||||
v = value
|
||||
}
|
||||
if !Success(ret) {
|
||||
err = FormatError(C.SQL_HANDLE_STMT, stmt.handle)
|
||||
}
|
||||
return v, int(field_type), int(fl), err
|
||||
}
|
||||
|
||||
func (stmt *Statement) NumFields() (int, *ODBCError) {
|
||||
var NOC C.SQLSMALLINT
|
||||
ret := C.SQLNumResultCols(C.SQLHSTMT(stmt.handle), &NOC)
|
||||
if !Success(ret) {
|
||||
err := FormatError(C.SQL_HANDLE_STMT, stmt.handle)
|
||||
return -1, err
|
||||
}
|
||||
return int(NOC), nil
|
||||
}
|
||||
|
||||
func (stmt *Statement) GetParamType(index int) (int, int, int, int, *ODBCError) {
|
||||
var data_type, dec_ptr, null_ptr C.SQLSMALLINT
|
||||
var size_ptr C.SQLULEN
|
||||
ret := C.SQLDescribeParam(C.SQLHSTMT(stmt.handle), C.SQLUSMALLINT(index), &data_type, &size_ptr, &dec_ptr, &null_ptr)
|
||||
if !Success(ret) {
|
||||
err := FormatError(C.SQL_HANDLE_STMT, stmt.handle)
|
||||
return -1, -1, -1, -1, err
|
||||
}
|
||||
return int(data_type), int(size_ptr), int(dec_ptr), int(null_ptr), nil
|
||||
}
|
||||
|
||||
func (stmt *Statement) BindParam(index int, param interface{}) *ODBCError {
|
||||
var ValueType C.SQLSMALLINT
|
||||
var ParameterType C.SQLSMALLINT
|
||||
var ColumnSize C.SQLULEN
|
||||
var DecimalDigits C.SQLSMALLINT
|
||||
var ParameterValuePtr C.SQLPOINTER
|
||||
var BufferLength C.SQLLEN
|
||||
var StrLen_or_IndPt C.SQLLEN
|
||||
v := reflect.ValueOf(param)
|
||||
if param == nil {
|
||||
ft, _, _, _, err := stmt.GetParamType(index)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ParameterType = C.SQLSMALLINT(ft)
|
||||
if ParameterType == C.SQL_UNKNOWN_TYPE {
|
||||
ParameterType = C.SQL_VARCHAR
|
||||
}
|
||||
ValueType = C.SQL_C_DEFAULT
|
||||
StrLen_or_IndPt = C.SQL_NULL_DATA
|
||||
ColumnSize = 1
|
||||
} else {
|
||||
switch v.Kind() {
|
||||
case reflect.Bool:
|
||||
ParameterType = C.SQL_BIT
|
||||
ValueType = C.SQL_C_BIT
|
||||
var b [1]byte
|
||||
if v.Bool() {
|
||||
b[0] = 1
|
||||
} else {
|
||||
b[0] = 0
|
||||
}
|
||||
ParameterValuePtr = C.SQLPOINTER(unsafe.Pointer(&b[0]))
|
||||
BufferLength = 1
|
||||
StrLen_or_IndPt = 0
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
switch v.Type().Kind() {
|
||||
case reflect.Int:
|
||||
case reflect.Int8, reflect.Int16, reflect.Int32:
|
||||
ParameterType = C.SQL_INTEGER
|
||||
ValueType = C.SQL_C_LONG
|
||||
var l C.long = C.long(v.Int())
|
||||
ParameterValuePtr = C.SQLPOINTER(unsafe.Pointer(&l))
|
||||
BufferLength = 4
|
||||
StrLen_or_IndPt = 0
|
||||
case reflect.Int64:
|
||||
ParameterType = C.SQL_BIGINT
|
||||
ValueType = C.SQL_C_SBIGINT
|
||||
var ll C.longlong = C.longlong(v.Int())
|
||||
ParameterValuePtr = C.SQLPOINTER(unsafe.Pointer(&ll))
|
||||
BufferLength = 8
|
||||
StrLen_or_IndPt = 0
|
||||
}
|
||||
case reflect.Float32, reflect.Float64:
|
||||
ParameterType = C.SQL_DOUBLE
|
||||
ValueType = C.SQL_C_DOUBLE
|
||||
var d C.double = C.double(v.Float())
|
||||
ParameterValuePtr = C.SQLPOINTER(unsafe.Pointer(&d))
|
||||
BufferLength = 8
|
||||
StrLen_or_IndPt = 0
|
||||
case reflect.Complex64, reflect.Complex128:
|
||||
case reflect.String:
|
||||
var slen C.SQLUINTEGER = C.SQLUINTEGER(len(v.String()))
|
||||
ParameterType = C.SQL_VARCHAR
|
||||
ValueType = C.SQL_C_CHAR
|
||||
s := []byte(v.String())
|
||||
ParameterValuePtr = C.SQLPOINTER(unsafe.Pointer(&s[0]))
|
||||
ColumnSize = C.SQLULEN(slen)
|
||||
BufferLength = C.SQLLEN(slen + 1)
|
||||
StrLen_or_IndPt = C.SQLLEN(slen)
|
||||
default:
|
||||
fmt.Println("Not support type", v)
|
||||
}
|
||||
}
|
||||
ret := C.SQLBindParameter(C.SQLHSTMT(stmt.handle), C.SQLUSMALLINT(index), C.SQL_PARAM_INPUT, ValueType, ParameterType, ColumnSize, DecimalDigits, ParameterValuePtr, BufferLength, &StrLen_or_IndPt)
|
||||
if !Success(ret) {
|
||||
err := FormatError(C.SQL_HANDLE_STMT, stmt.handle)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (stmt *Statement) NextResult() bool {
|
||||
ret := C.SQLMoreResults(C.SQLHSTMT(stmt.handle))
|
||||
if ret == C.SQL_NO_DATA {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (stmt *Statement) NumRows() (int, *ODBCError) {
|
||||
var NOR C.SQLLEN
|
||||
ret := C.SQLRowCount(C.SQLHSTMT(stmt.handle), &NOR)
|
||||
if !Success(ret) {
|
||||
err := FormatError(C.SQL_HANDLE_STMT, stmt.handle)
|
||||
return -1, err
|
||||
}
|
||||
return int(NOR), nil
|
||||
}
|
||||
|
||||
func (stmt *Statement) HasRows() bool {
|
||||
n, _ := stmt.NumRows()
|
||||
return n > 0
|
||||
}
|
||||
|
||||
type Field struct {
|
||||
Name string
|
||||
Type int
|
||||
Size int
|
||||
DecimalDigits int
|
||||
Nullable int
|
||||
}
|
||||
|
||||
func (stmt *Statement) FieldMetadata(col int) (*Field, *ODBCError) {
|
||||
var BufferLength C.SQLSMALLINT = INFO_BUFFER_LEN
|
||||
var NameLength C.SQLSMALLINT
|
||||
var DataType C.SQLSMALLINT
|
||||
var ColumnSize C.SQLULEN
|
||||
var DecimalDigits C.SQLSMALLINT
|
||||
var Nullable C.SQLSMALLINT
|
||||
ColumnName := make([]byte, INFO_BUFFER_LEN)
|
||||
ret := C.SQLDescribeCol(C.SQLHSTMT(stmt.handle),
|
||||
C.SQLUSMALLINT(col),
|
||||
(*C.SQLCHAR)(unsafe.Pointer(&ColumnName[0])),
|
||||
BufferLength,
|
||||
&NameLength,
|
||||
&DataType,
|
||||
&ColumnSize,
|
||||
&DecimalDigits,
|
||||
&Nullable)
|
||||
if !Success(ret) {
|
||||
err := FormatError(C.SQL_HANDLE_STMT, stmt.handle)
|
||||
return nil, err
|
||||
}
|
||||
field := &Field{string(ColumnName[0:NameLength]), int(DataType), int(ColumnSize), int(DecimalDigits), int(Nullable)}
|
||||
return field, nil
|
||||
}
|
||||
|
||||
func (stmt *Statement) free() {
|
||||
if stmt.handle != nil {
|
||||
C.SQLFreeHandle(C.SQL_HANDLE_STMT, stmt.handle)
|
||||
stmt.handle = nil
|
||||
}
|
||||
}
|
||||
|
||||
func (stmt *Statement) Close() {
|
||||
stmt.free()
|
||||
}
|
||||
|
||||
func Success(ret C.SQLRETURN) bool {
|
||||
return int(ret) == C.SQL_SUCCESS || int(ret) == C.SQL_SUCCESS_WITH_INFO
|
||||
}
|
||||
|
||||
func FormatError(ht C.SQLSMALLINT, h C.SQLHANDLE) (err *ODBCError) {
|
||||
sqlState := make([]uint16, 6)
|
||||
var nativeError C.SQLINTEGER
|
||||
messageText := make([]uint16, C.SQL_MAX_MESSAGE_LENGTH)
|
||||
var textLength C.SQLSMALLINT
|
||||
err = &ODBCError{}
|
||||
i := 0
|
||||
for {
|
||||
i++
|
||||
ret := C.SQLGetDiagRecW(C.SQLSMALLINT(ht),
|
||||
h,
|
||||
C.SQLSMALLINT(i),
|
||||
(*C.SQLWCHAR)(unsafe.Pointer(&sqlState[0])),
|
||||
&nativeError,
|
||||
(*C.SQLWCHAR)(unsafe.Pointer(&messageText[0])),
|
||||
C.SQL_MAX_MESSAGE_LENGTH,
|
||||
&textLength)
|
||||
if ret == C.SQL_INVALID_HANDLE || ret == C.SQL_NO_DATA {
|
||||
break
|
||||
}
|
||||
if i == 1 { // first error message save the SQLSTATE.
|
||||
err.SQLState = UTF16ToString(sqlState)
|
||||
err.NativeError = int(nativeError)
|
||||
}
|
||||
err.ErrorMessage += UTF16ToString(messageText)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func init() {
|
||||
if err := initEnv(); err != nil {
|
||||
panic("odbc init env error!" + err.String())
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package odbc
|
||||
|
||||
import (
|
||||
"unicode/utf16"
|
||||
)
|
||||
|
||||
// StringToUTF16 returns the UTF-16 encoding of the UTF-8 string s,
|
||||
// with a terminating NUL added.
|
||||
func StringToUTF16(s string) []uint16 { return utf16.Encode([]rune(s + "\x00")) }
|
||||
|
||||
// UTF16ToString returns the UTF-8 encoding of the UTF-16 sequence s,
|
||||
// with a terminating NUL removed.
|
||||
func UTF16ToString(s []uint16) string {
|
||||
for i, v := range s {
|
||||
if v == 0 {
|
||||
s = s[0:i]
|
||||
break
|
||||
}
|
||||
}
|
||||
return string(utf16.Decode(s))
|
||||
}
|
||||
|
||||
// StringToUTF16Ptr returns pointer to the UTF-16 encoding of
|
||||
// the UTF-8 string s, with a terminating NUL added.
|
||||
func StringToUTF16Ptr(s string) *uint16 { return &StringToUTF16(s)[0] }
|
||||
|
|
@ -0,0 +1,656 @@
|
|||
package main
|
||||
|
||||
type tool_data struct {
|
||||
Series string `json:"series"`
|
||||
InstrumentID string `json:"instrument_id"`
|
||||
}
|
||||
|
||||
type get_nbpdf_resp struct {
|
||||
FileId string `json:"fileId"`
|
||||
}
|
||||
|
||||
type get_nbpdf_req struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Wellname string `json:"wellname"`
|
||||
BCode string `json:"bcode"`
|
||||
}
|
||||
|
||||
type getSeriesWarningCsv_req struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
}
|
||||
|
||||
type remove_battery_base_req struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
ID int `json:"id"`
|
||||
}
|
||||
|
||||
type get_battery_life_resp struct {
|
||||
Data []Battery_life `json:"data"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type Battery_life struct {
|
||||
ID int `json:"id"`
|
||||
B_code string `json:"b_code"`
|
||||
B_life string `json:"b_life"`
|
||||
}
|
||||
|
||||
type get_battery_base_resp struct {
|
||||
Data []Battery_base `json:"data"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type Battery_base struct {
|
||||
ID int `json:"id"`
|
||||
S_ID string `json:"sid"`
|
||||
IID string `json:"iid"`
|
||||
B_ID string `json:"b_id"`
|
||||
B_code string `json:"b_code"`
|
||||
}
|
||||
|
||||
type get_battery_base_req struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
S_ID string `json:"sid"`
|
||||
IID string `json:"iid"`
|
||||
B_ID string `json:"b_id"`
|
||||
B_code string `json:"b_code"`
|
||||
}
|
||||
|
||||
type add_battery_life_req struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
B_code string `json:"b_code"`
|
||||
B_life string `json:"b_life"`
|
||||
}
|
||||
|
||||
type add_battery_base_req struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
S_ID string `json:"sid"`
|
||||
IID string `json:"iid"`
|
||||
B_ID string `json:"b_id"`
|
||||
B_code string `json:"b_code"`
|
||||
}
|
||||
|
||||
type get_page_setting_req struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
}
|
||||
|
||||
type get_page_setting_resp struct {
|
||||
R1 string `json:"r1"`
|
||||
R2 string `json:"r2"`
|
||||
R3 string `json:"r3"`
|
||||
|
||||
Month bool `json:"r4"`
|
||||
R5 string `json:"r5"`
|
||||
}
|
||||
|
||||
type page_setting_req struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
R1 string `json:"r1"`
|
||||
R2 string `json:"r2"`
|
||||
R3 string `json:"r3"`
|
||||
|
||||
Month bool `json:"r4"`
|
||||
R5 string `json:"r5"`
|
||||
}
|
||||
|
||||
type get_up_off_well_info_req struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Index int `json:"index"`
|
||||
Count int `json:"count"`
|
||||
Wellname string `json:"wellname"`
|
||||
User string `json:"user"`
|
||||
If_es bool `json:"if_es"`
|
||||
}
|
||||
|
||||
type get_well_files_req get_srr_base_req
|
||||
|
||||
type download_file_req struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Filename string `json:"filename"`
|
||||
}
|
||||
|
||||
type add_dev_manage_req struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Data Dev_manage `json:"data"`
|
||||
}
|
||||
|
||||
type get_dev_manage_req get_srr_base_req
|
||||
|
||||
type get_tool_warning_req get_srr_base_req
|
||||
|
||||
type get_srr_event_req get_srr_base_req
|
||||
|
||||
type get_srr_state_req get_srr_base_req
|
||||
|
||||
type get_srr_base_req struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Wellname string `json:"wellname"`
|
||||
}
|
||||
|
||||
type get_cmr_pdf_req get_cmr_req
|
||||
|
||||
type get_cmr_record_req get_cmr_req
|
||||
|
||||
type get_cmr_req struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Wellname string `json:"wellname"`
|
||||
Flag bool `json:"flag"`
|
||||
}
|
||||
|
||||
type get_vibration_req struct {
|
||||
OpUser string `json:"opUser"`
|
||||
Wellname string `json:"wellname"` //井名
|
||||
WellNameSource string `json:"wellNameSource"` //井名对应库
|
||||
Uploadname string `json:"upload_name"`
|
||||
}
|
||||
|
||||
type get_nb_csv_req struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
}
|
||||
|
||||
type remove_nb_his_req struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
|
||||
ID int `json:"id"`
|
||||
Bid string `json:"b_id"`
|
||||
Bcode string `json:"b_code"`
|
||||
|
||||
WellName string `json:"wellname"`
|
||||
}
|
||||
|
||||
type update_nb_his_req struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
|
||||
ID int `json:"id"`
|
||||
Wellname string `json:"wellname"`
|
||||
Sid string `json:"sid"`
|
||||
Iid string `json:"iid"`
|
||||
Bid string `json:"b_id"`
|
||||
Bcode string `json:"b_code"`
|
||||
Uset float32 `json:"uset"`
|
||||
Action int `json:"action"`
|
||||
Bt string `json:"bt"`
|
||||
Et string `json:"et"`
|
||||
}
|
||||
|
||||
type add_nb_his_req struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
|
||||
Wellname string `json:"wellname"`
|
||||
Sid string `json:"sid"`
|
||||
Iid string `json:"iid"`
|
||||
Bid string `json:"b_id"`
|
||||
Bcode string `json:"b_code"`
|
||||
Uset float32 `json:"uset"`
|
||||
Action int `json:"action"`
|
||||
Bt string `json:"bt"`
|
||||
Et string `json:"et"`
|
||||
}
|
||||
|
||||
type get_nb_his_ex_req struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Index int `json:"index"`
|
||||
Count int `json:"count"`
|
||||
Wellname string `json:"wellname"`
|
||||
|
||||
Checked bool `json:"checked"`
|
||||
}
|
||||
|
||||
type get_nb_his_req struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Bid string `json:"b_id"`
|
||||
Bcode string `json:"b_code"`
|
||||
}
|
||||
|
||||
type get_nb_req struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Index int `json:"index"`
|
||||
Count int `json:"count"`
|
||||
Sid string `json:"series_id"`
|
||||
Code string `json:"num"`
|
||||
}
|
||||
|
||||
type getNotifyReq struct {
|
||||
UserName string `json:"username"`
|
||||
}
|
||||
|
||||
type GetLcmMssReq struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
|
||||
Series string `json:"sid"`
|
||||
Instrument_id string `json:"iid"`
|
||||
Index int `json:"index"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
type postLcmDeviceReq struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
OperType int `json:"oper_type"`
|
||||
ID string `json:"id"`
|
||||
Series string `json:"series"`
|
||||
InstrumentID string `json:"instrument_id"`
|
||||
Ver string `json:"ver"`
|
||||
Op_User string `json:"op_user"`
|
||||
Op_time string `json:"op_time"`
|
||||
}
|
||||
|
||||
type getLcmDeviceReq struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Sid string `json:"sid"`
|
||||
Iid string `json:"iid"`
|
||||
Index int `json:"index"`
|
||||
Count int `json:"count"`
|
||||
BeginTime string `json:"beginTime"`
|
||||
EndTime string `json:"endTime"`
|
||||
}
|
||||
|
||||
type postLcmReq_ex struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
OperType int `json:"oper_type"`
|
||||
ID string `json:"id"`
|
||||
Series string `json:"series"`
|
||||
InstrumentID string `json:"instrument_id"`
|
||||
Op_user string `json:"op_user"`
|
||||
Note string `json:"note"`
|
||||
Time string `json:"time"`
|
||||
}
|
||||
|
||||
type postLcmReq struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
OperType int `json:"oper_type"`
|
||||
ID string `json:"id"`
|
||||
Series string `json:"series"`
|
||||
InstrumentID string `json:"instrument_id"`
|
||||
Repair_cnt string `json:"repair_cnt"`
|
||||
Repair_level string `json:"repair_level"`
|
||||
Applicanter string `json:"applicanter"`
|
||||
Note string `json:"note"`
|
||||
Time string `json:"time"`
|
||||
}
|
||||
|
||||
type getLcmReq struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Sid string `json:"sid"`
|
||||
Iid string `json:"iid"`
|
||||
Index int `json:"index"`
|
||||
Count int `json:"count"`
|
||||
BeginTime string `json:"beginTime"`
|
||||
EndTime string `json:"endTime"`
|
||||
}
|
||||
|
||||
type getAuthorizePosCsvReq struct {
|
||||
SID string `json:"sid"`
|
||||
IID string `json:"iid"`
|
||||
}
|
||||
|
||||
type getAuthHisPosReq struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
SID string `json:"sid"`
|
||||
IID string `json:"iid"`
|
||||
|
||||
Index int `json:"index"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
type getUserLoginCntCsvReq struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
SearchUser string `json:"user"`
|
||||
BeginTime string `json:"b_time"`
|
||||
EndTime string `json:"e_time"`
|
||||
}
|
||||
|
||||
type getUserLoginCntReq struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
SearchUser string `json:"user"`
|
||||
BeginTime string `json:"b_time"`
|
||||
EndTime string `json:"e_time"`
|
||||
Index int `json:"index"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
type getEsCsvReq struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Wellname string `json:"Wellname"`
|
||||
BeginTime string `json:"BeginTime"`
|
||||
EndTime string `json:"EndTime"`
|
||||
}
|
||||
|
||||
type getEsReq struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Wellname string `json:"Wellname"`
|
||||
}
|
||||
|
||||
type get_well_ex1_req struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Wellname string `json:"Wellname"`
|
||||
Index int `json:"index"`
|
||||
Count int `json:"count"`
|
||||
BeginTime string `json:"BeginTime"`
|
||||
EndTime string `json:"EndTime"`
|
||||
Checked bool `json:"checked"`
|
||||
If_warn bool `json:"if_warn"`
|
||||
}
|
||||
|
||||
type GetWellExReq struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Wellname string `json:"Wellname"`
|
||||
Index int `json:"index"`
|
||||
Count int `json:"count"`
|
||||
BeginTime string `json:"BeginTime"`
|
||||
EndTime string `json:"EndTime"`
|
||||
}
|
||||
|
||||
type batchAuthReq struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Authorizer string `json:"authorizer"`
|
||||
Auth_date string
|
||||
Expire_date string `json:"expire_date"`
|
||||
Data []batchAuthReqData `json:"auth_data"`
|
||||
|
||||
Applicanter string `json:"applicanter"`
|
||||
Note string `json:"note"`
|
||||
}
|
||||
|
||||
type batchAuthReqData struct {
|
||||
Series string `json:"series"`
|
||||
InstrumentID string `json:"instrument_id"`
|
||||
Auth_count string `json:"auth_count"`
|
||||
Auth_Mark string `json:"auth_mark"`
|
||||
}
|
||||
|
||||
type getWellWorkingConditionReq struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
WellName string `json:"wellname"`
|
||||
}
|
||||
|
||||
type postMsSettingReq struct {
|
||||
User string `json:"op_user"`
|
||||
ID int `json:"id"`
|
||||
Series_num string `json:"series_num"`
|
||||
Series_num_new string `json:"series_num_new"`
|
||||
Oper_type int `json:"oper_type"`
|
||||
}
|
||||
|
||||
type getMsSettingReq struct {
|
||||
User string `json:"op_user"`
|
||||
}
|
||||
|
||||
type getMhSettingReq struct {
|
||||
User string `json:"op_user"`
|
||||
}
|
||||
|
||||
type updateMhSettingReq struct {
|
||||
User string `json:"op_user"`
|
||||
Series_num string `json:"series_num"`
|
||||
Series_num_new string `json:"series_num_new"`
|
||||
}
|
||||
|
||||
type exportWellTestTypeReq struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Wellname string `json:"wellname"`
|
||||
Type int `json:"type"`
|
||||
BeginTime string `json:"beginTime"`
|
||||
EndTime string `json:"endTime"`
|
||||
}
|
||||
|
||||
type getWellTestTypeReq struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Wellname string `json:"wellname"`
|
||||
Type int `json:"type"`
|
||||
Index int `json:"index"`
|
||||
Count int `json:"count"`
|
||||
BeginTime string `json:"beginTime"`
|
||||
EndTime string `json:"endTime"`
|
||||
}
|
||||
|
||||
type faultRateExportReq struct {
|
||||
Series string `json:"series"`
|
||||
Op_user string `json:"op_user"`
|
||||
}
|
||||
|
||||
type getFaultRateReq struct {
|
||||
Series string `json:"series"`
|
||||
Index int `json:"index"`
|
||||
Count int `json:"count"`
|
||||
Op_user string `json:"op_user"`
|
||||
}
|
||||
|
||||
type TsExportReq struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
WellName string `json:"wellname"`
|
||||
Series string `json:"series"`
|
||||
Instrument_id string `json:"instrument_id"`
|
||||
T_type string `json:"t_type"`
|
||||
}
|
||||
|
||||
type GetTsReq struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Series string `json:"series"`
|
||||
Instrument_id string `json:"instrument_id"`
|
||||
WellName string `json:"wellname"`
|
||||
Index int `json:"index"`
|
||||
Count int `json:"count"`
|
||||
T_type string `json:"t_type"`
|
||||
}
|
||||
|
||||
type getUserOpHistoryReq struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
SearchUser string `json:"user"`
|
||||
BeginTime string `json:"b_time"`
|
||||
EndTime string `json:"e_time"`
|
||||
Index int `json:"index"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
type getAuthReq struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Id string `json:"id"`
|
||||
Iid string `json:"iid"`
|
||||
Index int `json:"index"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
type getUsersReq struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Id string `json:"id"`
|
||||
Index int `json:"index"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
type GetMssReq struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Series string `json:"series"`
|
||||
Instrument_id string `json:"instrument_id"`
|
||||
WellName string `json:"wellname"`
|
||||
Index int `json:"index"`
|
||||
Count int `json:"count"`
|
||||
Checked bool `json:"checked"`
|
||||
|
||||
If_en bool `json:"if_en"`
|
||||
}
|
||||
|
||||
type GetMhReq struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Id string `json:"id"`
|
||||
BeginTime string `json:"beginTime"`
|
||||
EndTime string `json:"endTime"`
|
||||
Index int `json:"index"`
|
||||
Count int `json:"count"`
|
||||
IfAll bool `json:"if_all"`
|
||||
Checked bool `json:"checked"`
|
||||
}
|
||||
|
||||
type MssExportReq struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Wellname string `json:"wellname"`
|
||||
|
||||
Series string `json:"series"`
|
||||
Instrument_id string `json:"instrument_id"`
|
||||
|
||||
Checked bool `json:"checked"`
|
||||
}
|
||||
|
||||
type MsExportReq struct {
|
||||
SerierNum string `json:"seriesNum"`
|
||||
Op_user string `json:"op_user"`
|
||||
}
|
||||
|
||||
type GetMsReq struct {
|
||||
SearchType string `json:"type"`
|
||||
SearchValue string `json:"value"`
|
||||
Index int `json:"index"`
|
||||
Count int `json:"count"`
|
||||
Op_user string `json:"op_user"`
|
||||
}
|
||||
|
||||
type MhExportReq struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Wellname string `json:"wellname"`
|
||||
BeginTime string `json:"beginTime"`
|
||||
EndTime string `json:"endTime"`
|
||||
IfAll bool `json:"if_all"`
|
||||
Checked bool `json:"checked"`
|
||||
}
|
||||
|
||||
type getDeesAuthDbReq GetDeesAuthReq
|
||||
|
||||
type GetMenuReq struct {
|
||||
UserName string `json:"username"`
|
||||
}
|
||||
|
||||
// restful interface
|
||||
type GetDeesAuthReq struct {
|
||||
Series string `json:"series"`
|
||||
InstrumentID string `json:"instrument_id"`
|
||||
}
|
||||
|
||||
type PostAuthReq struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
OperType int `json:"oper_type"`
|
||||
ID string `json:"id"`
|
||||
Series string `json:"series"`
|
||||
InstrumentID string `json:"instrument_id"`
|
||||
Auth_date string `json:"auth_date"`
|
||||
Expire_date string `json:"expire_date"`
|
||||
Area_code string `json:"area_code"`
|
||||
Country string `json:"country"`
|
||||
Longitude string `json:"longitude"`
|
||||
Latitude string `json:"latitude"`
|
||||
Auth_count string `json:"auth_count"`
|
||||
Auth_Mark string `json:"auth_mark"`
|
||||
Authorizer string `json:"authorizer"`
|
||||
Applicanter string `json:"applicanter"`
|
||||
Note string `json:"note"`
|
||||
}
|
||||
|
||||
type LoginOutReq struct {
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
type RefreshUserReq struct {
|
||||
Uuid string `json:"uuid"`
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
type LoginReq struct {
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
type PostUserReq struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Id int `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
Role string `json:"role"`
|
||||
Department string `json:"department"`
|
||||
OperType int `json:"oper_type"`
|
||||
}
|
||||
|
||||
type GetHisWellReq struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Id string `json:"id"`
|
||||
Index int `json:"index"`
|
||||
Count int `json:"count"`
|
||||
BeginTime string `json:"beginTime"`
|
||||
EndTime string `json:"endTime"`
|
||||
IfAsc bool `json:"if_asc"`
|
||||
IfVip bool `json:"if_vit"`
|
||||
R1 string `json:"r1"`
|
||||
R2 string `json:"r2"`
|
||||
}
|
||||
|
||||
type getWellRealTimeData_req struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Id string `json:"id"`
|
||||
Index int `json:"index"`
|
||||
Count int `json:"count"`
|
||||
R1 string `json:"r1"`
|
||||
R2 string `json:"r2"`
|
||||
}
|
||||
|
||||
type CommonReq struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Id string `json:"id"`
|
||||
Index int `json:"index"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
type GetWellData struct {
|
||||
OpUser string `json:"opuser"`
|
||||
OpUserUuid string `json:"opuser_uuid"`
|
||||
Id string `json:"id"`
|
||||
Index int `json:"index"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
|
@ -0,0 +1,741 @@
|
|||
package main
|
||||
|
||||
type get_cur_well_dep_resp struct {
|
||||
Wellname string `json:"wellname"`
|
||||
|
||||
X string `json:"x"`
|
||||
Y string `json:"y"`
|
||||
|
||||
Cur_well_dep string `json:"cur_well_dep"`
|
||||
Drilling_num string `json:"Drilling_num"` //钻次
|
||||
Servicer string `json:"Servicer"`
|
||||
|
||||
Wait_time string `json:"Wait_time"`
|
||||
Work_time string `json:"Work_time"`
|
||||
}
|
||||
|
||||
type get_csv_resp struct {
|
||||
FileId string `json:"fileId"`
|
||||
}
|
||||
|
||||
type get_up_off_well_info_resp struct {
|
||||
Data []Up_off_well `json:"data"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type Up_off_well struct {
|
||||
Wellname string `json:"wellname"`
|
||||
Service_type string `json:"service_type"`
|
||||
User string `json:"user"`
|
||||
Up_well_time string `json:"up_well_time"`
|
||||
Entry_time string `json:"entry_time"`
|
||||
Out_time string `json:"out_time"`
|
||||
Off_well_time string `json:"off_well_time"`
|
||||
|
||||
Op_type string `json:"op_type"`
|
||||
}
|
||||
|
||||
type get_well_files_resp struct {
|
||||
Data []Well_file `json:"data"`
|
||||
}
|
||||
|
||||
type Well_file struct {
|
||||
ID int `json:"id"`
|
||||
Filename string `json:"filename"`
|
||||
}
|
||||
|
||||
type get_dev_manage_resp struct {
|
||||
Data []Dev_manage `json:"data"`
|
||||
}
|
||||
|
||||
type get_tool_warning_resp struct {
|
||||
Data []Tool_warning `json:"data"`
|
||||
}
|
||||
|
||||
type get_srr_event_resp struct {
|
||||
Data []Srr_event `json:"data"`
|
||||
}
|
||||
|
||||
type get_srr_state_resp struct {
|
||||
Data []Srr_state `json:"data"`
|
||||
}
|
||||
|
||||
type get_srr_base_resp struct {
|
||||
Wellname string `json:"wellname"`
|
||||
Uploadname string `json:"upload_name"`
|
||||
Ip string `json:"ip"`
|
||||
Location string `json:"location"`
|
||||
}
|
||||
|
||||
type get_cmr_pdf_resp getDeesAuthDbResp
|
||||
|
||||
type get_cmr_record_resp struct {
|
||||
Data []Cmr_input_record `json:"data"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type Cmr_input_record_ex struct {
|
||||
Time string `json:"time"`
|
||||
V1 string `json:"v1"`
|
||||
V2 string `json:"v2"`
|
||||
V3 string `json:"v3"`
|
||||
V4 string `json:"v4"`
|
||||
}
|
||||
|
||||
type Cmr_input_record struct {
|
||||
Time string `json:"time"`
|
||||
Context string `json:"context"`
|
||||
}
|
||||
|
||||
type get_vibration_resp struct {
|
||||
OpUser string `json:"opUser"`
|
||||
Wellname string `json:"wellname"` //井名
|
||||
WellNameSource string `json:"WELLNameSource"` //井名对应库
|
||||
Uploadname string `json:"upload_name"`
|
||||
WellTeam string `json:"well_team"`
|
||||
}
|
||||
|
||||
// 定义接收查询结果的结构体,左
|
||||
type VibrationStatLeft struct {
|
||||
Range string
|
||||
Count int
|
||||
Percentage string
|
||||
}
|
||||
|
||||
// 定义振动粘滑查询结果结构体
|
||||
type VibrationStatData struct {
|
||||
Deep float64 `json:"DEEP"`
|
||||
Time string `json:"TIME"`
|
||||
Code int `json:"CODE"`
|
||||
Value float64 `json:"VALUE"`
|
||||
Level int `json:"LEVEL"` // 指针类型处理NULL
|
||||
}
|
||||
|
||||
// TimeDepthRange 包含时间范围和深度范围
|
||||
type TimeDepthRange struct {
|
||||
FromTime string // 最早时间 "2025-02-20 08:46:04"
|
||||
ToTime string // 最晚时间
|
||||
MinDepth float64 // 最小深度
|
||||
MaxDepth float64 // 最大深度
|
||||
}
|
||||
|
||||
type get_cmr_resp struct {
|
||||
Data Cmr `json:"data"`
|
||||
}
|
||||
|
||||
type get_nb_csv_resp exportWellHisResp
|
||||
|
||||
type get_nb_his_resp struct {
|
||||
Data []battery_his_info `json:"data"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type battery_his_info struct {
|
||||
ID int `json:"id"`
|
||||
Wellname string `json:"wellname"`
|
||||
Sid string `json:"sid"`
|
||||
Iid string `json:"iid"`
|
||||
Bid string `json:"b_id"`
|
||||
Bcode string `json:"b_code"`
|
||||
Uset float32 `json:"uset"`
|
||||
Action string `json:"action"`
|
||||
Bt string `json:"bt"`
|
||||
Et string `json:"et"`
|
||||
Flag int `json:"flag"`
|
||||
}
|
||||
|
||||
type get_nb_resp struct {
|
||||
Data []battery_info `json:"data"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type Well_battery_info struct {
|
||||
Bid string `json:"b_id"`
|
||||
Bcode string `json:"b_code"`
|
||||
Sid string `json:"sid"`
|
||||
Iid string `json:"iid"`
|
||||
Uset float32 `json:"uset"`
|
||||
|
||||
Bt string `json:"bt"`
|
||||
Et string `json:"et"`
|
||||
|
||||
Flag int `json:"flag"`
|
||||
|
||||
WellName string `json:"wellname"`
|
||||
Cloud_account string `json:"Cloud_account"`
|
||||
Service_type int `json:"service_type"`
|
||||
|
||||
B_life float32 `json:"b_life"`
|
||||
}
|
||||
|
||||
type battery_info struct {
|
||||
Bid string `json:"b_id"`
|
||||
Bcode string `json:"b_code"`
|
||||
Uset float32 `json:"uset"`
|
||||
Remaining_t float32 `json:"remaining_t"`
|
||||
|
||||
Remaining_t1 string `json:"remaining_t1"`
|
||||
|
||||
B_life string `json:"b_life"`
|
||||
|
||||
WellName string `json:"wellname"`
|
||||
}
|
||||
|
||||
type getNotifyResp struct {
|
||||
Data string `json:"data"`
|
||||
}
|
||||
|
||||
type GetLcmMssResp struct {
|
||||
Data []GetLcmMssRespData `json:"data"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type GetLcmMssRespData struct {
|
||||
WellName string `json:"wellname"`
|
||||
WorkTime string `json:"workTime"`
|
||||
TotalWorkTime string `json:"totalWorkTime"`
|
||||
TotalFootage float32 `json:"totalFootage"`
|
||||
|
||||
Service_personnel string `json:"sp"` //服务人员
|
||||
}
|
||||
|
||||
type GetLcmDeviceResp struct {
|
||||
Data []GetLcmDeviceRespData `json:"data"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type GetLcmDeviceRespData struct {
|
||||
ID string `json:"id"`
|
||||
Series string `json:"series"`
|
||||
InstrumentID string `json:"instrument_id"`
|
||||
Ver string `json:"ver"`
|
||||
OpUser string `json:"op_user"`
|
||||
Op_time string `json:"op_time"`
|
||||
IfWarning bool `json:"if_warning"`
|
||||
}
|
||||
|
||||
type GetLcmResp_ex struct {
|
||||
Data []GetLcmRespData_ex `json:"data"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type GetLcmRespData_ex struct {
|
||||
ID string `json:"id"`
|
||||
Series string `json:"series"`
|
||||
InstrumentID string `json:"instrument_id"`
|
||||
Op_user string `json:"op_user"`
|
||||
Note string `json:"note"`
|
||||
Time string `json:"time"`
|
||||
IfShowOp bool `json:"if_show_op"`
|
||||
}
|
||||
|
||||
type GetLcmResp struct {
|
||||
Data []GetLcmRespData `json:"data"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type GetLcmRespData struct {
|
||||
ID string `json:"id"`
|
||||
Series string `json:"series"`
|
||||
InstrumentID string `json:"instrument_id"`
|
||||
Repair_cnt string `json:"repair_cnt"`
|
||||
Repair_level string `json:"repair_level"`
|
||||
Applicanter string `json:"applicanter"`
|
||||
Note string `json:"note"`
|
||||
Time string `json:"time"`
|
||||
IfShowOp bool `json:"if_show_op"`
|
||||
}
|
||||
|
||||
type getWellAnalysisResultResp struct {
|
||||
WellInline int `json:"well_online"`
|
||||
WellOffline int `json:"well_offline"`
|
||||
MWD_cnt int `json:"mwd"`
|
||||
Near_bit int `json:"near_bit"` //近钻头
|
||||
Resistivity int `json:"resistivity"` //电阻率
|
||||
Gamma1 int `json:"gamma1"` //探管式方位伽马
|
||||
Gamma2 int `json:"gamma2"` //钻铤式方位伽马
|
||||
Context string `json:"context"`
|
||||
}
|
||||
|
||||
type getAuthHisPosResp struct {
|
||||
Data []getAuthHisPosRespD `json:"data"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type getAuthHisPosRespD struct {
|
||||
Series string `json:"series"`
|
||||
InstrumentID string `json:"instrument_id"`
|
||||
Auth_date string `json:"auth_date"`
|
||||
Expire_date string `json:"expire_date"`
|
||||
Longitude string `json:"longitude"`
|
||||
Latitude string `json:"latitude"`
|
||||
Auth_Mark string `json:"auth_mark"`
|
||||
Authorizer string `json:"authorizer"`
|
||||
|
||||
ReportLongitude string `json:"report_longitude"`
|
||||
ReportLatitude string `json:"report_latitude"`
|
||||
|
||||
ReportLongitudeX string `json:"x"`
|
||||
ReportLatitudeY string `json:"y"`
|
||||
|
||||
WellName string `json:"wellname"`
|
||||
}
|
||||
|
||||
type getUserLoginCntResp struct {
|
||||
Data []getUserLoginCntRespD `json:"data"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
type getUserLoginCntRespD struct {
|
||||
UserName string `json:"username"`
|
||||
LoginCnt int `json:"login_cnt"`
|
||||
OpText string `json:"op_text"`
|
||||
}
|
||||
|
||||
type getUserLoginCntCsvResp getDeesAuthDbResp
|
||||
|
||||
type getExCsvResp getDeesAuthDbResp
|
||||
|
||||
type EngineeringServices struct {
|
||||
wellCreateTime string
|
||||
Wellname string `json:"Wellname"`
|
||||
Locale string `json:"Locale"` //服务地点
|
||||
ServiceType string `json:"ServiceType"` //服务类型
|
||||
|
||||
ClientName string `json:"ClientName"` //客户名字
|
||||
DrillingCrewName string `json:"DrillingCrewName"` //井队名称
|
||||
DrillingCrewCompany string `json:"DrillingCrewCompany"` //井队所属公司
|
||||
|
||||
Welltype string `json:"Welltype"` //井型
|
||||
OpUser string `json:"OpUser"` //服务人员
|
||||
WorkState string `json:"WorkState"` //工作状态
|
||||
|
||||
SpecialNote string `json:"SpecialNote"` //特殊说明
|
||||
DesignDepth string `json:"DesignDepth"` //设计井深
|
||||
WellDeviation string `json:"WellDeviation"` //设计最大井斜
|
||||
|
||||
DesignOrientation string `json:"DesignOrientation"` //设计方位
|
||||
LongitudeLatitude string `json:"LongitudeLatitude"` //经纬度
|
||||
GTBTDIP string `json:"GTBTDIP"` //井位标称值
|
||||
|
||||
Length_of_horizontal_section string `json:"Length_of_horizontal_section"` //水平段长度
|
||||
Rate string `json:"Rate"`
|
||||
DrillingTimes string `json:"DrillingTimes"` //钻次
|
||||
|
||||
Instrument_angle_difference string `json:"Instrument_angle_difference"` //仪器角差
|
||||
Angle_difference_of_drilling_tool string `json:"Angle_difference_of_drilling_tool"` //钻具角差
|
||||
MudType string `json:"MudType"` //泥浆类型
|
||||
|
||||
MudDensity float32 `json:"MudDensity"` //泥浆密度
|
||||
MudViscosity float32 `json:"MudViscosity"` //泥浆粘度
|
||||
OutputVolume float32 `json:"OutputVolume"` //排量
|
||||
|
||||
Sediment_concentration float32 `json:"Sediment_concentration"` //含沙量
|
||||
Screw_curvature float32 `json:"Screw_curvature"` //螺杆弯度
|
||||
LoopTime float32 `json:"LoopTime"` //循环时间
|
||||
|
||||
EntryWellDepth float32 `json:"EntryWellDepth"`
|
||||
TotalFootage float32 `json:"TotalFootage"`
|
||||
|
||||
BHA string `json:"BHA"` //钻具组合
|
||||
InstrumentCombination string `json:"InstrumentCombination"` //仪器组合
|
||||
|
||||
MaxPressure float32 `json:"MaxPressure"`
|
||||
MaxTemp float32 `json:"MaxTemp"`
|
||||
}
|
||||
|
||||
type GetWellExResp struct {
|
||||
Data []wellExData `json:"data"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type wellExData struct {
|
||||
WellNameSource string `json:"wellNameSource"`
|
||||
Wellstate string `json:"wellstate"`
|
||||
Welltime string `json:"welltime"`
|
||||
Welloperator string `json:"welloperator"`
|
||||
|
||||
Rt_flag bool `json:"rt_flag"`
|
||||
Es_flag bool `json:"es_flag"`
|
||||
|
||||
Upload_user string `json:"upload_user"`
|
||||
|
||||
Tool_state_warning bool `json:"tsw"`
|
||||
}
|
||||
|
||||
type SeriesWarning struct {
|
||||
Wellname string `json:"wellname"`
|
||||
Series string `json:"series"`
|
||||
InstrumentID string `json:"instrument_id"`
|
||||
Grade int `json:"grade"`
|
||||
Type int `json:"type"`
|
||||
Warning_time int `json:"warning_time"`
|
||||
Special string `json:"special"`
|
||||
IsInvalid int `json:"is_invalid"`
|
||||
DevName string `json:"dev_name"`
|
||||
DefWarningTime int `json:"def_warning_time"`
|
||||
|
||||
Ver string `json:"cur_ver"`
|
||||
LstVer string `json:"lst_ver"`
|
||||
}
|
||||
|
||||
type GetAuthPosCsvResp getDeesAuthDbResp
|
||||
|
||||
type GetAuthPosData struct {
|
||||
ID string `json:"id"`
|
||||
Series string `json:"series"`
|
||||
InstrumentID string `json:"instrument_id"`
|
||||
Auth_date string `json:"auth_date"`
|
||||
Expire_date string `json:"expire_date"`
|
||||
Area_code string `json:"area_code"`
|
||||
Country string `json:"country"`
|
||||
Longitude string `json:"longitude"`
|
||||
Latitude string `json:"latitude"`
|
||||
Auth_count string `json:"auth_count"`
|
||||
Auth_Mark string `json:"auth_mark"`
|
||||
Authorizer string `json:"authorizer"`
|
||||
|
||||
ReportLongitude string `json:"report_longitude"`
|
||||
ReportLatitude string `json:"report_latitude"`
|
||||
|
||||
ReportLongitudeX string `json:"x"`
|
||||
ReportLatitudeY string `json:"y"`
|
||||
|
||||
WellName string `json:"wellname"`
|
||||
}
|
||||
|
||||
type wellWorkingCondition struct {
|
||||
Es EngineeringServices `json:"es"`
|
||||
|
||||
ReportLongitude string `json:"report_longitude"`
|
||||
ReportLatitude string `json:"report_latitude"`
|
||||
|
||||
ReportLongitudeX string `json:"report_longitude_x"`
|
||||
ReportLatitudeY string `json:"report_latitude_y"`
|
||||
}
|
||||
|
||||
type addUserByDeesResp struct {
|
||||
Ret int `json:"ret"`
|
||||
}
|
||||
|
||||
type exportWellHisResp getDeesAuthDbResp
|
||||
|
||||
type postMsSettingResp struct {
|
||||
Ret int `json:"r"`
|
||||
}
|
||||
|
||||
type getMsSettingResp struct {
|
||||
Data []msSetting `json:"data"`
|
||||
}
|
||||
|
||||
type msSetting struct {
|
||||
ID int `json:"id"`
|
||||
Series_num string `json:"series_num"`
|
||||
Series_num_new string `json:"series_num_new"`
|
||||
}
|
||||
|
||||
type getMhSettingResp struct {
|
||||
Series_num string `json:"series_num"`
|
||||
Series_num_new string `json:"series_num_new"`
|
||||
}
|
||||
|
||||
type updateMhSettingResp struct {
|
||||
Ret int `json:"r"`
|
||||
}
|
||||
|
||||
type mt struct {
|
||||
Series string
|
||||
Instrument_id string
|
||||
WorkTime string
|
||||
RepairCnt string
|
||||
SaveTime string
|
||||
TotalWorkTime string
|
||||
}
|
||||
|
||||
type getWellTestTypeResp struct {
|
||||
Data []wellTestType `json:"data"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type wellTestType struct {
|
||||
Wellname string `json:"wellname"`
|
||||
Type string `json:"type"`
|
||||
WellCreateTime string `json:"well_create_time"`
|
||||
}
|
||||
|
||||
type footage struct {
|
||||
TotalFootage float64 `json:"total_footage"`
|
||||
CurFootage float64 `json:"cur_footage"`
|
||||
}
|
||||
|
||||
type getFaultRateResp struct {
|
||||
Data []faultRate `json:"data"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type faultRate struct {
|
||||
Series string `json:"series"`
|
||||
RepairCnt int `json:"repairCnt"`
|
||||
TotalFootage string `json:"total_footage"`
|
||||
Rate string `json:"rate"`
|
||||
|
||||
tfootage float64
|
||||
}
|
||||
|
||||
type GetTsResp struct {
|
||||
Data []tsData `json:"data"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type tsData struct {
|
||||
WellName string `json:"wellname"`
|
||||
Series string `json:"series"`
|
||||
InstrumentID string `json:"instrument_id"`
|
||||
TempSection string `json:"temp_section"`
|
||||
WorkTime string `json:"work_time"`
|
||||
BeginTime string `json:"bt"`
|
||||
wt int `json:"wt"`
|
||||
}
|
||||
|
||||
type getUserOpHistoryResp struct {
|
||||
Data []getUserOpHistoryRespData `json:"data"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type getUserOpHistoryRespData struct {
|
||||
UserName string `json:"username"`
|
||||
Time string `json:"time"`
|
||||
OpText string `json:"op_text"`
|
||||
}
|
||||
|
||||
type DownFileResp getDeesAuthDbResp
|
||||
|
||||
type GetMssResp struct {
|
||||
Data []GetMssRespData `json:"data"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type GetMsResp struct {
|
||||
Data []GetMsRespData `json:"data"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type GetMssRespData struct {
|
||||
WellName string `json:"wellname"`
|
||||
Series string `json:"series"`
|
||||
InstrumentID string `json:"instrument_id"`
|
||||
SaveTime string `json:"saveTime"`
|
||||
Ver string `json:"ver"`
|
||||
LastVer string `json:"lastVer"`
|
||||
WorkTime string `json:"workTime"`
|
||||
TotalWorkTime string `json:"totalWorkTime"`
|
||||
State string `json:"state"`
|
||||
UseTime string `json:"useTime"`
|
||||
WellEntryTime string `json:"wellEntryTime"`
|
||||
RepairCnt string `json:"repairCnt"`
|
||||
|
||||
Warn_type string `json:"warn_type"`
|
||||
}
|
||||
|
||||
type GetMsRespData struct {
|
||||
Series string `json:"series"`
|
||||
RepairCnt int `json:"repairCnt"`
|
||||
TotalTime int `json:"totalTime"`
|
||||
MtbfTime int `json:"mtbfTime"`
|
||||
}
|
||||
|
||||
type MhExportResp getDeesAuthDbResp
|
||||
|
||||
type GetMhSResp struct {
|
||||
Data []GetMhSRespData `json:"data"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type GetMhSRespData struct {
|
||||
WellName string `json:"wellname"`
|
||||
WellOper string `json:"welloper"`
|
||||
WorkState string `json:"workState"`
|
||||
SaveTime string `json:"saveTime"`
|
||||
Note string `json:"note"`
|
||||
}
|
||||
|
||||
type GetMhResp struct {
|
||||
Data []GetMhRespData `json:"data"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type GetMhRespData struct {
|
||||
WellName string `json:"wellname"`
|
||||
WellOper string `json:"welloper"`
|
||||
WellCreateT string `json:"wellCreateTime"`
|
||||
WellBeginT string `json:"wellBeginTime"`
|
||||
WellEndT string `json:"wellEndTime"`
|
||||
WellWorkT string `json:"wellWorkTime"`
|
||||
State string `json:"state"`
|
||||
}
|
||||
|
||||
type GetMenuResp struct {
|
||||
MenuData []GetMenuRespData `json:"data"`
|
||||
}
|
||||
|
||||
type Svg struct {
|
||||
First string `json:"first"`
|
||||
Second string `json:"second"`
|
||||
}
|
||||
|
||||
type GetMenuRespData struct {
|
||||
Title string `json:"title"`
|
||||
Class string `json:"classname"`
|
||||
SvgData Svg `json:"svg"`
|
||||
Index string `json:"index"`
|
||||
Key string `json:"key"`
|
||||
Items []menuItem `json:"items"`
|
||||
}
|
||||
|
||||
type menuItem struct {
|
||||
Title string `json:"title"`
|
||||
Index string `json:"index"`
|
||||
Key string `json:"key"`
|
||||
}
|
||||
|
||||
type getDeesAuthDbResp struct {
|
||||
FileId string `json:"fileId"`
|
||||
}
|
||||
|
||||
type GetDeesAuthResp struct {
|
||||
Series string `json:"series"`
|
||||
InstrumentID string `json:"instrument_id"`
|
||||
Auth_date string `json:"auth_date"`
|
||||
Expire_date string `json:"expire_date"`
|
||||
Area_code string `json:"area_code"`
|
||||
Country string `json:"country"`
|
||||
Longitude string `json:"longitude"`
|
||||
Latitude string `json:"latitude"`
|
||||
Auth_count string `json:"auth_count"`
|
||||
Auth_Mark string `json:"auth_mark"`
|
||||
Authorizer string `json:"authorizer"`
|
||||
}
|
||||
|
||||
type GetAuthResp struct {
|
||||
Data []GetAuthRespData `json:"data"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type GetAuthRespData struct {
|
||||
ID string `json:"id"`
|
||||
Series string `json:"series"`
|
||||
InstrumentID string `json:"instrument_id"`
|
||||
Auth_date string `json:"auth_date"`
|
||||
Expire_date string `json:"expire_date"`
|
||||
Area_code string `json:"area_code"`
|
||||
Country string `json:"country"`
|
||||
Longitude string `json:"longitude"`
|
||||
Latitude string `json:"latitude"`
|
||||
Auth_count string `json:"auth_count"`
|
||||
Auth_Mark string `json:"auth_mark"`
|
||||
Authorizer string `json:"authorizer"`
|
||||
Applicanter string `json:"applicanter"`
|
||||
Note string `json:"note"`
|
||||
}
|
||||
|
||||
type CommonResp struct {
|
||||
Ret int `json:"r"`
|
||||
}
|
||||
|
||||
type LoginResp struct {
|
||||
Ret int `json:"r"`
|
||||
Uuid string `json:"uuid"`
|
||||
Level int `json:"level"`
|
||||
Url string `json:"url"`
|
||||
DID int `json:"did"`
|
||||
|
||||
Err_text string `json:"err_text"`
|
||||
}
|
||||
|
||||
type PostUserResp struct {
|
||||
Ret int `json:"r"`
|
||||
}
|
||||
|
||||
type GetWellDataResp struct {
|
||||
Data []wellData `json:"data"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type wellData struct {
|
||||
WellID int `json:"wellID"`
|
||||
WellNameSource string `json:"wellNameSource"`
|
||||
WellName string `json:"wellName"`
|
||||
Wellstate string `json:"wellstate"`
|
||||
Welltime string `json:"welltime"`
|
||||
Wellip string `json:"wellip"`
|
||||
Welloperator string `json:"welloperator"`
|
||||
|
||||
Rt_flag bool `json:"rt_flag"`
|
||||
Es_flag bool `json:"es_flag"`
|
||||
|
||||
Cloud_account string `json:"Cloud_account"`
|
||||
Service_type int `json:"service_type"`
|
||||
}
|
||||
|
||||
type GetWellNamesResp struct {
|
||||
Value string `json:"value"`
|
||||
Label string `json:"label"`
|
||||
}
|
||||
|
||||
type jx struct {
|
||||
Value string `json:"value"`
|
||||
Time string `json:"time"`
|
||||
}
|
||||
|
||||
type getWellRealTimeDataResp struct {
|
||||
Data []GetHisWellRespdata `json:"data"`
|
||||
Total int `json:"total"`
|
||||
Fw jx `json:"fw"`
|
||||
Jx jx `json:"jx"`
|
||||
|
||||
Time_warn int `json:"time_warn"` //客户端时间异常预警
|
||||
}
|
||||
|
||||
type GetHisWellResp struct {
|
||||
Data []GetHisWellRespdata `json:"data"`
|
||||
Total int `json:"total"`
|
||||
Time_warn int `json:"time_warn"` //客户端时间异常预警
|
||||
}
|
||||
|
||||
type GetHisWellRespdata struct {
|
||||
Time string `json:"time"`
|
||||
WellDepth float32 `json:"welldepth"`
|
||||
Paraname string `json:"paraname"`
|
||||
DecodeValue string `json:"decodevalue"`
|
||||
Precision float32 `json:"precision"`
|
||||
Wellname string `json:"wellname"`
|
||||
Wellnum string `json:"wellnum"`
|
||||
IfWarning int `json:"ifWarning"`
|
||||
Unit string `json:"unit"`
|
||||
}
|
||||
|
||||
type wellHistoryData struct {
|
||||
Time string `json:"time"`
|
||||
WellDepth float64 `json:"welldepth"`
|
||||
Paraname string `json:"paraname"`
|
||||
DecodeValue string `json:"decodevalue"`
|
||||
Precision float64 `json:"precision"`
|
||||
Wellname string `json:"wellname"`
|
||||
Wellnum string `json:"wellnum"`
|
||||
IfWarning int `json:"ifWarning"`
|
||||
Unit string `json:"unit"`
|
||||
}
|
||||
|
||||
type GetUsersResp struct {
|
||||
Data []GetUsersRespdata `json:"data"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type GetUsersRespdata struct {
|
||||
Userid int `json:"userid"`
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
Userrole string `json:"userrole"`
|
||||
UserDepartment string `json:"user_department"`
|
||||
Cnt int `json:"cnt"`
|
||||
LoginTime string `json:"loginTime"`
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,43 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type DeesUserStat struct {
|
||||
Uuid string `json:"uuid"`
|
||||
Username string `json:"username"`
|
||||
State int `json:"state"`
|
||||
RefreshTime time.Time `json:"refreshTime"`
|
||||
ExpireTime time.Time `json:"expireTime"`
|
||||
UserRole string `json:"userrole"`
|
||||
|
||||
lck sync.RWMutex
|
||||
}
|
||||
|
||||
func (d *DeesUserStat) Lock() {
|
||||
d.lck.Lock()
|
||||
}
|
||||
|
||||
func (d *DeesUserStat) Unlock() {
|
||||
d.lck.Unlock()
|
||||
}
|
||||
|
||||
func (d *DeesUserStat) RLock() {
|
||||
d.lck.RLock()
|
||||
}
|
||||
|
||||
func (d *DeesUserStat) RUnlock() {
|
||||
d.lck.RUnlock()
|
||||
}
|
||||
|
||||
var (
|
||||
deesUserStatMap map[string]*DeesUserStat
|
||||
|
||||
deesUserStatMaplck sync.RWMutex
|
||||
)
|
||||
|
||||
func init() {
|
||||
deesUserStatMap = make(map[string]*DeesUserStat)
|
||||
}
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
// "encoding/json"
|
||||
// "strings"
|
||||
|
||||
"fmt"
|
||||
|
||||
"github.com/astaxie/beego/logs"
|
||||
"golang.org/x/net/websocket"
|
||||
)
|
||||
|
||||
//websocket
|
||||
|
||||
type wsSubscribeCmd struct {
|
||||
ID string `json:"id"` //井名
|
||||
User string `json:user`
|
||||
Lang string `json:"lang"`
|
||||
}
|
||||
|
||||
type wsMsg struct {
|
||||
ID string `json:"id"`
|
||||
Type int `json:"type"` //0 真实数据 1 是心跳
|
||||
Msg []GetHisWellRespdata `json:"msg"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
/*go func() {
|
||||
|
||||
t := time.NewTicker(time.Second * 5)
|
||||
|
||||
for {
|
||||
|
||||
select {
|
||||
case <-t.C:
|
||||
|
||||
ioCh <- "hello" + time.Now().String()
|
||||
}
|
||||
}
|
||||
|
||||
}()*/
|
||||
}
|
||||
|
||||
//HandleSubscribe subscribe handler
|
||||
func HandleSubscribe(ws *websocket.Conn) {
|
||||
|
||||
defer ws.Close()
|
||||
|
||||
var cmd wsSubscribeCmd
|
||||
var err error
|
||||
err = websocket.JSON.Receive(ws, &cmd)
|
||||
if err != nil {
|
||||
logs.Error("websocket.JSON.Receive failed %v", err)
|
||||
return
|
||||
}
|
||||
logs.Info("receive cmd :", cmd)
|
||||
|
||||
var ioCh = make(chan []GetHisWellRespdata, 1000)
|
||||
var exitCh = make(chan struct{}, 1)
|
||||
|
||||
go wsGetWellRealTimeData(cmd.Lang, cmd.ID, cmd.User, ioCh, exitCh)
|
||||
|
||||
t := time.NewTicker(time.Second * 5)
|
||||
for {
|
||||
|
||||
var msg wsMsg
|
||||
select {
|
||||
case v, ok := <-ioCh:
|
||||
if !ok {
|
||||
logs.Info("msg chan err!")
|
||||
|
||||
goto exit_l
|
||||
}
|
||||
|
||||
//fmt.Println(v)
|
||||
msg = wsMsg{Msg: v}
|
||||
|
||||
case <-t.C:
|
||||
msg = wsMsg{Type: 1}
|
||||
|
||||
/*case <-exitCh:
|
||||
goto exit_l*/
|
||||
|
||||
}
|
||||
|
||||
err := websocket.JSON.Send(ws, msg)
|
||||
if err != nil {
|
||||
logs.Info(fmt.Sprintf("ws send failed!%v!Msg is:%v", err, msg.Msg))
|
||||
|
||||
goto exit_l
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exit_l:
|
||||
|
||||
close(exitCh)
|
||||
}
|
||||
Loading…
Reference in New Issue