Commit f57f7a87 authored by 何虹's avatar 何虹 💬

读写分离加到头上

parent 3353ab96
...@@ -2003,8 +2003,8 @@ class Control { ...@@ -2003,8 +2003,8 @@ class Control {
if (!dbCode) { if (!dbCode) {
parms.dbCode = urlParam.dbCode || '' parms.dbCode = urlParam.dbCode || ''
} }
if (!userId && userId !== 0) { if (!userId) {
parms.userId = -2 parms.userId = -1
} }
if (!configType && configType !== 0) { if (!configType && configType !== 0) {
parms.configType = -2 parms.configType = -2
...@@ -2056,7 +2056,7 @@ class Control { ...@@ -2056,7 +2056,7 @@ class Control {
*/ */
webChartConfigQuery (data) { webChartConfigQuery (data) {
this.packParamHandle(data) this.packParamHandle(data)
const { appCode, pageName, controlName, userId, dbName, dbCode,configType } = data const { appCode, pageName, controlName, userId, dbName, dbCode, configType } = data
const postData = { const postData = {
exec_sql: `EXEC dbo.spappWebChartConfig_Query @sAppCode='${appCode}',@sPage='${pageName}',@sControl='${controlName}',@iUserId='${userId}',@iConfigType='${configType}'`, exec_sql: `EXEC dbo.spappWebChartConfig_Query @sAppCode='${appCode}',@sPage='${pageName}',@sControl='${controlName}',@iUserId='${userId}',@iConfigType='${configType}'`,
db_name: dbName, db_name: dbName,
...@@ -22014,6 +22014,15 @@ class RestFul { ...@@ -22014,6 +22014,15 @@ class RestFul {
parms.appCode = this.requestClient.appCode //|| urlParam.appCode parms.appCode = this.requestClient.appCode //|| urlParam.appCode
} }
} }
mergeHeaderQueryMaster (isQueryMaster) {
if (isQueryMaster) {
return {
'x-db_router_type': 'master'
}
} else {
return {}
}
}
query (data) { query (data) {
this.packParamHandle(data) this.packParamHandle(data)
const { tableName, appCode, group, parms, bodyData, isQueryMaster } = data const { tableName, appCode, group, parms, bodyData, isQueryMaster } = data
...@@ -22021,9 +22030,7 @@ class RestFul { ...@@ -22021,9 +22030,7 @@ class RestFul {
if (group) { // 非标准保存 if (group) { // 非标准保存
url = `${url}${group}/` url = `${url}${group}/`
} }
const header = { const header = this.mergeHeaderQueryMaster(isQueryMaster)
isQueryMaster: isQueryMaster ? 1 : 0
}
if (bodyData) { if (bodyData) {
return this.requestClient.put(url, bodyData, parms, header) return this.requestClient.put(url, bodyData, parms, header)
} else { } else {
...@@ -22046,9 +22053,7 @@ class RestFul { ...@@ -22046,9 +22053,7 @@ class RestFul {
if (group) { if (group) {
url_ = `${url_}${group}/` url_ = `${url_}${group}/`
} }
const header = { const header = this.mergeHeaderQueryMaster(isQueryMaster)
isQueryMaster: isQueryMaster ? 1 : 0
}
if (bodyData) { if (bodyData) {
return this.requestClient.put(url_, bodyData, parms, header) return this.requestClient.put(url_, bodyData, parms, header)
} else { } else {
...@@ -22062,9 +22067,8 @@ class RestFul { ...@@ -22062,9 +22067,8 @@ class RestFul {
if (group) { // 非标准保存 if (group) { // 非标准保存
url = `${url}${group}/` url = `${url}${group}/`
} }
return this.requestClient.put(url, bodyData, parms, { const header = this.mergeHeaderQueryMaster(isQueryMaster)
isQueryMaster: isQueryMaster ? 1 : 0 return this.requestClient.put(url, bodyData, parms, header)
})
} }
queryList (data) { queryList (data) {
...@@ -22075,9 +22079,7 @@ class RestFul { ...@@ -22075,9 +22079,7 @@ class RestFul {
url_ = `${url_}${group}/` url_ = `${url_}${group}/`
} }
parms.fuzzy = 1 parms.fuzzy = 1
const header = { const header = this.mergeHeaderQueryMaster(isQueryMaster)
isQueryMaster: isQueryMaster ? 1 : 0
}
if (bodyData) { if (bodyData) {
return this.requestClient.put(url_, bodyData, parms, header) return this.requestClient.put(url_, bodyData, parms, header)
} else { } else {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -11,6 +11,15 @@ class RestFul { ...@@ -11,6 +11,15 @@ class RestFul {
parms.appCode = this.requestClient.appCode //|| urlParam.appCode parms.appCode = this.requestClient.appCode //|| urlParam.appCode
} }
} }
mergeHeaderQueryMaster (isQueryMaster) {
if (isQueryMaster) {
return {
'x-db_router_type': 'master'
}
} else {
return {}
}
}
query (data) { query (data) {
this.packParamHandle(data) this.packParamHandle(data)
const { tableName, appCode, group, parms, bodyData, isQueryMaster } = data const { tableName, appCode, group, parms, bodyData, isQueryMaster } = data
...@@ -18,9 +27,7 @@ class RestFul { ...@@ -18,9 +27,7 @@ class RestFul {
if (group) { // 非标准保存 if (group) { // 非标准保存
url = `${url}${group}/` url = `${url}${group}/`
} }
const header = { const header = this.mergeHeaderQueryMaster(isQueryMaster)
isQueryMaster: isQueryMaster ? 1 : 0
}
if (bodyData) { if (bodyData) {
return this.requestClient.put(url, bodyData, parms, header) return this.requestClient.put(url, bodyData, parms, header)
} else { } else {
...@@ -43,9 +50,7 @@ class RestFul { ...@@ -43,9 +50,7 @@ class RestFul {
if (group) { if (group) {
url_ = `${url_}${group}/` url_ = `${url_}${group}/`
} }
const header = { const header = this.mergeHeaderQueryMaster(isQueryMaster)
isQueryMaster: isQueryMaster ? 1 : 0
}
if (bodyData) { if (bodyData) {
return this.requestClient.put(url_, bodyData, parms, header) return this.requestClient.put(url_, bodyData, parms, header)
} else { } else {
...@@ -59,9 +64,8 @@ class RestFul { ...@@ -59,9 +64,8 @@ class RestFul {
if (group) { // 非标准保存 if (group) { // 非标准保存
url = `${url}${group}/` url = `${url}${group}/`
} }
return this.requestClient.put(url, bodyData, parms, { const header = this.mergeHeaderQueryMaster(isQueryMaster)
isQueryMaster: isQueryMaster ? 1 : 0 return this.requestClient.put(url, bodyData, parms, header)
})
} }
queryList (data) { queryList (data) {
...@@ -72,9 +76,7 @@ class RestFul { ...@@ -72,9 +76,7 @@ class RestFul {
url_ = `${url_}${group}/` url_ = `${url_}${group}/`
} }
parms.fuzzy = 1 parms.fuzzy = 1
const header = { const header = this.mergeHeaderQueryMaster(isQueryMaster)
isQueryMaster: isQueryMaster ? 1 : 0
}
if (bodyData) { if (bodyData) {
return this.requestClient.put(url_, bodyData, parms, header) return this.requestClient.put(url_, bodyData, parms, header)
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment