Pārlūkot izejas kodu

自动建立表-toekn

qdy 1 mēnesi atpakaļ
vecāks
revīzija
467d1dc97d
8 mainītis faili ar 268 papildinājumiem un 62 dzēšanām
  1. Binārs
      .DS_Store
  2. 66
    5
      go.mod
  3. 103
    3
      go.sum
  4. 64
    25
      main.go
  5. 16
    13
      service/create_config_template.go
  6. 15
    12
      service/query_yaml_configure.go
  7. 2
    2
      test/my_init_template_test.go
  8. 2
    2
      test/my_post_query_test.go

Binārs
.DS_Store Parādīt failu


+ 66
- 5
go.mod Parādīt failu

@@ -5,13 +5,74 @@ go 1.25.4
5 5
 require (
6 6
 	git.x2erp.com/qdy/go-base v0.1.70
7 7
 	git.x2erp.com/qdy/go-db v0.1.70
8
+	github.com/jmoiron/sqlx v1.4.0
8 9
 	go-micro.dev/v4 v4.11.0
9 10
 )
10 11
 
11 12
 require (
12
-	github.com/kr/pretty v0.3.1 // indirect
13
-	github.com/rogpeppe/go-internal v1.14.1 // indirect
14
-	gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
13
+	dario.cat/mergo v1.0.2 // indirect
14
+	filippo.io/edwards25519 v1.1.0 // indirect
15
+	github.com/Microsoft/go-winio v0.6.2 // indirect
16
+	github.com/ProtonMail/go-crypto v1.3.0 // indirect
17
+	github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da // indirect
18
+	github.com/bitly/go-simplejson v0.5.1 // indirect
19
+	github.com/cloudflare/circl v1.6.1 // indirect
20
+	github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
21
+	github.com/cyphar/filepath-securejoin v0.6.1 // indirect
22
+	github.com/emirpasic/gods v1.18.1 // indirect
23
+	github.com/fatih/color v1.9.0 // indirect
24
+	github.com/fsnotify/fsnotify v1.9.0 // indirect
25
+	github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
26
+	github.com/go-git/go-billy/v5 v5.6.2 // indirect
27
+	github.com/go-git/go-git/v5 v5.16.4 // indirect
28
+	github.com/go-micro/plugins/v4/registry/consul v1.2.1 // indirect
29
+	github.com/go-resty/resty/v2 v2.17.0 // indirect
30
+	github.com/go-sql-driver/mysql v1.9.3 // indirect
31
+	github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
32
+	github.com/golang-sql/sqlexp v0.1.0 // indirect
33
+	github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
34
+	github.com/golang/protobuf v1.5.4 // indirect
35
+	github.com/google/uuid v1.6.0 // indirect
36
+	github.com/hashicorp/consul/api v1.9.0 // indirect
37
+	github.com/hashicorp/go-cleanhttp v0.5.1 // indirect
38
+	github.com/hashicorp/go-hclog v0.12.0 // indirect
39
+	github.com/hashicorp/go-immutable-radix v1.0.0 // indirect
40
+	github.com/hashicorp/go-rootcerts v1.0.2 // indirect
41
+	github.com/hashicorp/golang-lru v0.5.3 // indirect
42
+	github.com/hashicorp/serf v0.9.5 // indirect
43
+	github.com/imdario/mergo v0.3.16 // indirect
44
+	github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
45
+	github.com/kevinburke/ssh_config v1.4.0 // indirect
46
+	github.com/klauspost/cpuid/v2 v2.3.0 // indirect
47
+	github.com/lib/pq v1.10.9 // indirect
48
+	github.com/mattn/go-colorable v0.1.8 // indirect
49
+	github.com/mattn/go-isatty v0.0.20 // indirect
50
+	github.com/microsoft/go-mssqldb v1.9.4 // indirect
51
+	github.com/miekg/dns v1.1.68 // indirect
52
+	github.com/mitchellh/go-homedir v1.1.0 // indirect
53
+	github.com/mitchellh/hashstructure v1.1.0 // indirect
54
+	github.com/mitchellh/mapstructure v1.3.3 // indirect
55
+	github.com/nxadm/tail v1.4.11 // indirect
56
+	github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect
57
+	github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
58
+	github.com/pjbgf/sha1cd v0.5.0 // indirect
59
+	github.com/pkg/errors v0.9.1 // indirect
60
+	github.com/russross/blackfriday/v2 v2.1.0 // indirect
61
+	github.com/sergi/go-diff v1.4.0 // indirect
62
+	github.com/sijms/go-ora/v2 v2.9.0 // indirect
63
+	github.com/skeema/knownhosts v1.3.2 // indirect
64
+	github.com/urfave/cli/v2 v2.27.7 // indirect
65
+	github.com/xanzy/ssh-agent v0.3.3 // indirect
66
+	github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 // indirect
67
+	golang.org/x/crypto v0.46.0 // indirect
68
+	golang.org/x/mod v0.32.0 // indirect
69
+	golang.org/x/net v0.48.0 // indirect
70
+	golang.org/x/sync v0.19.0 // indirect
71
+	golang.org/x/sys v0.39.0 // indirect
72
+	golang.org/x/text v0.32.0 // indirect
73
+	golang.org/x/tools v0.40.0 // indirect
74
+	google.golang.org/protobuf v1.36.10 // indirect
75
+	gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
76
+	gopkg.in/warnings.v0 v0.1.2 // indirect
77
+	gopkg.in/yaml.v2 v2.4.0 // indirect
15 78
 )
16
-
17
-require gopkg.in/yaml.v2 v2.4.0 // indirect

+ 103
- 3
go.sum Parādīt failu

@@ -1,14 +1,114 @@
1
-git.x2erp.com/qdy/go-base v0.1.44 h1:xHpMppSNj79lqdUc+lmgGXOgEvHyNotUayoe5/hHWr4=
2
-git.x2erp.com/qdy/go-base v0.1.44/go.mod h1:Q+YLwpCoU8CVSnzATLdz2LAzVMlz/CEGzo8DePf7cug=
3
-github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
1
+dario.cat/mergo v1.0.2 h1:85+piFYR1tMbRrLcDwR18y4UKJ3aH1Tbzi24VRW1TK8=
2
+filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
3
+git.x2erp.com/qdy/go-base v0.1.70 h1:P5IOfSN6CnXcBYIrs+4BULYemPyzcgrFMkI7TcCri5A=
4
+git.x2erp.com/qdy/go-db v0.1.70 h1:5VfvFxCmQ0+9OFEaPrTODYJ99wam+4lPjz4Y024SUdc=
5
+github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.0 h1:Gt0j3wceWMwPmiazCa8MzMA0MfhmPIz0Qp0FJ6qcM0U=
6
+github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.1 h1:B+blDbyVIG3WaikNxPnhPiJ1MThR03b3vKGtER95TP4=
7
+github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.1 h1:FPKJS1T+clwv+OLGt13a8UjqeRuh0O4SJ3lUriThc+4=
8
+github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.3.1 h1:Wgf5rZba3YZqeTNJPtvqZoBu1sBN/L4sry+u2U3Y75w=
9
+github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.1.1 h1:bFWuoEKg+gImo7pvkiQEFAc8ocibADgXeiLAxWhWmkI=
10
+github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 h1:oygO0locgZJe7PpYPXT5A29ZkwJaPqcva7BVeemZOZs=
11
+github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
12
+github.com/ProtonMail/go-crypto v1.3.0 h1:ILq8+Sf5If5DCpHQp4PbZdS1J7HDFRXz/+xKBiRGFrw=
13
+github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
14
+github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da h1:8GUt8eRujhVEGZFFEjBj46YV4rDjvGrNxb0KMWYkL2I=
15
+github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
16
+github.com/bitly/go-simplejson v0.5.1 h1:xgwPbetQScXt1gh9BmoJ6j9JMr3TElvuIyjR8pgdoow=
17
+github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ0=
18
+github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo=
19
+github.com/cyphar/filepath-securejoin v0.6.1 h1:5CeZ1jPXEiYt3+Z6zqprSAgSWiggmpVyciv8syjIpVE=
20
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
21
+github.com/elazarl/goproxy v1.7.2 h1:Y2o6urb7Eule09PjlhQRGNsqRfPmYI3KKQLFpCAV3+o=
22
+github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
23
+github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s=
24
+github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
25
+github.com/gliderlabs/ssh v0.3.8 h1:a4YXD1V7xMF9g5nTkdfnja3Sxy1PVDCj1Zg4Wb8vY6c=
26
+github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
27
+github.com/go-git/go-billy/v5 v5.6.2 h1:6Q86EsPXMa7c3YZ3aLAQsMA0VlWmy43r6FHqa/UNbRM=
28
+github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4=
29
+github.com/go-git/go-git/v5 v5.16.4 h1:7ajIEZHZJULcyJebDLo99bGgS0jRrOxzZG4uCk2Yb2Y=
30
+github.com/go-micro/plugins/v4/registry/consul v1.2.1 h1:3wctYMtstwQLCjoJ1HA6mKGGFF1hcdKDv5MzHakB1jE=
31
+github.com/go-resty/resty/v2 v2.17.0 h1:pW9DeXcaL4Rrym4EZ8v7L19zZiIlWPg5YXAcVmt+gN0=
32
+github.com/go-sql-driver/mysql v1.9.3 h1:U/N249h2WzJ3Ukj8SowVFjdtZKfu9vlLZxjPXV1aweo=
33
+github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
34
+github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA=
35
+github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A=
36
+github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ=
37
+github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
38
+github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo=
39
+github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
40
+github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
41
+github.com/hashicorp/consul/api v1.9.0 h1:T6dKIWcaihG2c21YUi0BMAHbJanVXiYuz+mPgqxY3N4=
42
+github.com/hashicorp/consul/sdk v0.8.0 h1:OJtKBtEjboEZvG6AOUdh4Z1Zbyu0WcxQ0qatRrZHTVU=
43
+github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
44
+github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM=
45
+github.com/hashicorp/go-hclog v0.12.0 h1:d4QkX8FRTYaKaCZBoXYY8zJX2BXjWxurN/GA2tkrmZM=
46
+github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0=
47
+github.com/hashicorp/go-msgpack v0.5.3 h1:zKjpN5BK/P5lMYrLmBHdBULWbJ0XpYR+7NGzqkZzoD4=
48
+github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
49
+github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc=
50
+github.com/hashicorp/go-sockaddr v1.0.0 h1:GeH6tui99pF4NJgfnhp+L6+FfobzVW3Ah46sLo0ICXs=
51
+github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
52
+github.com/hashicorp/golang-lru v0.5.3 h1:YPkqC67at8FYaadspW/6uE0COsBxS2656RLEr8Bppgk=
53
+github.com/hashicorp/memberlist v0.2.2 h1:5+RffWKwqJ71YPu9mWsF7ZOscZmwfasdA8kbdC7AO2g=
54
+github.com/hashicorp/serf v0.9.5 h1:EBWvyu9tcRszt3Bxp3KNssBMP1KuHWyO51lz9+786iM=
55
+github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4=
56
+github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
57
+github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
58
+github.com/kevinburke/ssh_config v1.4.0 h1:6xxtP5bZ2E4NF5tuQulISpTO2z8XbtH8cg1PWkxoFkQ=
59
+github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
4 60
 github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
5 61
 github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
6 62
 github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
7 63
 github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
8 64
 github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
65
+github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
66
+github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
67
+github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
68
+github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
69
+github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
70
+github.com/microsoft/go-mssqldb v1.9.4 h1:sHrj3GcdgkxytZ09aZ3+ys72pMeyEXJowT44j74pNgs=
71
+github.com/miekg/dns v1.1.68 h1:jsSRkNozw7G/mnmXULynzMNIsgY2dHC8LO6U6Ij2JEA=
72
+github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
73
+github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0=
74
+github.com/mitchellh/hashstructure v1.1.0 h1:P6P1hdjqAAknpY/M1CGipelZgp+4y9ja9kmUZPXP+H0=
75
+github.com/mitchellh/mapstructure v1.3.3 h1:SzB1nHZ2Xi+17FP0zVQBHIZqvwRN9408fJO8h+eeNA8=
76
+github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY=
77
+github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k=
78
+github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw=
79
+github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c h1:Lgl0gzECD8GnQ5QCWA8o6BtfL6mDH5rQgM4/fX3avOs=
80
+github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
81
+github.com/pjbgf/sha1cd v0.5.0 h1:a+UkboSi1znleCDUNT3M5YxjOnN1fz2FhN48FlwCxs0=
82
+github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
83
+github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
84
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
9 85
 github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
86
+github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
87
+github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I=
88
+github.com/sergi/go-diff v1.4.0 h1:n/SP9D5ad1fORl+llWyN+D6qoUETXNZARKjyY2/KVCw=
89
+github.com/sijms/go-ora/v2 v2.9.0 h1:+iQbUeTeCOFMb5BsOMgUhV8KWyrv9yjKpcK4x7+MFrg=
90
+github.com/skeema/knownhosts v1.3.2 h1:EDL9mgf4NzwMXCTfaxSD/o/a5fxDw/xL9nkU28JjdBg=
91
+github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
92
+github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
93
+github.com/urfave/cli/v2 v2.27.7 h1:bH59vdhbjLv3LAvIu6gd0usJHgoTTPhCFib8qqOwXYU=
94
+github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
95
+github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 h1:FnBeRrxr7OU4VvAzt5X7s6266i6cSVkkFPS0TuXWbIg=
10 96
 go-micro.dev/v4 v4.11.0 h1:DZ2xcr0pnZJDlp6MJiCLhw4tXRxLw9xrJlPT91kubr0=
97
+golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU=
98
+golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8=
99
+golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c=
100
+golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU=
101
+golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
102
+golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
103
+golang.org/x/term v0.38.0 h1:PQ5pkm/rLO6HnxFR7N2lJHOZX6Kez5Y1gDSJla6jo7Q=
104
+golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
105
+golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
106
+golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA=
107
+google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
11 108
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
12 109
 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
110
+gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
111
+gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
13 112
 gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
14 113
 gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
114
+gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

+ 64
- 25
main.go Parādīt failu

@@ -2,55 +2,94 @@ package main
2 2
 
3 3
 import (
4 4
 	"log"
5
-	"net/http"
6 5
 
7
-	"git.x2erp.com/qdy/go-base/bootstraps"
6
+	"git.x2erp.com/qdy/go-base/config"
7
+	"git.x2erp.com/qdy/go-base/container"
8
+	"git.x2erp.com/qdy/go-base/ctx"
9
+	"git.x2erp.com/qdy/go-base/graceful"
10
+	"git.x2erp.com/qdy/go-base/logger"
8 11
 	"git.x2erp.com/qdy/go-base/middleware"
12
+	"git.x2erp.com/qdy/go-base/model/request"
13
+	"git.x2erp.com/qdy/go-base/model/response"
14
+	"git.x2erp.com/qdy/go-base/webx"
15
+	"git.x2erp.com/qdy/go-base/webx/router"
9 16
 	"git.x2erp.com/qdy/go-db/factory/database"
10
-	"git.x2erp.com/qdy/go-db/myhandle"
17
+
11 18
 	"git.x2erp.com/qdy/go-db/sqldef"
12
-	"go-micro.dev/v4/web"
13 19
 
14 20
 	"git.x2erp.com/qdy/go-svc-configure/service"
15 21
 	_ "git.x2erp.com/qdy/go-svc-configure/tables" // 导入表定义包,触发 init() 函数
16 22
 )
17 23
 
18 24
 var (
19
-	serviceName    = "svc-configure"
20
-	serviceVersion = "1"
25
+	appName    = "svc-configure"
26
+	appVersion = "1"
21 27
 )
22 28
 
23 29
 func main() {
30
+	// 0. 初始化日志
31
+	logBootFactory := logger.InitBootLog()
32
+
33
+	// 1. 获取配置文件
34
+	cfg := config.GetConfig()
35
+	cfg.SetAppName(appName)
36
+	cfg.SetAppVersion(appVersion)
37
+
38
+	// 2. 创建关闭容器
39
+	ctr := container.NewContainer(cfg)
40
+
41
+	// 注册日志,实现自动关闭
42
+	container.Reg(ctr, logBootFactory)
43
+
44
+	// 3. 创建数据库工厂
45
+	dbFactory := container.Create(ctr, database.CreateDBFactory)
46
+	dbFactory.TestConnection()
47
+	// 创建表
48
+	creteTabel(dbFactory)
24 49
 
25
-	// 创建服务启动器
26
-	bootstrapper := bootstraps.NewServiceBootstrapper(serviceName, serviceVersion)
50
+	//启用运行日志
51
+	container.Create(ctr, logger.InitRuntimeLogger)
27 52
 
28
-	//加载配置
29
-	bootstrapper.InitConfig()
53
+	//建立httpservice
54
+	//得到webservice服务工厂
55
+	webxFactory := webx.GetWebServiceFactory()
30 56
 
31
-	//构建数据库工厂
32
-	bootstrapper.InitDatabase()
57
+	//建立hhtpService服务
58
+	webServcie, _ := webxFactory.CreateService(cfg.GetServiceConfig())
33 59
 
34
-	//创建表到数据库
35
-	creteTabel(bootstrapper.DbFactory)
60
+	//建立路由-api
61
+	routerService := router.NewWebService(webServcie.GetRouter())
62
+	//注册路由--api
63
+	registerRoutes(routerService, dbFactory)
36 64
 
37
-	// 启动服务,传入路由注册函数
38
-	bootstrapper.Run(registerRoutes)
65
+	//启动服务
66
+	webServcie.Run()
67
+
68
+	//等待关闭
69
+	graceful.WaitForShutdown(cfg.GetServiceConfig().ServiceName, ctr, webServcie.GetServer())
39 70
 
40 71
 }
41 72
 
42 73
 // 注册所有路由
43
-func registerRoutes(webService web.Service, dbFactory *database.DBFactory) {
74
+func registerRoutes(ws *router.RouterService, dbFactory *database.DBFactory) {
75
+
76
+	ws.POST("/api/query/yaml",
77
+		func(req request.QueryRequest, reqCtx *ctx.RequestContext) (*response.QueryResult[map[string]interface{}], error) {
78
+
79
+			result := service.QueryYamlConfigure(dbFactory, req, reqCtx)
80
+
81
+			return result, nil
82
+		},
83
+	).Use(middleware.JWTAuthMiddleware).Register()
84
+
85
+	ws.POST("/api/init/config/template",
86
+		func(req request.QueryRequest, reqCtx *ctx.RequestContext) (*response.QueryResult[map[string]interface{}], error) {
44 87
 
45
-	// 查询yaml配置文件
46
-	webService.Handle("/api/query/yaml", middleware.JWTAuthMiddleware(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
47
-		myhandle.QueryHandlerMap(w, r, dbFactory, service.QueryYamlConfigure)
48
-	})))
88
+			result := service.InitConfigTemplates(dbFactory, req, reqCtx)
49 89
 
50
-	// 初始化配置模版
51
-	webService.Handle("/api/init/config/template", middleware.JWTAuthMiddleware(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
52
-		myhandle.QueryHandlerMap(w, r, dbFactory, service.InitConfigTemplates)
53
-	})))
90
+			return result, nil
91
+		},
92
+	).Use(middleware.JWTAuthMiddleware).Register()
54 93
 
55 94
 }
56 95
 

+ 16
- 13
service/create_config_template.go Parādīt failu

@@ -6,20 +6,23 @@ import (
6 6
 
7 7
 	"git.x2erp.com/qdy/go-base/ctx"
8 8
 	"git.x2erp.com/qdy/go-base/logger"
9
-	"git.x2erp.com/qdy/go-base/myservice"
10
-	"git.x2erp.com/qdy/go-base/types"
9
+	"git.x2erp.com/qdy/go-base/model/request"
10
+	"git.x2erp.com/qdy/go-base/model/response"
11
+
12
+	"git.x2erp.com/qdy/go-base/util"
13
+
11 14
 	"git.x2erp.com/qdy/go-db/factory/database"
12 15
 	"git.x2erp.com/qdy/go-svc-configure/models"
13 16
 	"github.com/jmoiron/sqlx"
14 17
 )
15 18
 
16
-func InitConfigTemplates(dbFactory *database.DBFactory, req types.QueryRequest, reqCtx *ctx.RequestContext) *types.QueryResult[map[string]interface{}] {
19
+func InitConfigTemplates(dbFactory *database.DBFactory, req request.QueryRequest, reqCtx *ctx.RequestContext) *response.QueryResult[map[string]interface{}] {
17 20
 	return initConfigTemplates(dbFactory.GetDB(), reqCtx)
18 21
 
19 22
 }
20 23
 
21 24
 // InitConfigTemplates 初始化默认配置信息
22
-func initConfigTemplates(db *sqlx.DB, reqCtx *ctx.RequestContext) *types.QueryResult[map[string]interface{}] {
25
+func initConfigTemplates(db *sqlx.DB, reqCtx *ctx.RequestContext) *response.QueryResult[map[string]interface{}] {
23 26
 
24 27
 	builder := models.NewConfigTemplateBuilder()
25 28
 
@@ -129,23 +132,23 @@ func initConfigTemplates(db *sqlx.DB, reqCtx *ctx.RequestContext) *types.QueryRe
129 132
 	return createOrUpdateConfigTemplates(db, templates, reqCtx)
130 133
 }
131 134
 
132
-func CreateOrUpdateConfigTemplates(dbFactory *database.DBFactory, req *models.ConfigTemplate, reqCtx *ctx.RequestContext) *types.QueryResult[map[string]interface{}] {
135
+func CreateOrUpdateConfigTemplates(dbFactory *database.DBFactory, req *models.ConfigTemplate, reqCtx *ctx.RequestContext) *response.QueryResult[map[string]interface{}] {
133 136
 	configTemplates := []*models.ConfigTemplate{req}
134 137
 	return createOrUpdateConfigTemplates(dbFactory.GetDB(), configTemplates, reqCtx)
135 138
 
136 139
 }
137 140
 
138 141
 // CreateOrUpdateConfigTemplates 创建或更新配置模板(支持部分更新)
139
-func createOrUpdateConfigTemplates(db *sqlx.DB, templates []*models.ConfigTemplate, reqCtx *ctx.RequestContext) *types.QueryResult[map[string]interface{}] {
140
-	startTime := time.Now()
142
+func createOrUpdateConfigTemplates(db *sqlx.DB, templates []*models.ConfigTemplate, reqCtx *ctx.RequestContext) *response.QueryResult[map[string]interface{}] {
143
+
141 144
 	if db == nil {
142
-		return myservice.CreateErrorResult[map[string]interface{}]("database connection is nil", startTime, reqCtx)
145
+		return util.CreateErrorResult[map[string]interface{}]("database connection is nil", reqCtx)
143 146
 	}
144 147
 
145 148
 	// 开始事务
146 149
 	tx, err := db.Beginx()
147 150
 	if err != nil {
148
-		return myservice.CreateErrorResult[map[string]interface{}](fmt.Sprintf("begin transaction failed: %v", err), startTime, reqCtx)
151
+		return util.CreateErrorResult[map[string]interface{}](fmt.Sprintf("begin transaction failed: %v", err), reqCtx)
149 152
 	}
150 153
 	defer func() {
151 154
 		if err != nil {
@@ -165,14 +168,14 @@ func createOrUpdateConfigTemplates(db *sqlx.DB, templates []*models.ConfigTempla
165 168
 		// 1. 插入或更新模板主表
166 169
 		err := upsertTemplate(tx, template, now, reqCtx)
167 170
 		if err != nil {
168
-			return myservice.CreateErrorResult[map[string]interface{}](fmt.Sprintf("upsertTemplate: %v", err), startTime, reqCtx)
171
+			return util.CreateErrorResult[map[string]interface{}](fmt.Sprintf("upsertTemplate: %v", err), reqCtx)
169 172
 		}
170 173
 
171 174
 		// 2. 处理模板详情(部分更新)
172 175
 		if len(template.Details) > 0 {
173 176
 			err = upsertTemplateDetails(tx, template.Details, now)
174 177
 			if err != nil {
175
-				return myservice.CreateErrorResult[map[string]interface{}](fmt.Sprintf("upsertTemplateDetails: %v", err), startTime, reqCtx)
178
+				return util.CreateErrorResult[map[string]interface{}](fmt.Sprintf("upsertTemplateDetails: %v", err), reqCtx)
176 179
 
177 180
 			}
178 181
 		}
@@ -180,10 +183,10 @@ func createOrUpdateConfigTemplates(db *sqlx.DB, templates []*models.ConfigTempla
180 183
 
181 184
 	errCommit := tx.Commit()
182 185
 	if errCommit != nil {
183
-		return myservice.CreateErrorResult[map[string]interface{}](fmt.Sprintf("db commit: %v", errCommit), startTime, reqCtx)
186
+		return util.CreateErrorResult[map[string]interface{}](fmt.Sprintf("db commit: %v", errCommit), reqCtx)
184 187
 	}
185 188
 
186
-	return myservice.CreateSuccessResult[map[string]interface{}](startTime, reqCtx)
189
+	return util.CreateSuccessResult[map[string]interface{}](reqCtx)
187 190
 }
188 191
 
189 192
 // upsertTemplate 插入或更新模板主表

+ 15
- 12
service/query_yaml_configure.go Parādīt failu

@@ -8,25 +8,28 @@ import (
8 8
 
9 9
 	"git.x2erp.com/qdy/go-base/ctx"
10 10
 	"git.x2erp.com/qdy/go-base/logger"
11
-	"git.x2erp.com/qdy/go-base/myservice"
12
-	"git.x2erp.com/qdy/go-base/types"
11
+	"git.x2erp.com/qdy/go-base/model/request"
12
+	"git.x2erp.com/qdy/go-base/model/response"
13
+
14
+	"git.x2erp.com/qdy/go-base/util"
15
+
13 16
 	"git.x2erp.com/qdy/go-db/factory/database"
14 17
 	"github.com/jmoiron/sqlx"
15 18
 )
16 19
 
17
-func QueryYamlConfigure(dbFactory *database.DBFactory, req types.QueryRequest, reqCtx *ctx.RequestContext) *types.QueryResult[map[string]interface{}] {
20
+func QueryYamlConfigure(dbFactory *database.DBFactory, req request.QueryRequest, reqCtx *ctx.RequestContext) *response.QueryResult[map[string]interface{}] {
18 21
 	return query(dbFactory.GetDB(), req, reqCtx)
19 22
 
20 23
 }
21 24
 
22 25
 // QueryYamlConfigure 执行带位置参数的查询
23
-func query(db *sqlx.DB, req types.QueryRequest, reqCtx *ctx.RequestContext) *types.QueryResult[map[string]interface{}] {
26
+func query(db *sqlx.DB, req request.QueryRequest, reqCtx *ctx.RequestContext) *response.QueryResult[map[string]interface{}] {
24 27
 
25 28
 	startTime := time.Now()
26 29
 
27 30
 	// 安全检查
28 31
 	if db == nil {
29
-		return myservice.CreateErrorResult[map[string]interface{}]("database connection is nil", startTime, reqCtx)
32
+		return util.CreateErrorResult[map[string]interface{}]("database connection is nil", reqCtx)
30 33
 	}
31 34
 
32 35
 	sqlStr := `
@@ -43,7 +46,7 @@ func query(db *sqlx.DB, req types.QueryRequest, reqCtx *ctx.RequestContext) *typ
43 46
 	// 执行查询
44 47
 	rows, err := db.Queryx(sqlStr, params...)
45 48
 	if err != nil {
46
-		return myservice.CreateErrorResult[map[string]interface{}](fmt.Sprintf("Query execution failed: %v", err), startTime, reqCtx)
49
+		return util.CreateErrorResult[map[string]interface{}](fmt.Sprintf("Query execution failed: %v", err), reqCtx)
47 50
 	}
48 51
 	defer rows.Close()
49 52
 
@@ -51,16 +54,16 @@ func query(db *sqlx.DB, req types.QueryRequest, reqCtx *ctx.RequestContext) *typ
51 54
 	return processQueryResult(rows, startTime, reqCtx)
52 55
 }
53 56
 
54
-func processQueryResult(rows *sqlx.Rows, startTime time.Time, reqCtx *ctx.RequestContext) *types.QueryResult[map[string]interface{}] {
57
+func processQueryResult(rows *sqlx.Rows, startTime time.Time, reqCtx *ctx.RequestContext) *response.QueryResult[map[string]interface{}] {
55 58
 	// 初始化结果结构体
56
-	result := &types.QueryResult[map[string]interface{}]{
59
+	result := &response.QueryResult[map[string]interface{}]{
57 60
 		Metadata: reqCtx,
58 61
 	}
59 62
 
60 63
 	// 获取列信息
61 64
 	columns, err := rows.Columns()
62 65
 	if err != nil {
63
-		return myservice.CreateErrorResult[map[string]interface{}](fmt.Sprintf("Failed to get columns: %v", err), startTime, reqCtx)
66
+		return util.CreateErrorResult[map[string]interface{}](fmt.Sprintf("Failed to get columns: %v", err), reqCtx)
64 67
 	}
65 68
 
66 69
 	// 存储最终结果:根key -> 内层配置map
@@ -82,7 +85,7 @@ func processQueryResult(rows *sqlx.Rows, startTime time.Time, reqCtx *ctx.Reques
82 85
 
83 86
 		// 扫描行数据
84 87
 		if err := rows.Scan(valuePtrs...); err != nil {
85
-			return myservice.CreateErrorResult[map[string]interface{}](fmt.Sprintf("Scan row %d failed: %v", count, err), startTime, reqCtx)
88
+			return util.CreateErrorResult[map[string]interface{}](fmt.Sprintf("Scan row %d failed: %v", count, err), reqCtx)
86 89
 		}
87 90
 
88 91
 		// 提取当前行的三个核心字段
@@ -109,7 +112,7 @@ func processQueryResult(rows *sqlx.Rows, startTime time.Time, reqCtx *ctx.Reques
109 112
 		// 解析 detailID 获取根key(倒数第3段)
110 113
 		parts := strings.Split(detailID, ".")
111 114
 		if len(parts) < 3 {
112
-			return myservice.CreateErrorResult[map[string]interface{}](fmt.Sprintf("Row %d detailID format error: %s", count, detailID), startTime, reqCtx)
115
+			return util.CreateErrorResult[map[string]interface{}](fmt.Sprintf("Row %d detailID format error: %s", count, detailID), reqCtx)
113 116
 		}
114 117
 
115 118
 		rootKey := parts[len(parts)-3] // 取倒数第3段,例如 "database"
@@ -128,7 +131,7 @@ func processQueryResult(rows *sqlx.Rows, startTime time.Time, reqCtx *ctx.Reques
128 131
 
129 132
 	// 检查行遍历错误
130 133
 	if err := rows.Err(); err != nil {
131
-		return myservice.CreateErrorResult[map[string]interface{}](fmt.Sprintf("Row iteration error: %v", err), startTime, reqCtx)
134
+		return util.CreateErrorResult[map[string]interface{}](fmt.Sprintf("Row iteration error: %v", err), reqCtx)
132 135
 	}
133 136
 
134 137
 	// 构建成功结果

+ 2
- 2
test/my_init_template_test.go Parādīt failu

@@ -5,7 +5,7 @@ import (
5 5
 	"log"
6 6
 	"testing"
7 7
 
8
-	"git.x2erp.com/qdy/go-base/types"
8
+	"git.x2erp.com/qdy/go-base/model/request"
9 9
 	"git.x2erp.com/qdy/go-db/factory/http"
10 10
 )
11 11
 
@@ -39,7 +39,7 @@ func TestInit(t *testing.T) {
39 39
 		"svc-worker",
40 40
 	}
41 41
 	// 准备查询请求
42
-	queryRequest := types.QueryRequest{
42
+	queryRequest := request.QueryRequest{
43 43
 
44 44
 		PositionalParams: queryParams,
45 45
 	}

+ 2
- 2
test/my_post_query_test.go Parādīt failu

@@ -5,7 +5,7 @@ import (
5 5
 	"log"
6 6
 	"testing"
7 7
 
8
-	"git.x2erp.com/qdy/go-base/types"
8
+	"git.x2erp.com/qdy/go-base/model/request"
9 9
 	"git.x2erp.com/qdy/go-db/factory/http"
10 10
 )
11 11
 
@@ -39,7 +39,7 @@ func TestQuery(t *testing.T) {
39 39
 		"svc-worker",
40 40
 	}
41 41
 	// 准备查询请求
42
-	queryRequest := types.QueryRequest{
42
+	queryRequest := request.QueryRequest{
43 43
 
44 44
 		PositionalParams: queryParams,
45 45
 	}

Notiek ielāde…
Atcelt
Saglabāt