首次提交
This commit is contained in:
parent
f982ddc7fb
commit
8f615b0891
|
|
@ -0,0 +1 @@
|
||||||
|
/logs/*.log
|
||||||
|
|
@ -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*/
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
server = 119.3.242.17
|
||||||
|
port = 1433
|
||||||
|
user = sa
|
||||||
|
password = lh123456?
|
||||||
|
database = ma
|
||||||
|
|
@ -0,0 +1,102 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
type ma_temp_plan struct {
|
||||||
|
ID int `json:"id"` //序号
|
||||||
|
Recv_date string `json:"recv_date"` //接收日期
|
||||||
|
Dispath_date string `json:"dispath_date"` //下发日期
|
||||||
|
|
||||||
|
Return_task string `json:"return_task"` //退货任务
|
||||||
|
Head string `json:"head"` //负责人
|
||||||
|
P_id string `json:"p_id"` //产品编号
|
||||||
|
P_name string `json:"p_name"` //产品名称
|
||||||
|
P_serial string `json:"p_serial"` //产品序列号
|
||||||
|
|
||||||
|
Repairer string `json:"repairer"` //维修人员
|
||||||
|
Repair_type string `json:"rt"` //维修类型
|
||||||
|
|
||||||
|
Work string `json:"work"` //工作内容
|
||||||
|
Work_h string `json:"work_h"` //天工时长
|
||||||
|
Inspection_analysis string `json:"ia"` //初检分析
|
||||||
|
Repair_plan string `json:"rp"` //维修方案
|
||||||
|
Actual_completed_date string `json:"acd"` //实际完成
|
||||||
|
Link string `json:"link"` //自检记录链接
|
||||||
|
|
||||||
|
Material_status string `json:"ms"` //缺料情况
|
||||||
|
Material_task string `json:"mt"` //物料任务
|
||||||
|
|
||||||
|
Total_work_time string `json:"total_work_time"`
|
||||||
|
Total_cost string `json:"total_cost"`
|
||||||
|
|
||||||
|
Plan_data []plan_info `json:"plan_data"`
|
||||||
|
|
||||||
|
State string `json:"state"` //已审核 未审核
|
||||||
|
|
||||||
|
If_do int `json:"if_do"` // 1-已处理
|
||||||
|
|
||||||
|
If_e1 bool `json:"if_e1"` //是否转入E1库 true-转入
|
||||||
|
If_e1_str string `json:"if_e1_str"` //是否转入E1库 true-转入
|
||||||
|
Odd_num string `json:"odd_num"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ma_plan struct {
|
||||||
|
ID int `json:"id"` //序号
|
||||||
|
Recv_date string `json:"recv_date"` //接收日期
|
||||||
|
Dispath_date string `json:"dispath_date"` //下发日期
|
||||||
|
Repair_id string `json:"repair_id"` //维修订单号
|
||||||
|
Repair_report_id string `json:"repair_report_id"` //维修报告编号
|
||||||
|
Customer string `json:"customer"` //客户名称
|
||||||
|
Regional_head string `json:"regional_head"` //区域负责人
|
||||||
|
P_id string `json:"p_id"` //产品编号
|
||||||
|
P_name string `json:"p_name"` //产品名称
|
||||||
|
P_serial string `json:"p_serial"` //产品序列号
|
||||||
|
|
||||||
|
Repairer string `json:"repairer"` //维修人员
|
||||||
|
Repair_plan string `json:"rp"` //维修方案
|
||||||
|
Material_status string `json:"ms"` //缺料情况
|
||||||
|
Repair_cycle string `json:"rc"` //承诺维修周期
|
||||||
|
Repair_quotation_date string `json:"rqd"` //维修报价日期
|
||||||
|
Repair_status string `json:"rs"` //维修状态
|
||||||
|
Repair_OK_date string `json:"rod"` //确认维修日期
|
||||||
|
If_repair string `json:"if_repair"` //是否维修
|
||||||
|
Committed_completed_date string `json:"ccd"` //承诺完成
|
||||||
|
Actual_completed_date string `json:"acd"` //实际完成
|
||||||
|
Overdue string `json:"overdue"` //超期
|
||||||
|
Quotation string `json:"quotation"` //报价花费时间
|
||||||
|
Material_committed_date string `json:"mcd"` //承诺到料日期
|
||||||
|
Material_task string `json:"mt"` //物料任务
|
||||||
|
|
||||||
|
Inventory string `json:"inventory"` //库存量
|
||||||
|
|
||||||
|
Location string `json:"Location"`
|
||||||
|
|
||||||
|
Date_of_issuance string `json:"doi"` //发料日期
|
||||||
|
Link string `json:"link"` //自检记录链接
|
||||||
|
|
||||||
|
Mcn string `json:"mcn"` //维修合同号
|
||||||
|
|
||||||
|
If_warn int `json:"if_warn"`
|
||||||
|
|
||||||
|
Total_work_time string `json:"total_work_time"`
|
||||||
|
|
||||||
|
Total_cost string `json:"total_cost"`
|
||||||
|
|
||||||
|
Plan_data []plan_info `json:"plan_data"`
|
||||||
|
|
||||||
|
Station string `json:"station"` //维保站
|
||||||
|
|
||||||
|
State string `json:"state"` //已审核 未审核
|
||||||
|
}
|
||||||
|
|
||||||
|
type plan_info struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
|
||||||
|
Process_name string `json:"produce_plan"`
|
||||||
|
Process_t string `json:"produce_plan_use_t"`
|
||||||
|
Produce_user string `json:"produce_user"`
|
||||||
|
|
||||||
|
Actual_finished_t string `json:"p_actual_finished_t"`
|
||||||
|
|
||||||
|
State string `json:"state"` //已审核 未审核
|
||||||
|
|
||||||
|
Times int `json:"times"`
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
接收日期,退库任务,负责人,产品编号,产品名称,序列号,维修人员,维修类型,工作内容(天工),天工工时,转入E1库
|
||||||
|
2022-11-4,测试任务,测试,测试2,测试1,AA,人员1,,,,
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
接收日期,下发日期,维修订单号,维修报告编号,合同号,客户名称,区域负责人,产品编号,产品名称,序列号,维修人员,维修状态,是否维修,维保站
|
||||||
|
2022-11-4,2022-11-4,219457,219457,219457,测试4,测试3,测试2,测试1,AA,人员1,,,
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
module ma
|
||||||
|
|
||||||
|
go 1.16
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/LukeMauldin/lodbc v0.0.0-20130219161755-59316a7de9d4
|
||||||
|
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/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/tealeg/xlsx v1.0.5
|
||||||
|
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,206 @@
|
||||||
|
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/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/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/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/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/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/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.
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,301 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
type approval_provesses_req struct {
|
||||||
|
OpUser string `json:"opuser"`
|
||||||
|
OpUserUuid string `json:"opuser_uuid"`
|
||||||
|
ID int `json:"id"`
|
||||||
|
|
||||||
|
Rid string `json:"rid"`
|
||||||
|
Serial_id int `json:"serial_id"` //工序序号
|
||||||
|
|
||||||
|
Undo bool `json:"undo"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type get_processes_resp struct {
|
||||||
|
Data []get_processes_resp_data `json:"data"`
|
||||||
|
Total int `json:"total"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type get_processes_resp_data struct {
|
||||||
|
ID int `json:"id"` //序号
|
||||||
|
Repair_id string `json:"repair_id"` //维修订单号
|
||||||
|
P_id string `json:"p_id"` //产品编号
|
||||||
|
P_serial string `json:"p_serial"` //产品序列号
|
||||||
|
Repair_plan string `json:"rp"` //维修方案
|
||||||
|
|
||||||
|
Serial_id int `json:"serial_id"` //工序序号
|
||||||
|
Process_name string `json:"produce_plan"`
|
||||||
|
Process_t string `json:"produce_plan_use_t"`
|
||||||
|
Produce_user string `json:"produce_user"`
|
||||||
|
|
||||||
|
Actual_finished_t string `json:"p_actual_finished_t"`
|
||||||
|
|
||||||
|
State string `json:"state"` //已审核 未审核
|
||||||
|
|
||||||
|
Times int `json:"times"`
|
||||||
|
|
||||||
|
Work string `json:"work"` //工作内容
|
||||||
|
Work_h string `json:"work_h"` //天工时长
|
||||||
|
|
||||||
|
Head string `json:"head"` //负责人
|
||||||
|
}
|
||||||
|
|
||||||
|
type get_processes_req struct {
|
||||||
|
OpUser string `json:"opuser"`
|
||||||
|
OpUserUuid string `json:"opuser_uuid"`
|
||||||
|
Index int `json:"index"`
|
||||||
|
Count int `json:"count"`
|
||||||
|
ID string `json:"id"`
|
||||||
|
Rid string `json:"rid"`
|
||||||
|
If_done bool `json:"if_done"` //已处理
|
||||||
|
|
||||||
|
Repairer string `json:"repairer"` //维修人员
|
||||||
|
Repair_status string `json:"rs"` //维修状态
|
||||||
|
Regional_head string `json:"regional_head"` //区域负责人
|
||||||
|
Material_status string `json:"ms"` //缺料情况
|
||||||
|
|
||||||
|
Sort_field string `json:"sort_field"` //排序字段
|
||||||
|
|
||||||
|
Location string `json:"location"`
|
||||||
|
|
||||||
|
Pid string `json:"pid"`
|
||||||
|
P_name string `json:"pname"`
|
||||||
|
|
||||||
|
Station string `json:"station"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type get_p_process_options_resp struct {
|
||||||
|
Data []process_info `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type get_p_process_options_req struct {
|
||||||
|
OpUser string `json:"opuser"`
|
||||||
|
OpUserUuid string `json:"opuser_uuid"`
|
||||||
|
P_id string `json:"pid"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type post_rs_req struct {
|
||||||
|
OpUser string `json:"opuser"`
|
||||||
|
OpUserUuid string `json:"opuser_uuid"`
|
||||||
|
ID int `json:"id"`
|
||||||
|
State string `json:"rs"`
|
||||||
|
Oper_type int `json:"oper_type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type get_rs_req struct {
|
||||||
|
OpUser string `json:"opuser"`
|
||||||
|
OpUserUuid string `json:"opuser_uuid"`
|
||||||
|
State string `json:"state"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type cal_completion_date_req struct {
|
||||||
|
OpUser string `json:"opuser"`
|
||||||
|
OpUserUuid string `json:"opuser_uuid"`
|
||||||
|
Bt string `json:"bt"`
|
||||||
|
Days string `json:"days"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type remove_ma_plan_req struct {
|
||||||
|
OpUser string `json:"opuser"`
|
||||||
|
OpUserUuid string `json:"opuser_uuid"`
|
||||||
|
ID int `json:"id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type get_ma_username_req struct {
|
||||||
|
OpUser string `json:"opuser"`
|
||||||
|
OpUserUuid string `json:"opuser_uuid"`
|
||||||
|
|
||||||
|
Location string `json:"location"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type get_p_name_req struct {
|
||||||
|
OpUser string `json:"opuser"`
|
||||||
|
OpUserUuid string `json:"opuser_uuid"`
|
||||||
|
P_id string `json:"p_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type get_p_id_options_req struct {
|
||||||
|
OpUser string `json:"opuser"`
|
||||||
|
OpUserUuid string `json:"opuser_uuid"`
|
||||||
|
P_like_id string `json:"p_like_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type update_ma_temp_plan_req struct {
|
||||||
|
OpUser string `json:"opuser"`
|
||||||
|
OpUserUuid string `json:"opuser_uuid"`
|
||||||
|
Plan ma_temp_plan `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type update_ma_plan_req struct {
|
||||||
|
OpUser string `json:"opuser"`
|
||||||
|
OpUserUuid string `json:"opuser_uuid"`
|
||||||
|
Plan ma_plan `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type get_ma_temp_plan_req struct {
|
||||||
|
OpUser string `json:"opuser"`
|
||||||
|
OpUserUuid string `json:"opuser_uuid"`
|
||||||
|
Index int `json:"index"`
|
||||||
|
Count int `json:"count"`
|
||||||
|
ID string `json:"id"`
|
||||||
|
Rid string `json:"rid"` //rdm号
|
||||||
|
|
||||||
|
Head string `json:"head"` //负责人
|
||||||
|
P_id string `json:"p_id"` //产品编号
|
||||||
|
P_name string `json:"p_name"` //产品名称
|
||||||
|
P_serial string `json:"p_serial"` //产品序列号
|
||||||
|
|
||||||
|
Repairer string `json:"repairer"` //维修人员
|
||||||
|
Repair_type string `json:"rt"` //维修类型
|
||||||
|
|
||||||
|
If_done bool `json:"if_done"` //已处理
|
||||||
|
|
||||||
|
If_e1 bool `json:"if_e1"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type get_ma_plan_req struct {
|
||||||
|
OpUser string `json:"opuser"`
|
||||||
|
OpUserUuid string `json:"opuser_uuid"`
|
||||||
|
Index int `json:"index"`
|
||||||
|
Count int `json:"count"`
|
||||||
|
ID string `json:"id"`
|
||||||
|
Rid string `json:"rid"`
|
||||||
|
If_done bool `json:"if_done"` //已处理
|
||||||
|
|
||||||
|
Repairer string `json:"repairer"` //维修人员
|
||||||
|
Repair_status string `json:"rs"` //维修状态
|
||||||
|
Regional_head string `json:"regional_head"` //区域负责人
|
||||||
|
Material_status string `json:"ms"` //缺料情况
|
||||||
|
|
||||||
|
Sort_field string `json:"sort_field"` //排序字段
|
||||||
|
|
||||||
|
Location string `json:"location"`
|
||||||
|
|
||||||
|
Pid string `json:"pid"`
|
||||||
|
P_name string `json:"pname"`
|
||||||
|
|
||||||
|
Station string `json:"station"`
|
||||||
|
|
||||||
|
Bt string `json:"bt"`
|
||||||
|
Et string `json:"et"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type import_ma_temp_plan_Req struct {
|
||||||
|
OpUser string `json:"opuser"`
|
||||||
|
OpUserUuid string `json:"opuser_uuid"`
|
||||||
|
Plan []ma_temp_plan `json:"plan"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type import_ma_plan_Req struct {
|
||||||
|
OpUser string `json:"opuser"`
|
||||||
|
OpUserUuid string `json:"opuser_uuid"`
|
||||||
|
Plan []ma_plan `json:"plan"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type del_process_req struct {
|
||||||
|
OpUser string `json:"opuser"`
|
||||||
|
OpUserUuid string `json:"opuser_uuid"`
|
||||||
|
Ids []process_info `json:"ids"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type update_process_req struct {
|
||||||
|
OpUser string `json:"opuser"`
|
||||||
|
OpUserUuid string `json:"opuser_uuid"`
|
||||||
|
Data process_info `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type import_process_req struct {
|
||||||
|
OpUser string `json:"opuser"`
|
||||||
|
OpUserUuid string `json:"opuser_uuid"`
|
||||||
|
Data []process_info `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type get_process_req struct {
|
||||||
|
OpUser string `json:"opuser"`
|
||||||
|
OpUserUuid string `json:"opuser_uuid"`
|
||||||
|
P_id string `json:"p_id"`
|
||||||
|
P_name string `json:"p_name"`
|
||||||
|
Process_name string `json:"process_name"`
|
||||||
|
Index int `json:"index"`
|
||||||
|
Count int `json:"count"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type import_p_Req struct {
|
||||||
|
OpUser string `json:"opuser"`
|
||||||
|
OpUserUuid string `json:"opuser_uuid"`
|
||||||
|
Data []p_sap `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type del_p_req struct {
|
||||||
|
OpUser string `json:"opuser"`
|
||||||
|
OpUserUuid string `json:"opuser_uuid"`
|
||||||
|
Ids []p_sap `json:"ids"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type post_p_req struct {
|
||||||
|
OpUser string `json:"opuser"`
|
||||||
|
OpUserUuid string `json:"opuser_uuid"`
|
||||||
|
Id int `json:"id"`
|
||||||
|
P_id string `json:"p_id"`
|
||||||
|
P_name string `json:"p_name"`
|
||||||
|
OperType int `json:"oper_type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type get_p_Req struct {
|
||||||
|
OpUser string `json:"opuser"`
|
||||||
|
OpUserUuid string `json:"opuser_uuid"`
|
||||||
|
P_id string `json:"p_id"`
|
||||||
|
P_name string `json:"p_name"`
|
||||||
|
Index int `json:"index"`
|
||||||
|
Count int `json:"count"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type download_template_file_Req struct {
|
||||||
|
OpUser string `json:"opuser"`
|
||||||
|
OpUserUuid string `json:"opuser_uuid"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type getUserNamesReq struct {
|
||||||
|
OpUser string `json:"opuser"`
|
||||||
|
OpUserUuid string `json:"opuser_uuid"`
|
||||||
|
}
|
||||||
|
|
||||||
|
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"`
|
||||||
|
State string `json:"state"`
|
||||||
|
Location string `json:"location"`
|
||||||
|
}
|
||||||
|
|
||||||
|
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 GetMenuReq struct {
|
||||||
|
UserName string `json:"username"`
|
||||||
|
Uuid string `json:"uuid"`
|
||||||
|
}
|
||||||
|
|
||||||
|
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"`
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,160 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
type get_rs_resp struct {
|
||||||
|
Data []Repair_state `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Repair_state struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
Rs string `json:"rs"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type cal_completion_date_resp struct {
|
||||||
|
Completion_date string `json:"completion_date"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type get_ma_username_resp struct {
|
||||||
|
Data []string `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type get_p_name_resp struct {
|
||||||
|
P_name string `json:"p_name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type get_p_id_options_resp struct {
|
||||||
|
Data []string `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type get_ma_temp_plan_resp struct {
|
||||||
|
Data []ma_temp_plan `json:"data"`
|
||||||
|
Total int `json:"total"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type get_ma_plan_resp struct {
|
||||||
|
Data []ma_plan `json:"data"`
|
||||||
|
Total int `json:"total"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type get_process_resp struct {
|
||||||
|
Data []process_info `json:"data"`
|
||||||
|
Total int `json:"total"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type process_info struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
P_id string `json:"p_id"`
|
||||||
|
P_name string `json:"p_name"`
|
||||||
|
Process_name string `json:"process_name"`
|
||||||
|
Process_t string `json:"process_t"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type upload_resp struct {
|
||||||
|
Ret int `json:"ret"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type get_pf_Resp struct {
|
||||||
|
Data []plan_file `json:"data"`
|
||||||
|
Total int `json:"total"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type plan_file struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
P_id string `json:"p_id"`
|
||||||
|
P_name string `json:"p_name"`
|
||||||
|
Plan_name string `json:"plan_name"`
|
||||||
|
|
||||||
|
Plan_process_file string `json:"plan_process_file"`
|
||||||
|
Filing_time string `json:"filing_time"`
|
||||||
|
Filing_user string `json:"filing_user"`
|
||||||
|
Project_file string `json:"project_file"`
|
||||||
|
P_filing_time string `json:"p_filing_time"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type import_p_resp PostUserResp
|
||||||
|
|
||||||
|
type del_p_resp PostUserResp
|
||||||
|
|
||||||
|
type post_p_resp PostUserResp
|
||||||
|
|
||||||
|
type get_p_Resp struct {
|
||||||
|
Data []p_sap `json:"data"`
|
||||||
|
Total int `json:"total"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type p_sap struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
P_id string `json:"p_id"`
|
||||||
|
P_name string `json:"p_name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type download_file_Resp struct {
|
||||||
|
FileId string `json:"fileId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type getUserNamesResp struct {
|
||||||
|
Names []usernams `json:"names"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type usernams struct {
|
||||||
|
Value string `json:"value"`
|
||||||
|
Label string `json:"label"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type PostUserResp struct {
|
||||||
|
Ret int `json:"r"`
|
||||||
|
}
|
||||||
|
|
||||||
|
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 LoginResp struct {
|
||||||
|
Ret int `json:"r"`
|
||||||
|
Uuid string `json:"uuid"`
|
||||||
|
RoleId int `json:"roleid"`
|
||||||
|
Url string `json:"url"`
|
||||||
|
DId int `json:"did"`
|
||||||
|
Location string `json:"loc"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetUsersResp struct {
|
||||||
|
Data []useInfo `json:"data"`
|
||||||
|
Total int `json:"total"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type useInfo struct {
|
||||||
|
Userid int `json:"userid"`
|
||||||
|
Username string `json:"username"`
|
||||||
|
Password string `json:"password"`
|
||||||
|
RoleName string `json:"rolename"`
|
||||||
|
RoleId int `json:"roleid"`
|
||||||
|
Department string `json:"department"`
|
||||||
|
DepartmentId int `json:"departmentid"`
|
||||||
|
State string `json:"state"`
|
||||||
|
Location string `json:"location"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CommonResp struct {
|
||||||
|
Ret int `json:"r"`
|
||||||
|
Context string `json:"context"`
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,89 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"database/sql"
|
||||||
|
|
||||||
|
"github.com/astaxie/beego/logs"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
file_cache_data map[string]plan_file
|
||||||
|
file_cache_time string
|
||||||
|
|
||||||
|
file_ch chan int
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
file_cache_data = make(map[string]plan_file)
|
||||||
|
file_cache_time = "2023-01-01 00:00:00"
|
||||||
|
|
||||||
|
file_ch = make(chan int, 100)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func sync_file_cache() {
|
||||||
|
|
||||||
|
var sqlstr string
|
||||||
|
var rdRow *sql.Rows
|
||||||
|
var err error
|
||||||
|
|
||||||
|
sqlstr = fmt.Sprintf("select [ID],[p_id],[p_name],[plan_name],[process_file],[filing_time],[project_file],[p_filing_time],[op_time] from [plan_file] order by ID asc")
|
||||||
|
fmt.Println(sqlstr)
|
||||||
|
|
||||||
|
rdRow, err = sqlConn.Query(sqlstr)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error(fmt.Sprintf("sync_file_cache Query err:%v", err.Error()))
|
||||||
|
goto exit
|
||||||
|
}
|
||||||
|
|
||||||
|
for rdRow.Next() {
|
||||||
|
var d plan_file
|
||||||
|
var op_t string
|
||||||
|
if err := rdRow.Scan(&d.ID, &d.P_id, &d.P_name, &d.Plan_name, &d.Plan_process_file, &d.Filing_time, &d.Project_file, &d.P_filing_time, &op_t); err == nil {
|
||||||
|
file_cache_data[d.P_id+d.Plan_name] = d
|
||||||
|
|
||||||
|
if op_t > file_cache_time {
|
||||||
|
file_cache_time = op_t
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logs.Error("sync_file_cache scan Error", err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rdRow.Close()
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-file_ch:
|
||||||
|
sqlstr = fmt.Sprintf("select [ID],[p_id],[p_name],[plan_name],[process_file],[filing_time],[project_file],[p_filing_time],[op_time] from [plan_file] where [op_time]>'%s' order by ID asc", file_cache_time)
|
||||||
|
fmt.Println(sqlstr)
|
||||||
|
|
||||||
|
rdRow, err = sqlConn.Query(sqlstr)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error(fmt.Sprintf("sync_file_cache Query err:%v", err.Error()))
|
||||||
|
} else {
|
||||||
|
for rdRow.Next() {
|
||||||
|
var d plan_file
|
||||||
|
var op_t string
|
||||||
|
if err := rdRow.Scan(&d.ID, &d.P_id, &d.P_name, &d.Plan_name, &d.Plan_process_file, &d.Filing_time, &d.Project_file, &d.P_filing_time, &op_t); err == nil {
|
||||||
|
file_cache_data[d.P_id+d.Plan_name] = d
|
||||||
|
|
||||||
|
if op_t > file_cache_time {
|
||||||
|
file_cache_time = op_t
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logs.Error("sync_file_cache scan Error", err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rdRow.Close()
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
time.Sleep(time.Second * 5)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exit:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
@ -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 int `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)
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue