优化架构,新增路由

This commit is contained in:
robin
2022-07-09 02:54:00 +08:00
parent a9a4bd0981
commit 73c1343060
8 changed files with 3 additions and 30 deletions
@@ -3,6 +3,7 @@
* 账号密码注册 * 账号密码注册
* @param {string} data.account 账号. * @param {string} data.account 账号.
* @param {string} data.password 密码. * @param {string} data.password 密码.
* @param {string} data.oid 机构id
* @return {boolean} 注册 是否 成功. * @return {boolean} 注册 是否 成功.
*/ */
module.exports = async (data) => { module.exports = async (data) => {
-13
View File
@@ -1,13 +0,0 @@
module.exports = {
doc: "分组表",
api: true,//是否需要生成api接口
model: {
gid: {type: "STRING", comment: '分组id'},
name: {type: "STRING", comment: '分组名称'},
to_gid: {type: "STRING", comment: '上级分组id'},
to_oid: {type: "STRING", comment: '所属组织id'},
},
}
+1 -1
View File
@@ -3,8 +3,8 @@ module.exports = {
api: true,//是否需要生成api接口 api: true,//是否需要生成api接口
model: { model: {
pid: {type: "STRING", comment: '权限id'}, pid: {type: "STRING", comment: '权限id'},
to_pccode: {type: "STRING", comment: '所属权限分类码'},
name: {type: "STRING", comment: '权限名称'}, name: {type: "STRING", comment: '权限名称'},
type: {type: "STRING", comment: '权限类型:接口/字段/表格/按钮:jk/zd/bg/an'},
code: {type: "STRING", comment: '权限识别码'}, code: {type: "STRING", comment: '权限识别码'},
value: {type: "STRING", comment: '权限值'}, value: {type: "STRING", comment: '权限值'},
}, },
-10
View File
@@ -1,10 +0,0 @@
module.exports = {
doc: "权限分类表",
api: true,//是否需要生成api接口
model: {
name: {type: "STRING", comment: '权限分类名称'},
pccode: {type: "STRING", comment: '权限分类识别码'},
},
}
-2
View File
@@ -4,9 +4,7 @@ module.exports = {
model: { model: {
rid: {type: "STRING", comment: '角色id'}, rid: {type: "STRING", comment: '角色id'},
name: {type: "STRING", comment: '角色名称'}, name: {type: "STRING", comment: '角色名称'},
to_rid: {type: "STRING", comment: '上级角色id'},
to_oid: {type: "STRING", comment: '所属组织id'}, to_oid: {type: "STRING", comment: '所属组织id'},
to_gid: {type: "STRING", comment: '所属分组id'},
}, },
} }
-1
View File
@@ -2,7 +2,6 @@ module.exports = {
doc: "角色拥有的权限", doc: "角色拥有的权限",
api: true,//是否需要生成api接口 api: true,//是否需要生成api接口
model: { model: {
rpid: {type: "STRING", comment: '角色权限id'},
to_rid: {type: "STRING", comment: '角色id'}, to_rid: {type: "STRING", comment: '角色id'},
to_pid: {type: "STRING", comment: '权限id'}, to_pid: {type: "STRING", comment: '权限id'},
}, },
-2
View File
@@ -7,9 +7,7 @@ module.exports = {
password: {type: "STRING", comment: '用户加密密码'}, password: {type: "STRING", comment: '用户加密密码'},
salt: {type: "STRING", comment: '用户加密随机数'}, salt: {type: "STRING", comment: '用户加密随机数'},
to_oid: {type: "STRING", comment: '所属组织id'}, to_oid: {type: "STRING", comment: '所属组织id'},
to_gid: {type: "STRING", comment: '所属分组id'},
to_rid: {type: "STRING", comment: '所属角色id'}, to_rid: {type: "STRING", comment: '所属角色id'},
to_uid: {type: "STRING", comment: '上级用户id'},
}, },
} }
+1 -1
View File
@@ -15,7 +15,6 @@ module.exports = {
app.use(router.routes()).use(router.allowedMethods()) app.use(router.routes()).use(router.allowedMethods())
}, },
fun : async (app) => { fun : async (app) => {
const parameter = app.parameter
const router = new Router({ //设置前缀 const router = new Router({ //设置前缀
prefix: config.prefix prefix: config.prefix
}); });
@@ -25,6 +24,7 @@ module.exports = {
console.log(url); console.log(url);
router.all(url, async (ctx, next) => { router.all(url, async (ctx, next) => {
await next(); await next();
const parameter = app.parameter
const validate = parameter.validate(item.res.params, ctx.params); const validate = parameter.validate(item.res.params, ctx.params);
let res = null let res = null
if (validate) { if (validate) {