Commit f7ecff90 by 孙亚楠

dd

parent 78a765c4
......@@ -56,6 +56,9 @@ class ActionAPI extends APIBase {
case "listSaas":
opResult = await this.saasSve.apiListSaas(action_body);
break;
case "saasQueryById":
opResult = await this.saasSve.apiQueryById(action_body);
break;
// 组织机构
case "addOrg":
......@@ -70,8 +73,8 @@ class ActionAPI extends APIBase {
case "listOrg":
opResult = await this.orgSve.apiListOrg(action_body);
break;
case "findById":
opResult = await this.orgSve.apiFindById(action_body);
case "orgQueryById":
opResult = await this.orgSve.apiQueryById(action_body);
break;
case "byPid":
opResult = await this.orgSve.apiByPid(action_body);
......@@ -82,20 +85,20 @@ class ActionAPI extends APIBase {
// 菜单权限
case "addAuth":
return this.authSve.add(action_body);
opResult = this.authSve.add(action_body);
break;
case "updAuth":
return this.authSve.upd(action_body);
opResult = this.authSve.upd(action_body);
break;
case "tree":
return this.authSve.tree(action_body);
opResult = this.authSve.tree(action_body);
break;
case "byPid":
return this.authSve.byPid(action_body);
opResult = this.authSve.byPid(action_body);
break;
case "delAuth":
// TODO 验证是否有角色关联
return this.authSve.del(action_body);
opResult = this.authSve.del(action_body);
break;
// 角色
......@@ -111,6 +114,9 @@ class ActionAPI extends APIBase {
case "listRole":
opResult = await this.roleSve.apiListRole(action_body);
break;
case "roleQueryById":
opResult = await this.roleSve.apiQueryById(action_body);
break;
// 用户
case "addUser":
......
......@@ -67,7 +67,7 @@ class OrgService extends ServiceBase {
* 根据ID查明细
* @param {*} params
*/
async apiFindById(params){
async apiQueryById(params){
try {
return await this.queryById(params)
} catch (error) {
......@@ -249,33 +249,39 @@ class OrgService extends ServiceBase {
}
async byPid(obj) {
var list = await this.dao.findAll({
pid: obj.pid || 0,
});
return list;
try {
var list = await this.dao.findAll({
pid: obj.pid || 0,
});
return system.getResult(list);
} catch (error) {
return system.getResult(-1,`系统错误 错误信息 ${error}`);
}
}
/**
* 结构树
*/
async tree() {
var all = await this.dao.all();
var pmap = {};
for (var item of all) {
var list = pmap[item.pid];
if (!list) {
list = [];
try {
var all = await this.dao.all();
var pmap = {};
for (var item of all) {
var list = pmap[item.pid];
if (!list) {
list = [];
}
list.push(item);
pmap[item.pid] = list;
}
list.push(item);
pmap[item.pid] = list;
if (item.pid === 0) {
tree = item;
for(var item of all) {
item.childs = pmap[item.id] || [];
}
console.log(item.pid);
}
for(var item of all) {
item.childs = pmap[item.id] || [];
return system.getResult(pmap[0]);
} catch (error) {
return system.getResult(-1,`系统错误 错误信息 ${error}`);
}
return pmap[0];
}
}
module.exports = OrgService;
\ No newline at end of file
......@@ -17,6 +17,14 @@ class RoleService extends ServiceBase {
}
}
async apiQueryById(params){
try {
return await this.queryById(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* role 更新
* @param {*} params
......@@ -136,6 +144,25 @@ class RoleService extends ServiceBase {
}
/**
* 根据ID查询明细
* @param {*} params
*/
async queryById(params){
try {
if(!params.id){
return system.getResult(-1,`参数错误 ID不能为空`);
}
let _role = await this.findById(this.trim(params.id));
if(!_role){
return system.getResult(-1,`角色不存在`);
}
return system.getResult(_role);
} catch (error) {
return system.getResult(-1, `系统错误 错误信息${error}`);
}
}
/**
* 查询列表
* @param {*} params
*/
......
......@@ -53,8 +53,17 @@ class SaasService extends ServiceBase {
}
}
/**
* asss明细
* @param {*} params
*/
async apiQueryById(params){
try {
return this.queryById(params);
} catch (error) {
return system.getResult(-1,`系统错误 错误信息 ${error}`);
}
}
/********************************************************************** */
......@@ -168,5 +177,20 @@ class SaasService extends ServiceBase {
return system.getResult(-1,`系统错误 错误信息 ${error}`);
}
}
async queryById(params){
try {
if(!params.id){
return system.getResult(-1,`参数错误 ID不能为空`);
}
let _saas = await this.findById(this.trim(params.id));
if(!_saas){
return system.getResult(-1,`当前信息不存在`);
}
return system.getResult(_saas);
} catch (error) {
return system.getResult(-1,`系统错误 错误信息 ${error}`);
}
}
}
module.exports = SaasService;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment