Commit 6328b659 by 王昆

gsb

parent a2d78833
...@@ -70,7 +70,7 @@ class APIBase extends DocBase { ...@@ -70,7 +70,7 @@ class APIBase extends DocBase {
async doexec(gname, methodname, pobj, query, req) { async doexec(gname, methodname, pobj, query, req) {
var requestid = this.getUUID(); var requestid = this.getUUID();
try { try {
var rtn = await this[methodname](pobj, query, req); var rtn = await this[methodname](pobj, query, req) || {};
rtn.requestid = requestid; rtn.requestid = requestid;
this.oplogSve.createDb({ this.oplogSve.createDb({
......
...@@ -4,7 +4,14 @@ var settings = require("../../../../config/settings"); ...@@ -4,7 +4,14 @@ var settings = require("../../../../config/settings");
class ActionAPI extends APIBase { class ActionAPI extends APIBase {
constructor() { constructor() {
super(); super();
this.saasSve = system.getObject("service.saas.saasSve");
this.userSve = system.getObject("service.user.userSve");
this.orgSve = system.getObject("service.org.orgSve");
this.authSve = system.getObject("service.auth.authSve");
this.roleSve = system.getObject("service.role.roleSve");
} }
/** /**
* 接口跳转 * 接口跳转
* action_process 执行的流程 * action_process 执行的流程
...@@ -47,18 +54,28 @@ class ActionAPI extends APIBase { ...@@ -47,18 +54,28 @@ class ActionAPI extends APIBase {
case "updOrg": case "updOrg":
break; break;
case "delOrg": case "delOrg":
// 是否 uc_user_org 表中有数据
// 删除
break; break;
case "listOrg": case "listOrg":
break; break;
// 菜单权限 // 菜单权限
case "addAuth": case "addAuth":
return this.authSve.add(action_body);
break; break;
case "updAuth": case "updAuth":
return this.authSve.upd(action_body);
break; break;
case "delAuth": case "tree":
return this.authSve.tree(action_body);
break; break;
case "listAuth": case "byPid":
return this.authSve.byPid(action_body);
break;
case "delAuth":
// TODO 验证是否有角色关联
return this.authSve.del(action_body);
break; break;
// 角色 // 角色
...@@ -71,8 +88,6 @@ class ActionAPI extends APIBase { ...@@ -71,8 +88,6 @@ class ActionAPI extends APIBase {
case "listRole": case "listRole":
break; break;
// 用户 // 用户
case "addUser": case "addUser":
break; break;
...@@ -82,12 +97,6 @@ class ActionAPI extends APIBase { ...@@ -82,12 +97,6 @@ class ActionAPI extends APIBase {
break; break;
case "listUser": case "listUser":
break; break;
} }
return opResult; return opResult;
} }
......
...@@ -78,7 +78,6 @@ class Dao { ...@@ -78,7 +78,6 @@ class Dao {
where: qobj where: qobj
}); });
if (en != null) { if (en != null) {
1
return en.destroy(); return en.destroy();
} }
return null; return null;
...@@ -157,6 +156,10 @@ class Dao { ...@@ -157,6 +156,10 @@ class Dao {
console.log(qc); console.log(qc);
return qc; return qc;
} }
async findAll(obj){
return await this.model.findAll({where: obj || {}});
}
async findAndCountAll(qobj, t) { async findAndCountAll(qobj, t) {
var qc = this.buildQuery(qobj); var qc = this.buildQuery(qobj);
var apps = await this.model.findAndCountAll(qc); var apps = await this.model.findAndCountAll(qc);
......
...@@ -4,5 +4,9 @@ class AuthDao extends Dao { ...@@ -4,5 +4,9 @@ class AuthDao extends Dao {
constructor() { constructor() {
super(Dao.getModelName(AuthDao)); super(Dao.getModelName(AuthDao));
} }
async all() {
return this.customQuery("SELECT * FROM uc_auth WHERE deleted_at IS NULL");
}
} }
module.exports = AuthDao; module.exports = AuthDao;
\ No newline at end of file
...@@ -7,6 +7,7 @@ module.exports = (db, DataTypes) => { ...@@ -7,6 +7,7 @@ module.exports = (db, DataTypes) => {
menuType: DataTypes.INTEGER, menuType: DataTypes.INTEGER,
name: DataTypes.STRING, name: DataTypes.STRING,
icon: DataTypes.STRING, icon: DataTypes.STRING,
path: DataTypes.STRING,
sort: DataTypes.STRING, sort: DataTypes.STRING,
saas_id: DataTypes.STRING, saas_id: DataTypes.STRING,
}, { }, {
......
...@@ -4,6 +4,97 @@ const settings = require("../../../../config/settings") ...@@ -4,6 +4,97 @@ const settings = require("../../../../config/settings")
class AuthService extends ServiceBase { class AuthService extends ServiceBase {
constructor() { constructor() {
super("auth", ServiceBase.getDaoName(AuthService)); super("auth", ServiceBase.getDaoName(AuthService));
this.pmap = {};
}
async add(obj) {
var saas_id = Number(obj.saas_id || 0);
var pid = Number(obj.pid || 0);
if (!saas_id) {
return system.getResult(null, "请指定saas_id");
}
if (pid === 0) {
// 验证是否存在其他权限
var exist = await this.findCount({
where: {
saas_id: saas_id
}
});
if (exist) {
return system.getResult(null, "菜单根目录已经存在");
}
}
obj.pid = pid;
obj.saas_id = saas_id;
obj.menuType = Number(obj.menuType || 1);
obj.name = this.trim(obj.name);
obj.icon = this.trim(obj.icon);
obj.path = this.trim(obj.path);
obj.sort = Number(obj.sort || 99);
var obj = await this.dao.create(obj);
return system.getResultSuccess();
}
async upd(obj) {
var saas_id = Number(obj.saas_id || 0);
var pid = Number(obj.pid || 0);
var id = Number(obj.id || 0);
if (!id) {
return system.getResult(null, "菜单不存在");
}
var auth = await this.findById(id);
if (!saas_id) {
return system.getResult(null, "请指定saas_id");
}
if (saas_id != auth.saas_id) {
return system.getResult(null, "修改失败,权限不足");
}
auth.menuType = Number(obj.menuType || 1);
auth.name = this.trim(obj.name);
auth.icon = this.trim(obj.icon);
auth.path = this.trim(obj.path);
auth.sort = Number(obj.sort || 99);
await auth.save();
return system.getResultSuccess();
}
async byPid(obj) {
var list = await this.dao.findAll({
pid: obj.pid || 0,
});
return list;
}
async tree() {
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;
console.log(item.pid);
}
for(var item of all) {
item.childs = pmap[item.id] || [];
}
return system.getResultSuccess(pmap[0]);
}
async del(obj) {
await this.delete({id: obj.id});
return system.getResultSuccess();
} }
} }
module.exports = AuthService; module.exports = AuthService;
\ No newline at end of file
...@@ -183,6 +183,10 @@ class ServiceBase { ...@@ -183,6 +183,10 @@ class ServiceBase {
async findById(oid) { async findById(oid) {
return this.dao.findById(oid); return this.dao.findById(oid);
} }
async findAll(obj){
return await this.dao.findAll(obj);
}
/* /*
返回20位业务订单号 返回20位业务订单号
prefix:业务前缀 prefix:业务前缀
......
...@@ -7,12 +7,10 @@ var settings={ ...@@ -7,12 +7,10 @@ var settings={
}, },
database:{ database:{
dbname : "xgg-uc", dbname : "xgg-uc",
user: "root", user: "write",
password: "root", password: "write",
config: { config: {
// host: '43.247.184.35', host: '192.168.18.237',
// port: 8899,
host: '192.168.18.110',
port: 3306, port: 3306,
dialect: 'mysql', dialect: 'mysql',
......
...@@ -24,7 +24,7 @@ var settings = { ...@@ -24,7 +24,7 @@ var settings = {
salt: "%iatpD1gcxz7iF#B", salt: "%iatpD1gcxz7iF#B",
defaultpwd: "987456", defaultpwd: "987456",
basepath: path.normalize(path.join(__dirname, '../..')), basepath: path.normalize(path.join(__dirname, '../..')),
port: process.env.NODE_PORT || 3103, port: process.env.NODE_PORT || 3106,
reqEsAddr: function () { reqEsAddr: function () {
if (this.env == "dev") { if (this.env == "dev") {
var localsettings = require("./localsettings"); var localsettings = require("./localsettings");
......
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