You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
845 B
30 lines
845 B
var express = require('express');
|
|
var router = express.Router();
|
|
var path = require("path");
|
|
|
|
|
|
// 获取验证模块
|
|
var authorization = require(path.join(process.cwd(),"/modules/authorization"));
|
|
|
|
// 通过验证模块获取用户管理服务
|
|
var reportsServ = authorization.getService("ReportsService");
|
|
|
|
router.get("/type/:typeid",
|
|
// 参数验证
|
|
function(req,res,next){
|
|
if(!req.params.typeid) {
|
|
return res.sendResult(null,400,"报表类型不能为空");
|
|
}
|
|
if(isNaN(parseInt(req.params.typeid))) return res.sendResult(null,400,"报表类型必须是数字");
|
|
next();
|
|
},
|
|
// 业务逻辑
|
|
function(req,res,next) {
|
|
reportsServ.reports(req.params.typeid,function(err,result){
|
|
if(err) return res.sendResult(null,400,err);
|
|
res.sendResult(result,200,"获取报表成功");
|
|
})(req,res,next);
|
|
}
|
|
);
|
|
|
|
module.exports = router; |