Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
6c66c2eb
Commit
6c66c2eb
authored
Jan 04, 2020
by
宋毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tj
parent
c8923764
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
131 additions
and
49 deletions
+131
-49
igirl-channel/app/base/api/api.base.js
+78
-0
igirl-channel/app/config/objsettings.js
+0
-1
igirl-channel/app/config/routes/api.js
+53
-48
No files found.
igirl-channel/app/base/api/api.base.js
View file @
6c66c2eb
...
...
@@ -191,5 +191,83 @@ class APIBase {
return
rtnerror
;
}
}
//-----------------------新的模式------------------开始
async
doexecMethod
(
gname
,
methodname
,
pobj
,
query
,
req
)
{
var
requestid
=
req
.
headers
[
"request-id"
]
||
this
.
getUUID
();
if
(
!
req
.
headers
[
"request-id"
])
{
req
.
headers
[
"request-id"
]
=
requestid
;
}
try
{
if
(
pobj
.
actionType
==
"createChannelUser"
)
{
if
(
!
pobj
.
isUser
)
{
system
.
getResult
(
null
,
"isUser is empty"
);
}
if
(
pobj
.
isUser
!=
"yes"
)
{
system
.
getResult
(
null
,
"isUser value must yes"
);
}
}
// //验证accesskey或验签
// var isPassResult = await this.checkAcck(gname, methodname, pobj, query, req);
// if (isPassResult.status != 0) {
// isPassResult.requestId = "";
// return isPassResult;
// }
if
(
pobj
.
actionType
==
"createChannelUser"
)
{
var
encryptResult
=
await
this
.
toolSve
.
encryptStr
(
req
.
app
,
req
.
user
.
channelUserId
);
if
(
encryptResult
.
status
!=
0
)
{
system
.
getResult
(
null
,
"encrypt channelUserId is error"
);
}
req
.
user
.
encryptChannelUserId
=
encryptResult
.
data
;
return
system
.
getResultSuccess
(
req
.
user
);
}
//创建用户
req
.
requestId
=
requestid
;
var
rtn
=
await
this
[
methodname
](
pobj
,
query
,
req
);
if
(
rtn
&&
!
rtn
.
requestId
)
{
rtn
.
requestId
=
requestid
;
}
this
.
oplogSve
.
createDb
({
appid
:
req
.
app
.
id
,
appkey
:
req
.
app
.
uappKey
,
requestId
:
requestid
,
op
:
req
.
classname
+
"/"
+
methodname
,
content
:
JSON
.
stringify
(
pobj
),
resultInfo
:
JSON
.
stringify
(
rtn
),
clientIp
:
req
.
clientIp
,
agent
:
req
.
uagent
,
opTitle
:
"api服务提供方appKey:"
+
settings
.
appKey
,
});
return
rtn
;
}
catch
(
e
)
{
console
.
log
(
e
.
stack
,
"api调用出现异常,请联系管理员.........."
)
this
.
oplogSve
.
createDb
({
appid
:
req
.
app
.
id
,
appkey
:
req
.
app
.
uappKey
,
requestId
:
requestid
,
op
:
req
.
classname
+
"/"
+
methodname
,
content
:
JSON
.
stringify
(
pobj
),
resultInfo
:
JSON
.
stringify
(
e
.
stack
),
clientIp
:
req
.
clientIp
,
agent
:
req
.
uagent
,
opTitle
:
"api调用出现异常,请联系管理员error,appKey:"
+
settings
.
appKey
,
});
this
.
logCtl
.
error
({
appid
:
req
.
app
.
id
,
appkey
:
req
.
app
.
uappKey
,
requestId
:
requestid
,
op
:
pobj
.
classname
+
"/"
+
methodname
,
content
:
e
.
stack
,
clientIp
:
pobj
.
clientIp
,
agent
:
req
.
uagent
,
optitle
:
"api调用出现异常,请联系管理员"
,
});
var
rtnerror
=
system
.
getResultFail
(
-
200
,
"出现异常,error:"
+
e
.
stack
);
rtnerror
.
requestId
=
requestid
;
return
rtnerror
;
}
}
//-----------------------新的模式------------------结束
}
module
.
exports
=
APIBase
;
igirl-channel/app/config/objsettings.js
View file @
6c66c2eb
...
...
@@ -8,6 +8,5 @@ var settings = {
db
:
path
.
join
(
basepath
,
"app/base/db/impl"
),
tool
:
path
.
join
(
basepath
,
"app/base/tool"
),
service2
:
path
.
join
(
basepath
,
"app/base/service"
),
applet
:
path
.
join
(
basepath
,
"app/base/wxapplet/impl"
),
};
module
.
exports
=
settings
;
igirl-channel/app/config/routes/api.js
View file @
6c66c2eb
...
...
@@ -60,56 +60,61 @@ module.exports = function (app) {
res
.
end
(
JSON
.
stringify
(
r
));
});
});
// app.get('/api/:gname/:qname/:method', function (req, res) {
// var classPath = req.params["qname"];
// var methodName = req.params["method"];
// var gname = req.params["gname"];
// classPath = gname + "." + classPath;
// var tClientIp = system.get_client_ip(req);
// req.clientIp = tClientIp;
// req.uagent = req.headers["user-agent"];
// req.classname = classPath;
//-----------------------新的模式------------------开始
// var params = [];
// params.push(gname);
// params.push(methodName);
// params.push(req.body);
// params.push(req.query);
// params.push(req);
// var p = null;
// var invokeObj = system.getObject("api." + classPath);
// if (invokeObj["doexec"]) {
// p = invokeObj["doexec"].apply(invokeObj, params);
// }
// p.then(r => {
// res.end(JSON.stringify(r));
// });
// });
// app.post('/api/:gname/:qname/:method', function (req, res) {
// var classPath = req.params["qname"];
// var methodName = req.params["method"];
// var gname = req.params["gname"];
// var params = [];
// classPath = gname + "." + classPath;
// var tClientIp = system.get_client_ip(req);
app
.
get
(
'/web/:gname/:qname/:method'
,
function
(
req
,
res
)
{
var
classPath
=
req
.
params
[
"qname"
];
var
methodName
=
req
.
params
[
"method"
];
var
gname
=
req
.
params
[
"gname"
];
// req.clientIp = tClientIp;
// req.uagent = req.headers["user-agent"];
// req.classname = classPath;
classPath
=
gname
+
"."
+
classPath
;
var
tClientIp
=
system
.
get_client_ip
(
req
);
req
.
clientIp
=
tClientIp
;
req
.
uagent
=
req
.
headers
[
"user-agent"
];
req
.
classname
=
classPath
;
// params.push(gname);
// params.push(methodName);
// params.push(req.query);
// params.push(req.body);
// params.push(req);
// var p = null;
// var invokeObj = system.getObject("api." + classPath);
// if (invokeObj["doexec"]) {
// p = invokeObj["doexec"].apply(invokeObj, params);
// }
// p.then(r => {
// res.end(JSON.stringify(r));
// });
// });
var
params
=
[];
params
.
push
(
gname
);
params
.
push
(
methodName
);
params
.
push
(
req
.
body
);
params
.
push
(
req
.
query
);
params
.
push
(
req
);
var
p
=
null
;
var
invokeObj
=
system
.
getObject
(
"api."
+
classPath
);
if
(
invokeObj
[
"doexecMethod"
])
{
p
=
invokeObj
[
"doexecMethod"
].
apply
(
invokeObj
,
params
);
}
p
.
then
(
r
=>
{
res
.
end
(
JSON
.
stringify
(
r
));
});
});
app
.
post
(
'/web/:gname/:qname/:method'
,
function
(
req
,
res
)
{
var
classPath
=
req
.
params
[
"qname"
];
var
methodName
=
req
.
params
[
"method"
];
var
gname
=
req
.
params
[
"gname"
];
var
params
=
[];
classPath
=
gname
+
"."
+
classPath
;
var
tClientIp
=
system
.
get_client_ip
(
req
);
req
.
clientIp
=
tClientIp
;
req
.
uagent
=
req
.
headers
[
"user-agent"
];
req
.
classname
=
classPath
;
params
.
push
(
gname
);
params
.
push
(
methodName
);
params
.
push
(
req
.
query
);
params
.
push
(
req
.
body
);
params
.
push
(
req
);
var
p
=
null
;
var
invokeObj
=
system
.
getObject
(
"api."
+
classPath
);
if
(
invokeObj
[
"doexecMethod"
])
{
p
=
invokeObj
[
"doexecMethod"
].
apply
(
invokeObj
,
params
);
}
p
.
then
(
r
=>
{
res
.
end
(
JSON
.
stringify
(
r
));
});
});
//-----------------------新的模式------------------结束
};
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