2019-09-04 09:00:31 +08:00
|
|
|
'use strict';
|
|
|
|
|
2020-04-28 17:21:07 +08:00
|
|
|
const Moment = require('moment');
|
|
|
|
|
2019-09-04 09:00:31 +08:00
|
|
|
function ctxresp(ctx, data, errno, errmsg) {
|
|
|
|
if (errno === null || errno === undefined) errno = 0;
|
|
|
|
if (errmsg === null || errmsg === undefined) errmsg = '';
|
|
|
|
if (data === null || data === undefined) data = {};
|
|
|
|
|
|
|
|
ctx.body = {
|
2020-11-12 17:23:54 +08:00
|
|
|
code: errno,
|
|
|
|
msg: errmsg,
|
2020-04-28 17:21:07 +08:00
|
|
|
data: data,
|
2020-11-12 17:23:54 +08:00
|
|
|
stime: Moment().format('YYYY-MM-DD HH:mm:ss SSS')
|
2019-09-04 09:00:31 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = ctxresp;
|