@@ -46,9 +46,9 @@ func (s *Service) initShardingApi(api *restful.WebService) {
46
46
47
47
// ShardingDBConfig is the sharding db config for api
48
48
type ShardingDBConfig struct {
49
- MasterDB string `json:"master_db"`
50
- ForNewTenant string `json:"for_new_tenant "`
51
- SlaveDB map [string ]SlaveDBConfig `json:"slave_db"`
49
+ MasterDB string `json:"master_db"`
50
+ ForNewData string `json:"for_new_data "`
51
+ SlaveDB map [string ]SlaveDBConfig `json:"slave_db"`
52
52
}
53
53
54
54
// SlaveDBConfig is the slave db config for api
@@ -69,9 +69,9 @@ func (s *Service) GetShardingDBConfig(req *restful.Request, resp *restful.Respon
69
69
}
70
70
71
71
result := & ShardingDBConfig {
72
- MasterDB : conf .MasterDB ,
73
- ForNewTenant : conf .ForNewTenant ,
74
- SlaveDB : make (map [string ]SlaveDBConfig ),
72
+ MasterDB : conf .MasterDB ,
73
+ ForNewData : conf .ForNewData ,
74
+ SlaveDB : make (map [string ]SlaveDBConfig ),
75
75
}
76
76
77
77
for uuid , mongoConf := range conf .SlaveDB {
@@ -134,7 +134,7 @@ func (s *Service) getShardingDBConf(kit *rest.Kit) (*sharding.ShardingDBConf, er
134
134
135
135
// UpdateShardingDBReq is the update sharding db config request
136
136
type UpdateShardingDBReq struct {
137
- ForNewTenant string `json:"for_new_tenant ,omitempty"`
137
+ ForNewData string `json:"for_new_data ,omitempty"`
138
138
CreateSlaveDB []SlaveDBConfig `json:"create_slave_db,omitempty"`
139
139
UpdateSlaveDB map [string ]UpdateSlaveDBInfo `json:"update_slave_db,omitempty"`
140
140
}
@@ -177,8 +177,8 @@ func (s *Service) UpdateShardingDBConfig(req *restful.Request, resp *restful.Res
177
177
178
178
cond := map [string ]any {common .MongoMetaID : common .ShardingDBConfID }
179
179
updateData := map [string ]any {
180
- "for_new_tenant " : updateConf .ForNewTenant ,
181
- "slave_db" : updateConf .SlaveDB ,
180
+ "for_new_data " : updateConf .ForNewData ,
181
+ "slave_db" : updateConf .SlaveDB ,
182
182
}
183
183
err = s .db .Shard (kit .SysShardOpts ()).Table (common .BKTableNameSystem ).Update (s .ctx , cond , updateData )
184
184
if err != nil {
@@ -247,23 +247,23 @@ func (s *Service) genUpdatedShardingDBConf(kit *rest.Kit, dbConf *sharding.Shard
247
247
}
248
248
249
249
// update new tenant db config, check if the new tenant db config exists
250
- if conf .ForNewTenant != "" {
250
+ if conf .ForNewData != "" {
251
251
// use uuid to specify the new tenant db config for db that already exists
252
- _ , uuidExists := dbConf .SlaveDB [conf .ForNewTenant ]
253
- if conf .ForNewTenant == dbConf .MasterDB || uuidExists {
254
- dbConf .ForNewTenant = conf .ForNewTenant
252
+ _ , uuidExists := dbConf .SlaveDB [conf .ForNewData ]
253
+ if conf .ForNewData == dbConf .MasterDB || uuidExists {
254
+ dbConf .ForNewData = conf .ForNewData
255
255
return dbConf , nil
256
256
}
257
257
258
258
// use name to specify the new tenant db config for new db that doesn't have uuid before creation
259
- uuid , nameExists := nameUUIDMap [conf .ForNewTenant ]
259
+ uuid , nameExists := nameUUIDMap [conf .ForNewData ]
260
260
if nameExists {
261
- dbConf .ForNewTenant = uuid
261
+ dbConf .ForNewData = uuid
262
262
return dbConf , nil
263
263
}
264
264
265
- blog .Errorf ("add new tenant db %s is invalid, rid: %s" , conf .ForNewTenant , kit .Rid )
266
- return nil , kit .CCError .CCErrorf (common .CCErrCommParamsInvalid , "for_new_tenant " )
265
+ blog .Errorf ("add new tenant db %s is invalid, rid: %s" , conf .ForNewData , kit .Rid )
266
+ return nil , kit .CCError .CCErrorf (common .CCErrCommParamsInvalid , "for_new_data " )
267
267
}
268
268
return dbConf , nil
269
269
}
0 commit comments