Commit 1ffea5d7 by 王昆

gsb

parent f19544e9
...@@ -5,14 +5,17 @@ class DeliverDao extends Dao { ...@@ -5,14 +5,17 @@ class DeliverDao extends Dao {
super(Dao.getModelName(DeliverDao)); super(Dao.getModelName(DeliverDao));
} }
async getList(isEnabled, attrs) { async getList(params) {
attrs = attrs || "*" let attrs = params.attrs || "*"
var sql = []; var sql = [];
sql.push("SELECT "); sql.push("SELECT ");
sql.push(attrs); sql.push(attrs);
sql.push("FROM d_deliver"); sql.push("FROM d_deliver WHERE 1 = 1 ");
if (isEnabled == 1) { if (params.isEnabled == 1) {
sql.push("WHERE isEnabled = 1"); sql.push("AND isEnabled = 1");
}
if (params.saas_id) {
sql.push("AND saas_id = :saas_id");
} }
return await this.customQuery(sql.join(" ")) || []; return await this.customQuery(sql.join(" ")) || [];
} }
......
...@@ -3,6 +3,7 @@ const settings = require("../../../../config/settings"); ...@@ -3,6 +3,7 @@ const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey); const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => {
return db.define("businessscope", { return db.define("businessscope", {
saas_id: DataTypes.STRING,
domicile_id: DataTypes.STRING, domicile_id: DataTypes.STRING,
businessType: DataTypes.STRING, businessType: DataTypes.STRING,
businessscope: DataTypes.STRING, businessscope: DataTypes.STRING,
......
...@@ -3,6 +3,7 @@ const settings = require("../../../../config/settings"); ...@@ -3,6 +3,7 @@ const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey); const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => {
return db.define("deliverorg", { return db.define("deliverorg", {
saas_id: DataTypes.STRING,
deliver_id: DataTypes.STRING, deliver_id: DataTypes.STRING,
company_id: DataTypes.INTEGER, company_id: DataTypes.INTEGER,
code: DataTypes.STRING, code: DataTypes.STRING,
......
...@@ -101,12 +101,10 @@ class BusinessscopeService extends ServiceBase { ...@@ -101,12 +101,10 @@ class BusinessscopeService extends ServiceBase {
} }
async save(params) { async save(params) {
var domicileId = params.domicileId; let domicileId = this.trim(params.domicileId);
if (!domicileId) { let saas_id = this.trim(params.saas_id);
return system, getResult(null, domicileId); let id = this.trim(params.id);
} let bsc;
var id = params.id;
var bsc;
if (id) { if (id) {
bsc = await this.dao.findById(id); bsc = await this.dao.findById(id);
} else { } else {
...@@ -115,8 +113,8 @@ class BusinessscopeService extends ServiceBase { ...@@ -115,8 +113,8 @@ class BusinessscopeService extends ServiceBase {
bsc.businessType = this.trim(params.businesssType); bsc.businessType = this.trim(params.businesssType);
bsc.businessscope = this.trim(params.businessscope); bsc.businessscope = this.trim(params.businessscope);
bsc.isEnabled = params.isEnabled == 1 ? true : false; bsc.isEnabled = true;
bsc.isEnabled = 1; bsc.saas_id = saas_id;
if(bsc.id) { if(bsc.id) {
bsc = await bsc.save(); bsc = await bsc.save();
...@@ -131,7 +129,9 @@ class BusinessscopeService extends ServiceBase { ...@@ -131,7 +129,9 @@ class BusinessscopeService extends ServiceBase {
var pageSize = Number(params.pageSize || 10); var pageSize = Number(params.pageSize || 10);
var where = {}; var where = {};
if (params.saas_id) {
where.saas_id = params.saas_id;
}
if (params.domicileId) { if (params.domicileId) {
where.domicile_id = params.domicileId; where.domicile_id = params.domicileId;
} }
...@@ -161,13 +161,14 @@ class BusinessscopeService extends ServiceBase { ...@@ -161,13 +161,14 @@ class BusinessscopeService extends ServiceBase {
return; return;
} }
var ids = []; let ids = [];
for(var item of rows) { for (var item of rows) {
ids.push(item.domicile_id); if (item.domicile_id) {
ids.push(item.domicile_id);
}
} }
let map = await this.domicileDao.findMapByIds(ids);
var map = await this.domicileDao.findMapByIds(ids); for (var item of rows) {
for(var item of rows) {
item.domicile = map[item.domicile_id] || {}; item.domicile = map[item.domicile_id] || {};
this.handleDate(item.domicile, ["created_at"], null, -8); this.handleDate(item.domicile, ["created_at"], null, -8);
} }
......
...@@ -11,7 +11,7 @@ class DeliverService extends ServiceBase { ...@@ -11,7 +11,7 @@ class DeliverService extends ServiceBase {
async apiAll(params) { async apiAll(params) {
try { try {
return await this.allList(); return await this.allList(params);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
return system.getResult(null, "接口异常"); return system.getResult(null, "接口异常");
...@@ -192,8 +192,9 @@ class DeliverService extends ServiceBase { ...@@ -192,8 +192,9 @@ class DeliverService extends ServiceBase {
return system.getResultSuccess(); return system.getResultSuccess();
} }
async allList() { async allList(params) {
var list = await this.dao.getList(1); params.isEnabled = 1;
var list = await this.dao.getList(params);
return system.getResultSuccess(list); return system.getResultSuccess(list);
} }
...@@ -210,11 +211,14 @@ class DeliverService extends ServiceBase { ...@@ -210,11 +211,14 @@ class DeliverService extends ServiceBase {
let pageSize = Number(params.pageSize || 10); let pageSize = Number(params.pageSize || 10);
let where = {}; let where = {};
if(params.id){ if (params.id) {
where.id=this.trim(params.id); where.id = this.trim(params.id);
} }
if(params.name){ if (params.name) {
where.name=this.trim(params.name); where.name = this.trim(params.name);
}
if (params.saas_id) {
where.saas_id = this.trim(params.saas_id);
} }
let orderby = [ let orderby = [
["id", 'desc'] ["id", 'desc']
...@@ -440,7 +444,6 @@ class DeliverService extends ServiceBase { ...@@ -440,7 +444,6 @@ class DeliverService extends ServiceBase {
let real_name = this.trim(params.real_name); let real_name = this.trim(params.real_name);
let ucname = this.trim(params.ucname); let ucname = this.trim(params.ucname);
let org_id = params.org_id; let org_id = params.org_id;
let password = params.password;
let isAdmin = Number(params.isAdmin || 0); let isAdmin = Number(params.isAdmin || 0);
let authArr = []; let authArr = [];
if (params.auth) { if (params.auth) {
...@@ -576,13 +579,12 @@ class DeliverService extends ServiceBase { ...@@ -576,13 +579,12 @@ class DeliverService extends ServiceBase {
org.del_flag = 0; org.del_flag = 0;
org.group_type = 0; org.group_type = 0;
if (org.id) { if (org.id) {
await org.save(); org = await org.save();
// TODO 修改该组织机构下用户树
} else { } else {
org.saas_id = this.trim(params.saas_id);
org = await this.deliverorgDao.model.create(org); org = await this.deliverorgDao.model.create(org);
} }
return system.getResultSuccess(); return system.getResultSuccess(org);
} }
} }
......
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