1 Star 0 Fork 0

笨笨/twbe

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
router.js 3.65 KB
一键复制 编辑 原始数据 按行查看 历史
周子健 提交于 2023-09-14 18:21 . 优化:调整用户身份鉴别
const userCtrl = require("./controller/userCtrl");
const rlCtrl = require("./controller/rlCtrl");
const workCtrl = require("./controller/workCtrl");
const messageCtrl = require("./controller/messageCtrl");
const fileGiteeCtrl = require("./controller/fileGitee")
const appCtrl = require("./controller/application")
const wx135Ctrl = require("./controller/wechat/135")
const HHAICtrl = require("./controller/AI/hh")
const tool = require("./tool.js")
let routeConfigs = {
user: {
ctrl: userCtrl,
router: [{
url: 'user/register',
method: "GET"
}, {
url: 'user/getUserInfo',
method: "GET"
}, {
url: 'user/getDepartmentPerson',
method: "GET"
}],
},
rl: {
ctrl: rlCtrl,
router: [{
url: 'rl/getRl',
method: "GET"
}]
},
file: {
ctrl: fileGiteeCtrl,
router: [{
url: 'file/upload',
method: "POST"
}]
},
app: {
ctrl: appCtrl,
router: [{
url: 'app/appConfig',
method: "GET"
}, {
url: 'app/appMain',
method: "GET"
}]
},
wx: {
ctrl: wx135Ctrl,
router: [{
url: 'wx/135/getList',
method: "GET"
}]
},
AI: {
ctrl: HHAICtrl,
router: [{
url: 'AI/HH/HH',
authority: "0000010000",
method: "GET"
}]
},
message: {
ctrl: messageCtrl,
router: [{
url: 'message/getMyMessage',
method: "GET"
}, {
url: 'message/getQ',
method: "GET"
}, {
url: 'message/getNews',
method: "GET"
}, {
url: 'message/setWrite',
method: "GET"
}, {
url: 'message/upQ',
method: "POST"
}, {
url: 'message/upNews',
method: "POST"
}, {
url: 'message/getCanUp',
method: "GET"
}, {
url: 'message/setQImg',
method: "POST"
}, {
url: 'message/create',
method: "GET"
}, {
url: 'message/face',
method: "GET"
}, {
url: 'message/psd',
method: "GET"
}]
},
work: {
ctrl: workCtrl,
router: [{
url: 'work/add',
method: "GET"
}, {
url: 'work/save',
method: "GET"
}, {
url: 'work/getPaper',
method: "GET"
}, {
url: 'work/setCanSee',
method: "GET"
}, {
url: 'work/getMyWork',
method: "GET"
}, {
url: 'work/delMyWork',
method: "GET"
}, {
url: 'work/getMyDoWork',
method: "GET"
}]
}
}
class router {
constructor(app) {
this.app = app
}
addRoute(routeConfigs) {
let AAC = {} // Account authority controller
Object.keys(routeConfigs).map((rKey) => {
for (let rc of routeConfigs[rKey].router) {
AAC[rc.url] = rc
if (rc.method == "GET") {
this.app.get("/" + rc.url, (req, resp) => {
req.query.uId=tool.decodeToken(req.query.uToken)
console.log(9)
return routeConfigs[rKey].ctrl[rc.url.split("/").slice(-1)].call(this, req, resp)
})
}
}
})
return AAC
}
}
module.exports = {
router, routeConfigs
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/bendantada/twbe.git
git@gitee.com:bendantada/twbe.git
bendantada
twbe
twbe
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385