Commit 6328b659 by 王昆

gsb

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