Browse Source

mongodb测试通过-推送大版本号

qdy 2 months ago
parent
commit
b30af83bb2

+ 4
- 4
factory/database/db_factory.go View File

9
 	"git.x2erp.com/qdy/go-base/config/subconfigs"
9
 	"git.x2erp.com/qdy/go-base/config/subconfigs"
10
 	"git.x2erp.com/qdy/go-base/ctx"
10
 	"git.x2erp.com/qdy/go-base/ctx"
11
 	"git.x2erp.com/qdy/go-base/logger"
11
 	"git.x2erp.com/qdy/go-base/logger"
12
-	"git.x2erp.com/qdy/go-base/types"
12
+	"git.x2erp.com/qdy/go-base/model/response"
13
 	"git.x2erp.com/qdy/go-db/drivers"
13
 	"git.x2erp.com/qdy/go-db/drivers"
14
 	"git.x2erp.com/qdy/go-db/functions"
14
 	"git.x2erp.com/qdy/go-db/functions"
15
 
15
 
149
 // ========== 快捷操作方法 ==========
149
 // ========== 快捷操作方法 ==========
150
 
150
 
151
 // QueryToJSON 快捷查询,直接返回 JSON 字节流
151
 // QueryToJSON 快捷查询,直接返回 JSON 字节流
152
-func (f *DBFactory) QueryToJSON(sql string, reqCtx *ctx.RequestContext) *types.QueryResult[[]map[string]interface{}] {
152
+func (f *DBFactory) QueryToJSON(sql string, reqCtx *ctx.RequestContext) *response.QueryResult[[]map[string]interface{}] {
153
 	return functions.QueryToJSON(f.db, sql, reqCtx)
153
 	return functions.QueryToJSON(f.db, sql, reqCtx)
154
 }
154
 }
155
 
155
 
156
 // QueryPositionalToJSON 位置参数查询并返回 JSON 字节数据
156
 // QueryPositionalToJSON 位置参数查询并返回 JSON 字节数据
157
-func (f *DBFactory) QueryPositionalToJSON(sql string, params []interface{}, reqCtx *ctx.RequestContext) *types.QueryResult[[]map[string]interface{}] {
157
+func (f *DBFactory) QueryPositionalToJSON(sql string, params []interface{}, reqCtx *ctx.RequestContext) *response.QueryResult[[]map[string]interface{}] {
158
 	return functions.QueryPositionalToJSON(f.db, sql, params, reqCtx)
158
 	return functions.QueryPositionalToJSON(f.db, sql, params, reqCtx)
159
 }
159
 }
160
 
160
 
161
 // QueryParamsNameToJSON 命名参数查询并返回 JSON 字节数据
161
 // QueryParamsNameToJSON 命名参数查询并返回 JSON 字节数据
162
-func (f *DBFactory) QueryParamsNameToJSON(sql string, params map[string]interface{}, reqCtx *ctx.RequestContext) *types.QueryResult[[]map[string]interface{}] {
162
+func (f *DBFactory) QueryParamsNameToJSON(sql string, params map[string]interface{}, reqCtx *ctx.RequestContext) *response.QueryResult[[]map[string]interface{}] {
163
 	return functions.QueryParamsNameToJSON(f.db, sql, params, reqCtx)
163
 	return functions.QueryParamsNameToJSON(f.db, sql, params, reqCtx)
164
 }
164
 }
165
 
165
 

+ 11
- 4
factory/mongodb/mongodb_factory.go View File

11
 	"git.x2erp.com/qdy/go-base/config"
11
 	"git.x2erp.com/qdy/go-base/config"
12
 	"git.x2erp.com/qdy/go-base/config/subconfigs"
12
 	"git.x2erp.com/qdy/go-base/config/subconfigs"
13
 	"git.x2erp.com/qdy/go-base/logger"
13
 	"git.x2erp.com/qdy/go-base/logger"
14
+	"git.x2erp.com/qdy/go-base/model/response"
14
 	"go.mongodb.org/mongo-driver/bson"
15
 	"go.mongodb.org/mongo-driver/bson"
15
 	"go.mongodb.org/mongo-driver/mongo"
16
 	"go.mongodb.org/mongo-driver/mongo"
16
 	"go.mongodb.org/mongo-driver/mongo/options"
17
 	"go.mongodb.org/mongo-driver/mongo/options"
201
 // ========== 快捷操作方法(增强版) ==========
202
 // ========== 快捷操作方法(增强版) ==========
202
 
203
 
203
 // InsertOne 插入单个文档,返回是否成功
204
 // InsertOne 插入单个文档,返回是否成功
204
-func (f *MongoDBFactory) InsertOne(collectionName string, document interface{}) bool {
205
+func (f *MongoDBFactory) InsertOne(collectionName string, document interface{}) (*response.QueryResult[interface{}], error) {
205
 	collection := f.GetCollection(collectionName)
206
 	collection := f.GetCollection(collectionName)
206
 	ctx, cancel := context.WithTimeout(context.Background(), f.config.GetTimeout())
207
 	ctx, cancel := context.WithTimeout(context.Background(), f.config.GetTimeout())
207
 	defer cancel()
208
 	defer cancel()
208
 
209
 
209
-	_, err := collection.InsertOne(ctx, document)
210
+	result, err := collection.InsertOne(ctx, document)
210
 	if err != nil {
211
 	if err != nil {
211
 		logger.Errorf("插入文档失败,集合:%s,错误:%v", collectionName, err)
212
 		logger.Errorf("插入文档失败,集合:%s,错误:%v", collectionName, err)
212
-		return false
213
+		return &response.QueryResult[interface{}]{
214
+			Success: false,
215
+			Error:   err.Error(),
216
+		}, err
213
 	}
217
 	}
214
-	return true
218
+	return &response.QueryResult[interface{}]{
219
+		Success: true,
220
+		Data:    result.InsertedID,
221
+	}, nil
215
 }
222
 }
216
 
223
 
217
 // InsertOneWithResult 插入单个文档并返回结果
224
 // InsertOneWithResult 插入单个文档并返回结果

+ 5
- 4
factory/rabbitmq/consumer_factory.go View File

3
 import (
3
 import (
4
 	"fmt"
4
 	"fmt"
5
 
5
 
6
-	"git.x2erp.com/qdy/go-base/types"
6
+	"git.x2erp.com/qdy/go-base/model/request"
7
+	"git.x2erp.com/qdy/go-base/model/response"
7
 	amqp "github.com/streadway/amqp"
8
 	amqp "github.com/streadway/amqp"
8
 )
9
 )
9
 
10
 
10
 // MessageHandler 消息处理器接口
11
 // MessageHandler 消息处理器接口
11
 type MessageHandler interface {
12
 type MessageHandler interface {
12
-	Process(ueueRequest *types.QueueRequest, body []byte) types.QueryResult[interface{}]
13
+	Process(ueueRequest *request.QueueRequest, body []byte) response.QueryResult[interface{}]
13
 }
14
 }
14
 
15
 
15
 // Consumer 消费者结构体
16
 // Consumer 消费者结构体
17
 	Channel      *amqp.Channel
18
 	Channel      *amqp.Channel
18
 	QueueName    string
19
 	QueueName    string
19
 	Handler      MessageHandler
20
 	Handler      MessageHandler
20
-	QueueRequest *types.QueueRequest
21
+	QueueRequest *request.QueueRequest
21
 }
22
 }
22
 
23
 
23
 // CreateConsumer 创建消费者
24
 // CreateConsumer 创建消费者
24
 // 返回Consumer对象,创建后自动开始消费
25
 // 返回Consumer对象,创建后自动开始消费
25
-func (f *RabbitMQFactory) CreateConsumer(queueRequest *types.QueueRequest, consumerID string, handler MessageHandler) (*Consumer, error) {
26
+func (f *RabbitMQFactory) CreateConsumer(queueRequest *request.QueueRequest, consumerID string, handler MessageHandler) (*Consumer, error) {
26
 	// 生成唯一的通道名称
27
 	// 生成唯一的通道名称
27
 	channelName := fmt.Sprintf("%s_%s", queueRequest.QueueName, consumerID)
28
 	channelName := fmt.Sprintf("%s_%s", queueRequest.QueueName, consumerID)
28
 
29
 

+ 8
- 8
functions/query_json.go View File

6
 	"time"
6
 	"time"
7
 
7
 
8
 	"git.x2erp.com/qdy/go-base/ctx"
8
 	"git.x2erp.com/qdy/go-base/ctx"
9
-	"git.x2erp.com/qdy/go-base/types"
9
+	"git.x2erp.com/qdy/go-base/model/response"
10
 	"github.com/jmoiron/sqlx"
10
 	"github.com/jmoiron/sqlx"
11
 )
11
 )
12
 
12
 
13
 // QueryParamsNameToJSON 执行带命名参数的查询
13
 // QueryParamsNameToJSON 执行带命名参数的查询
14
-func QueryParamsNameToJSON(db *sqlx.DB, sql string, params map[string]interface{}, reqCtx *ctx.RequestContext) *types.QueryResult[[]map[string]interface{}] {
14
+func QueryParamsNameToJSON(db *sqlx.DB, sql string, params map[string]interface{}, reqCtx *ctx.RequestContext) *response.QueryResult[[]map[string]interface{}] {
15
 	startTime := time.Now()
15
 	startTime := time.Now()
16
 
16
 
17
 	if sql == "" {
17
 	if sql == "" {
37
 }
37
 }
38
 
38
 
39
 // QueryPositionalToJSON 执行带位置参数的查询
39
 // QueryPositionalToJSON 执行带位置参数的查询
40
-func QueryPositionalToJSON(db *sqlx.DB, sql string, params []interface{}, reqCtx *ctx.RequestContext) *types.QueryResult[[]map[string]interface{}] {
40
+func QueryPositionalToJSON(db *sqlx.DB, sql string, params []interface{}, reqCtx *ctx.RequestContext) *response.QueryResult[[]map[string]interface{}] {
41
 	startTime := time.Now()
41
 	startTime := time.Now()
42
 
42
 
43
 	//fmt.Printf("positionalParams: %s", params)
43
 	//fmt.Printf("positionalParams: %s", params)
58
 }
58
 }
59
 
59
 
60
 // QueryToJSON 执行无参数的查询
60
 // QueryToJSON 执行无参数的查询
61
-func QueryToJSON(db *sqlx.DB, sql string, reqCtx *ctx.RequestContext) *types.QueryResult[[]map[string]interface{}] {
61
+func QueryToJSON(db *sqlx.DB, sql string, reqCtx *ctx.RequestContext) *response.QueryResult[[]map[string]interface{}] {
62
 	startTime := time.Now()
62
 	startTime := time.Now()
63
 
63
 
64
 	if sql == "" {
64
 	if sql == "" {
77
 }
77
 }
78
 
78
 
79
 // processQueryResult 处理查询结果(公共部分)
79
 // processQueryResult 处理查询结果(公共部分)
80
-func processQueryResult(rows *sql.Rows, startTime time.Time) *types.QueryResult[[]map[string]interface{}] {
80
+func processQueryResult(rows *sql.Rows, startTime time.Time) *response.QueryResult[[]map[string]interface{}] {
81
 
81
 
82
-	result := &types.QueryResult[[]map[string]interface{}]{}
82
+	result := &response.QueryResult[[]map[string]interface{}]{}
83
 	// 获取列信息
83
 	// 获取列信息
84
 	columns, err := rows.Columns()
84
 	columns, err := rows.Columns()
85
 	if err != nil {
85
 	if err != nil {
133
 }
133
 }
134
 
134
 
135
 // createErrorResult 创建错误结果的辅助函数
135
 // createErrorResult 创建错误结果的辅助函数
136
-func createErrorResult(errorMsg string, startTime time.Time, reqCtx *ctx.RequestContext) *types.QueryResult[[]map[string]interface{}] {
137
-	return &types.QueryResult[[]map[string]interface{}]{
136
+func createErrorResult(errorMsg string, startTime time.Time, reqCtx *ctx.RequestContext) *response.QueryResult[[]map[string]interface{}] {
137
+	return &response.QueryResult[[]map[string]interface{}]{
138
 		Success:  false,
138
 		Success:  false,
139
 		Error:    errorMsg,
139
 		Error:    errorMsg,
140
 		Time:     time.Since(startTime).String(),
140
 		Time:     time.Since(startTime).String(),

+ 4
- 1
go.mod View File

4
 go 1.25.4
4
 go 1.25.4
5
 
5
 
6
 require (
6
 require (
7
-	git.x2erp.com/qdy/go-base v0.1.51
7
+	git.x2erp.com/qdy/go-base v0.1.12-20251231-1
8
 	github.com/go-sql-driver/mysql v1.9.3
8
 	github.com/go-sql-driver/mysql v1.9.3
9
 	github.com/lib/pq v1.10.9
9
 	github.com/lib/pq v1.10.9
10
 	github.com/microsoft/go-mssqldb v1.9.4
10
 	github.com/microsoft/go-mssqldb v1.9.4
11
 	github.com/sijms/go-ora/v2 v2.9.0
11
 	github.com/sijms/go-ora/v2 v2.9.0
12
+	go.uber.org/zap v1.27.1
12
 )
13
 )
13
 
14
 
14
 require (
15
 require (
21
 	github.com/xdg-go/scram v1.1.2 // indirect
22
 	github.com/xdg-go/scram v1.1.2 // indirect
22
 	github.com/xdg-go/stringprep v1.0.4 // indirect
23
 	github.com/xdg-go/stringprep v1.0.4 // indirect
23
 	github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
24
 	github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
25
+	go.uber.org/multierr v1.10.0 // indirect
24
 	golang.org/x/net v0.47.0 // indirect
26
 	golang.org/x/net v0.47.0 // indirect
25
 	golang.org/x/sync v0.18.0 // indirect
27
 	golang.org/x/sync v0.18.0 // indirect
28
+	gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
26
 	gopkg.in/yaml.v2 v2.4.0 // indirect
29
 	gopkg.in/yaml.v2 v2.4.0 // indirect
27
 )
30
 )
28
 
31
 

+ 26
- 10
go.sum View File

1
 filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
1
 filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
2
 filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
2
 filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
3
-git.x2erp.com/qdy/go-base v0.1.51/go.mod h1:IYkjIY0xiqPKIOBojsR9miER2ceyly6+iwv4Zd64OT0=
4
-git.x2erp.com/qdy/go-base v0.1.60 h1:eGexgp8fUNMBmecpR7pelNsvr8ujYFZf1phLNFlGjVE=
5
-git.x2erp.com/qdy/go-base v0.1.60/go.mod h1:IYkjIY0xiqPKIOBojsR9miER2ceyly6+iwv4Zd64OT0=
3
+git.x2erp.com/qdy/go-base v0.1.12-20251231-1 h1:xcEdI8zKVNJA50e6Q3fACD3qJH6HAORZyejnvkz2n/I=
4
+git.x2erp.com/qdy/go-base v0.1.12-20251231-1/go.mod h1:bhbWJO4/dxNNjXjie1E0G41pvKEEm2dPnRXRzYnV9tU=
6
 github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.0 h1:Gt0j3wceWMwPmiazCa8MzMA0MfhmPIz0Qp0FJ6qcM0U=
5
 github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.0 h1:Gt0j3wceWMwPmiazCa8MzMA0MfhmPIz0Qp0FJ6qcM0U=
7
 github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.0/go.mod h1:Ot/6aikWnKWi4l9QB7qVSwa8iMphQNqkWALMoNT3rzM=
6
 github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.0/go.mod h1:Ot/6aikWnKWi4l9QB7qVSwa8iMphQNqkWALMoNT3rzM=
8
 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.1 h1:B+blDbyVIG3WaikNxPnhPiJ1MThR03b3vKGtER95TP4=
7
 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.1 h1:B+blDbyVIG3WaikNxPnhPiJ1MThR03b3vKGtER95TP4=
21
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
20
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
22
 github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
21
 github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
23
 github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
22
 github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
24
-github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
25
-github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
23
+github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
24
+github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
26
 github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
25
 github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
27
 github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
26
 github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
28
 github.com/go-resty/resty/v2 v2.17.0 h1:pW9DeXcaL4Rrym4EZ8v7L19zZiIlWPg5YXAcVmt+gN0=
27
 github.com/go-resty/resty/v2 v2.17.0 h1:pW9DeXcaL4Rrym4EZ8v7L19zZiIlWPg5YXAcVmt+gN0=
38
 github.com/golang-sql/sqlexp v0.1.0/go.mod h1:J4ad9Vo8ZCWQ2GMrC4UCQy1JpCbwU9m3EOqtpKwwwHI=
37
 github.com/golang-sql/sqlexp v0.1.0/go.mod h1:J4ad9Vo8ZCWQ2GMrC4UCQy1JpCbwU9m3EOqtpKwwwHI=
39
 github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
38
 github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
40
 github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
39
 github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
40
+github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
41
+github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
41
 github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
42
 github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
42
 github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
43
 github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
43
 github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
44
 github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
44
 github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY=
45
 github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY=
45
 github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I=
46
 github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I=
46
 github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
47
 github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
48
+github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
49
+github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
50
+github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
51
+github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
47
 github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
52
 github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
48
 github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
53
 github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
49
 github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
54
 github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
54
 github.com/microsoft/go-mssqldb v1.9.4/go.mod h1:GBbW9ASTiDC+mpgWDGKdm3FnFLTUsLYN3iFL90lQ+PA=
59
 github.com/microsoft/go-mssqldb v1.9.4/go.mod h1:GBbW9ASTiDC+mpgWDGKdm3FnFLTUsLYN3iFL90lQ+PA=
55
 github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE=
60
 github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE=
56
 github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
61
 github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
57
-github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY=
58
-github.com/nxadm/tail v1.4.11/go.mod h1:OTaG3NK980DZzxbRq6lEuzgU+mug70nY11sMd4JXXHc=
62
+github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
63
+github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
59
 github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
64
 github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
60
 github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
65
 github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
61
 github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
66
 github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
64
 github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
69
 github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
65
 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
70
 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
66
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
71
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
72
+github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
73
+github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
67
 github.com/sijms/go-ora/v2 v2.9.0 h1:+iQbUeTeCOFMb5BsOMgUhV8KWyrv9yjKpcK4x7+MFrg=
74
 github.com/sijms/go-ora/v2 v2.9.0 h1:+iQbUeTeCOFMb5BsOMgUhV8KWyrv9yjKpcK4x7+MFrg=
68
 github.com/sijms/go-ora/v2 v2.9.0/go.mod h1:QgFInVi3ZWyqAiJwzBQA+nbKYKH77tdp1PYoCqhR2dU=
75
 github.com/sijms/go-ora/v2 v2.9.0/go.mod h1:QgFInVi3ZWyqAiJwzBQA+nbKYKH77tdp1PYoCqhR2dU=
69
 github.com/streadway/amqp v1.1.0 h1:py12iX8XSyI7aN/3dUT8DFIDJazNJsVJdxNVEpnQTZM=
76
 github.com/streadway/amqp v1.1.0 h1:py12iX8XSyI7aN/3dUT8DFIDJazNJsVJdxNVEpnQTZM=
70
 github.com/streadway/amqp v1.1.0/go.mod h1:WYSrTEYHOXHd0nwFeUXAe2G2hRnQT+deZJJf88uS9Bg=
77
 github.com/streadway/amqp v1.1.0/go.mod h1:WYSrTEYHOXHd0nwFeUXAe2G2hRnQT+deZJJf88uS9Bg=
71
-github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
72
-github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
78
+github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
79
+github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
73
 github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
80
 github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
74
 github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
81
 github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
75
 github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY=
82
 github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY=
81
 github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
88
 github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
82
 go.mongodb.org/mongo-driver v1.17.6 h1:87JUG1wZfWsr6rIz3ZmpH90rL5tea7O3IHuSwHUpsss=
89
 go.mongodb.org/mongo-driver v1.17.6 h1:87JUG1wZfWsr6rIz3ZmpH90rL5tea7O3IHuSwHUpsss=
83
 go.mongodb.org/mongo-driver v1.17.6/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ=
90
 go.mongodb.org/mongo-driver v1.17.6/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ=
91
+go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
92
+go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
93
+go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ=
94
+go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
95
+go.uber.org/zap v1.27.1 h1:08RqriUEv8+ArZRYSTXy1LeBScaMpVSTBhCeaZYfMYc=
96
+go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
84
 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
97
 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
85
 golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
98
 golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
86
 golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
99
 golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
116
 golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
129
 golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
117
 golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
130
 golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
118
 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
131
 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
119
-gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
120
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
132
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
133
+gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
134
+gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
135
+gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
136
+gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
121
 gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
137
 gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
122
 gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
138
 gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
123
 gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
139
 gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=

myhandle/query_handler_bytes.go → util/query_handler_bytes.go View File

1
-package myhandle
1
+package util
2
 
2
 
3
 import (
3
 import (
4
 	"encoding/json"
4
 	"encoding/json"

myhandle/query_handler_json.go → util/query_handler_json.go View File

1
-package myhandle
1
+package util
2
 
2
 
3
 import (
3
 import (
4
 	"encoding/json"
4
 	"encoding/json"
6
 	"time"
6
 	"time"
7
 
7
 
8
 	"git.x2erp.com/qdy/go-base/ctx"
8
 	"git.x2erp.com/qdy/go-base/ctx"
9
-	"git.x2erp.com/qdy/go-base/types"
9
+	"git.x2erp.com/qdy/go-base/model/response"
10
 )
10
 )
11
 
11
 
12
 // queryHandler - 最简单的版本
12
 // queryHandler - 最简单的版本
14
 	w http.ResponseWriter,
14
 	w http.ResponseWriter,
15
 	r *http.Request,
15
 	r *http.Request,
16
 	factory F,
16
 	factory F,
17
-	handlerFunc func(F, T, *ctx.RequestContext) *types.QueryResult[[]map[string]interface{}],
17
+	handlerFunc func(F, T, *ctx.RequestContext) *response.QueryResult[[]map[string]interface{}],
18
 ) {
18
 ) {
19
 	// 解析请求参数
19
 	// 解析请求参数
20
 	var req T
20
 	var req T
21
 	if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
21
 	if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
22
 		// 如果解析失败,也返回 QueryResult 格式
22
 		// 如果解析失败,也返回 QueryResult 格式
23
 		w.Header().Set("Content-Type", "application/json")
23
 		w.Header().Set("Content-Type", "application/json")
24
-		json.NewEncoder(w).Encode(&types.QueryResult[[]map[string]interface{}]{
24
+		json.NewEncoder(w).Encode(&response.QueryResult[[]map[string]interface{}]{
25
 			Success: false,
25
 			Success: false,
26
 			Error:   "Invalid request body: " + err.Error(),
26
 			Error:   "Invalid request body: " + err.Error(),
27
 			Time:    time.Now().Format(time.RFC3339),
27
 			Time:    time.Now().Format(time.RFC3339),

myhandle/query_handler_map.go → util/query_handler_map.go View File

1
-package myhandle
1
+package util
2
 
2
 
3
 import (
3
 import (
4
 	"encoding/json"
4
 	"encoding/json"
6
 	"time"
6
 	"time"
7
 
7
 
8
 	"git.x2erp.com/qdy/go-base/ctx"
8
 	"git.x2erp.com/qdy/go-base/ctx"
9
-	"git.x2erp.com/qdy/go-base/types"
9
+	"git.x2erp.com/qdy/go-base/model/response"
10
 )
10
 )
11
 
11
 
12
 // queryHandler - 最简单的版本
12
 // queryHandler - 最简单的版本
14
 	w http.ResponseWriter,
14
 	w http.ResponseWriter,
15
 	r *http.Request,
15
 	r *http.Request,
16
 	factory F,
16
 	factory F,
17
-	handlerFunc func(F, T, *ctx.RequestContext) *types.QueryResult[map[string]interface{}],
17
+	handlerFunc func(F, T, *ctx.RequestContext) *response.QueryResult[map[string]interface{}],
18
 ) {
18
 ) {
19
 	// 解析请求参数
19
 	// 解析请求参数
20
 	var req T
20
 	var req T
21
 	if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
21
 	if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
22
 		// 如果解析失败,也返回 QueryResult 格式
22
 		// 如果解析失败,也返回 QueryResult 格式
23
 		w.Header().Set("Content-Type", "application/json")
23
 		w.Header().Set("Content-Type", "application/json")
24
-		json.NewEncoder(w).Encode(&types.QueryResult[[]map[string]interface{}]{
24
+		json.NewEncoder(w).Encode(&response.QueryResult[[]map[string]interface{}]{
25
 			Success: false,
25
 			Success: false,
26
 			Error:   "Invalid request body: " + err.Error(),
26
 			Error:   "Invalid request body: " + err.Error(),
27
 			Time:    time.Now().Format(time.RFC3339),
27
 			Time:    time.Now().Format(time.RFC3339),

Loading…
Cancel
Save