Commit 88e569e9 by 王昆

gsb

parent a829ae37
const system = require("../../../system");
const Dao = require("../../dao.base");
class DeliverorgDao extends Dao {
constructor() {
super(Dao.getModelName(DeliverorgDao));
}
async findListByIds(ids) {
if (!ids || ids.length == 0) {
return [];
}
var sql = [];
sql.push("SELECT");
sql.push("*");
sql.push("FROM d_deliver_org");
sql.push("WHERE id IN (:ids)");
return await this.customQuery(sql.join(" "), {
ids: ids
}) || [];
}
async findMapByIds(ids) {
var result = {};
if (!ids || ids.length == 0) {
return result;
}
var list = await this.findListByIds(ids);
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.id] = item;
}
return result;
}
}
module.exports = DeliverorgDao;
// var u=new UserDao();
// var roledao=system.getObject("db.roleDao");
// (async ()=>{
// var users=await u.model.findAll({where:{app_id:1}});
// var role=await roledao.model.findOne({where:{code:"guest"}});
// console.log(role);
// for(var i=0;i<users.length;i++){
// await users[i].setRoles([role]);
// console.log(i);
// }
//
// })();
\ No newline at end of file
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("deliverorg", {
deliver_id: DataTypes.STRING,
company_id: DataTypes.INTEGER,
code: DataTypes.STRING,
name: DataTypes.STRING,
parent_id: DataTypes.INTEGER,
path: DataTypes.STRING,
type: DataTypes.STRING,
group_type: DataTypes.STRING,
description: DataTypes.STRING,
del_flag: DataTypes.STRING,
crt_time: DataTypes.DATE,
crt_user: DataTypes.STRING,
crt_name: DataTypes.STRING,
crt_host: DataTypes.STRING,
upd_time: DataTypes.DATE,
upd_user: DataTypes.STRING,
upd_name: DataTypes.STRING,
upd_host: DataTypes.STRING,
}, {
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'd_deliver_org',
validate: {},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
\ No newline at end of file
...@@ -13,6 +13,9 @@ module.exports = (db, DataTypes) => { ...@@ -13,6 +13,9 @@ module.exports = (db, DataTypes) => {
allowNull: true, allowNull: true,
}, },
saas_id: DataTypes.STRING, saas_id: DataTypes.STRING,
org_id: DataTypes.INTEGER,
org_path: DataTypes.STRING,
auth: DataTypes.STRING,
}, { }, {
paranoid: true, //假的删除 paranoid: true, //假的删除
underscored: true, underscored: true,
......
...@@ -6,6 +6,7 @@ class DeliverService extends ServiceBase { ...@@ -6,6 +6,7 @@ class DeliverService extends ServiceBase {
constructor() { constructor() {
super("deliver", ServiceBase.getDaoName(DeliverService)); super("deliver", ServiceBase.getDaoName(DeliverService));
this.deliveruserDao = system.getObject("db.deliver.deliveruserDao"); this.deliveruserDao = system.getObject("db.deliver.deliveruserDao");
this.deliverorgDao = system.getObject("db.deliver.deliverorgDao");
} }
async apiAll(params) { async apiAll(params) {
...@@ -132,6 +133,7 @@ class DeliverService extends ServiceBase { ...@@ -132,6 +133,7 @@ class DeliverService extends ServiceBase {
} }
user = user || {}; user = user || {};
user.real_name = params.real_name; user.real_name = params.real_name;
user.auth = '1111';
if (user.id) { if (user.id) {
user = await user.save(); user = await user.save();
} else { } else {
...@@ -144,6 +146,31 @@ class DeliverService extends ServiceBase { ...@@ -144,6 +146,31 @@ class DeliverService extends ServiceBase {
} }
deliver.admin_id = user.id; deliver.admin_id = user.id;
await deliver.save(); await deliver.save();
if(user.org_id) {
let org = await this.deliverorgDao.findById(user.org_id);
org.name = deliver.name;
org.path = deliver.name + ".";
await org.save();
user.org_path = org.path;
await user.save();
} else {
let org = {
deliver_id: deliver.id,
name: deliver.name,
parent_id: 0,
path: deliver.name + ".",
type: '',
del_flag: 0,
group_type: 0
};
org = await this.deliverorgDao.model.create(org);
user.org_id = org.id;
user.org_path = org.path;
await user.save();
}
return system.getResultSuccess(); return system.getResultSuccess();
} }
......
...@@ -10,10 +10,10 @@ var settings={ ...@@ -10,10 +10,10 @@ var settings={
user: "write", user: "write",
password: "write", password: "write",
config: { config: {
// host: '43.247.184.35', // host: '192.168.18.237',
// port: 8899, // port: 3306,
host: '192.168.18.237', host: '43.247.184.35',
port: 3306, port: 8899,
dialect: 'mysql', dialect: 'mysql',
operatorsAliases: false, operatorsAliases: false,
......
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