Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
openresty
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tangku7
openresty
Commits
05557eaa
Commit
05557eaa
authored
Aug 06, 2018
by
周尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
数据同步接口返回处理整理
parent
0d62adfd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
7 deletions
+29
-7
nginx/lua/luabiz/tk_sync.lua
nginx/lua/luabiz/tk_sync.lua
+29
-7
No files found.
nginx/lua/luabiz/tk_sync.lua
View file @
05557eaa
...
...
@@ -171,35 +171,57 @@ end
-- 数据同步接口
-- @param nil
-- @return ngx.say
function
TK_SYNC
.
sync
()
local
function
tk_
sync
()
local
dbs_st
=
zx_base
:
db_read
(
db_conf
)
local
code
local
mesg
if
ngx
.
req
.
get_method
()
~=
"POST"
then
ngx
.
say
(
json
.
encode
({
mesgRetCode
=
"A7"
,
mesgRetDesc
=
"invalid method"
}))
code
=
"A7"
mesg
=
"invalid method"
else
local
data
=
json
.
decode
(
ngx
.
var
.
request_body
)
if
data
.
mesgType
~=
"table_sync"
then
ngx
.
say
(
json
.
encode
({
mesgRetcode
=
"N1"
,
mesgRetDesc
=
"mesgType invalid"
}))
code
=
"N1"
mesg
=
"invalid mesgType"
elseif
data
.
dbHost
==
ngx
.
null
then
ngx
.
say
(
json
.
encode
({
mesgRetCode
=
"N0"
,
mesgRetDesc
=
"dbHost missing"
}))
code
=
"N0"
mesg
=
"database host missing"
else
for
i
=
1
,
#
dbs_st
.
tk_biz
do
if
dbs_st
.
tk_biz
[
i
].
host
==
data
.
dbHost
then
if
data
.
dbTable
==
ngx
.
null
then
ngx
.
say
(
json
.
encode
({
mesgRetCode
=
"N0"
,
mesgRetDesc
=
"dbTable missing"
}))
code
=
"N0"
mesg
=
"database table missing"
return
code
,
mesg
else
async
(
dbs_st
.
tk_biz
[
i
],
dbs_st
.
tk_control
,
dbs_st
.
tk_biz
[
i
].
database
,
data
.
dbTable
)
return
ngx
.
say
(
json
.
encode
({
mesgRetCode
=
"00"
,
mesgRetDesc
=
"SUCCESS"
}))
code
=
"00"
mesg
=
"SUCCESS"
return
code
,
mesg
end
end
end
ngx
.
say
(
json
.
encode
({
mesgRetCode
=
"N1"
,
mesgRetDesc
=
"dbHost invalid"
}))
code
=
"N1"
mesg
=
"database host invalid"
end
end
-- ngx.say(json.encode({mesgRetCode=code, mesgRetMesg=mesg}))
return
code
,
mesg
end
function
TK_SYNC
.
sync
()
local
code
,
mesg
=
tk_sync
()
ngx
.
say
(
json
.
encode
({
mesgRetCode
=
code
,
mesgRetMesg
=
mesg
}))
ngx
.
eof
()
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment