- update log

master
李光春 1 year ago
parent b69cc2ec64
commit bda5c8a176

@ -1,7 +1,11 @@
## v2022-12-28
- update log
## v2022-12-23 ## v2022-12-23
- meituanupdate api - meituanupdate api
- stringupdate - stringupdate
## v2022-12-19 ## v2022-12-19

@ -1,5 +1,5 @@
package go_library package go_library
func Version() string { func Version() string {
return "1.0.61" return "1.0.62"
} }

@ -73,9 +73,12 @@ func NewApiClient(config *ApiClientConfig) (*ApiClient, error) {
c.setConfig(ctx) c.setConfig(ctx)
gormClient, gormTableName := config.GormClientFun() gormClient, gormTableName := config.GormClientFun()
mongoClient, mongoDatabaseName, mongoCollectionName := config.MongoClientFun() //mongoClient, mongoDatabaseName, mongoCollectionName := config.MongoClientFun()
if (gormClient == nil || gormClient.GetDb() == nil) || (mongoClient == nil || mongoClient.GetDb() == nil) { //if (gormClient == nil || gormClient.GetDb() == nil) || (mongoClient == nil || mongoClient.GetDb() == nil) {
// return nil, dbClientFunNoConfig
//}
if gormClient == nil || gormClient.GetDb() == nil {
return nil, dbClientFunNoConfig return nil, dbClientFunNoConfig
} }
@ -97,30 +100,30 @@ func NewApiClient(config *ApiClientConfig) (*ApiClient, error) {
} }
// 配置非关系数据库 // 配置非关系数据库
if mongoClient != nil || mongoClient.GetDb() != nil { //if mongoClient != nil || mongoClient.GetDb() != nil {
//
c.mongoClient = mongoClient // c.mongoClient = mongoClient
//
if mongoDatabaseName == "" { // if mongoDatabaseName == "" {
return nil, errors.New("没有设置库名") // return nil, errors.New("没有设置库名")
} else { // } else {
c.mongoConfig.databaseName = mongoDatabaseName // c.mongoConfig.databaseName = mongoDatabaseName
} // }
//
if mongoCollectionName == "" { // if mongoCollectionName == "" {
return nil, errors.New("没有设置表名") // return nil, errors.New("没有设置表名")
} else { // } else {
c.mongoConfig.collectionName = mongoCollectionName // c.mongoConfig.collectionName = mongoCollectionName
} // }
//
// 创建时间序列集合 // // 创建时间序列集合
c.mongoCreateCollection(ctx) // c.mongoCreateCollection(ctx)
//
// 创建索引 // // 创建索引
c.mongoCreateIndexes(ctx) // c.mongoCreateIndexes(ctx)
//
c.mongoConfig.stats = true // c.mongoConfig.stats = true
} //}
return c, nil return c, nil
} }
@ -130,9 +133,9 @@ func (c *ApiClient) Middleware(ctx context.Context, request gorequest.Response,
if c.gormConfig.stats { if c.gormConfig.stats {
c.gormMiddleware(ctx, request, sdkVersion) c.gormMiddleware(ctx, request, sdkVersion)
} }
if c.mongoConfig.stats { //if c.mongoConfig.stats {
c.mongoMiddleware(ctx, request, sdkVersion) // c.mongoMiddleware(ctx, request, sdkVersion)
} //}
} }
// MiddlewareXml 中间件 // MiddlewareXml 中间件
@ -140,9 +143,9 @@ func (c *ApiClient) MiddlewareXml(ctx context.Context, request gorequest.Respons
if c.gormConfig.stats { if c.gormConfig.stats {
c.gormMiddlewareXml(ctx, request, sdkVersion) c.gormMiddlewareXml(ctx, request, sdkVersion)
} }
if c.mongoConfig.stats { //if c.mongoConfig.stats {
c.mongoMiddlewareXml(ctx, request, sdkVersion) // c.mongoMiddlewareXml(ctx, request, sdkVersion)
} //}
} }
// MiddlewareCustom 中间件 // MiddlewareCustom 中间件
@ -150,7 +153,7 @@ func (c *ApiClient) MiddlewareCustom(ctx context.Context, api string, request go
if c.gormConfig.stats { if c.gormConfig.stats {
c.gormMiddlewareCustom(ctx, api, request, sdkVersion) c.gormMiddlewareCustom(ctx, api, request, sdkVersion)
} }
if c.mongoConfig.stats { //if c.mongoConfig.stats {
c.mongoMiddlewareCustom(ctx, api, request, sdkVersion) // c.mongoMiddlewareCustom(ctx, api, request, sdkVersion)
} //}
} }

@ -83,9 +83,12 @@ func NewGinClient(config *GinClientConfig) (*GinClient, error) {
c.setConfig(ctx) c.setConfig(ctx)
gormClient, gormTableName := config.GormClientFun() gormClient, gormTableName := config.GormClientFun()
mongoClient, mongoDatabaseName, mongoCollectionName := config.MongoClientFun() //mongoClient, mongoDatabaseName, mongoCollectionName := config.MongoClientFun()
if (gormClient == nil || gormClient.GetDb() == nil) || (mongoClient == nil || mongoClient.GetDb() == nil) { //if (gormClient == nil || gormClient.GetDb() == nil) || (mongoClient == nil || mongoClient.GetDb() == nil) {
// return nil, dbClientFunNoConfig
//}
if gormClient == nil || gormClient.GetDb() == nil {
return nil, dbClientFunNoConfig return nil, dbClientFunNoConfig
} }
@ -106,30 +109,30 @@ func NewGinClient(config *GinClientConfig) (*GinClient, error) {
} }
// 配置非关系数据库 // 配置非关系数据库
if mongoClient != nil || mongoClient.GetDb() != nil { //if mongoClient != nil || mongoClient.GetDb() != nil {
//
c.mongoClient = mongoClient // c.mongoClient = mongoClient
//
if mongoDatabaseName == "" { // if mongoDatabaseName == "" {
return nil, errors.New("没有设置库名") // return nil, errors.New("没有设置库名")
} else { // } else {
c.mongoConfig.databaseName = mongoDatabaseName // c.mongoConfig.databaseName = mongoDatabaseName
} // }
//
if mongoCollectionName == "" { // if mongoCollectionName == "" {
return nil, errors.New("没有设置表名") // return nil, errors.New("没有设置表名")
} else { // } else {
c.mongoConfig.collectionName = mongoCollectionName // c.mongoConfig.collectionName = mongoCollectionName
} // }
//
// 创建时间序列集合 // // 创建时间序列集合
//c.mongoCreateCollection(ctx) // //c.mongoCreateCollection(ctx)
//
// 创建索引 // // 创建索引
c.mongoCreateIndexes(ctx) // c.mongoCreateIndexes(ctx)
//
c.mongoConfig.stats = true // c.mongoConfig.stats = true
} //}
return c, nil return c, nil
} }
@ -213,13 +216,6 @@ func (c *GinClient) Middleware() gin.HandlerFunc {
c.gormRecordXml(ginCtx, traceId, requestTime, data, responseCode, responseBody, startTime, endTime, info) c.gormRecordXml(ginCtx, traceId, requestTime, data, responseCode, responseBody, startTime, endTime, info)
} }
} }
if c.mongoConfig.stats {
if dataJson {
c.mongoRecordJson(ginCtx, traceId, requestTime, data, responseCode, responseBody, startTime, endTime, info)
} else {
c.mongoRecordXml(ginCtx, traceId, requestTime, data, responseCode, responseBody, startTime, endTime, info)
}
}
}() }()
} }
} }

Loading…
Cancel
Save