|
@@ -110,11 +110,12 @@ module.exports = app => {
|
|
this.transaction = await this.db.beginTransaction();
|
|
this.transaction = await this.db.beginTransaction();
|
|
try {
|
|
try {
|
|
const data = {
|
|
const data = {
|
|
- tender_id: tender_id,
|
|
|
|
- rpt_id: rpt_id,
|
|
|
|
- sid: sid,
|
|
|
|
|
|
+ tender_id,
|
|
|
|
+ rpt_id,
|
|
|
|
+ sid,
|
|
rel_content: JSON.stringify(relArr),
|
|
rel_content: JSON.stringify(relArr),
|
|
};
|
|
};
|
|
|
|
+ // console.log(data);
|
|
rst = await this.transaction.insert(this.tableName, data);
|
|
rst = await this.transaction.insert(this.tableName, data);
|
|
await this.transaction.commit();
|
|
await this.transaction.commit();
|
|
} catch (ex) {
|
|
} catch (ex) {
|
|
@@ -153,13 +154,13 @@ module.exports = app => {
|
|
async updateRoleRelationship(id, tender_id, rpt_id, sid, relArr) {
|
|
async updateRoleRelationship(id, tender_id, rpt_id, sid, relArr) {
|
|
let rst = null;
|
|
let rst = null;
|
|
if (id < 0) {
|
|
if (id < 0) {
|
|
- rst = this.createRoleRelationship(tender_id, rpt_id, sid, relArr);
|
|
|
|
|
|
+ rst = await this.createRoleRelationship(tender_id, rpt_id, sid, relArr);
|
|
} else {
|
|
} else {
|
|
this.transaction = await this.db.beginTransaction();
|
|
this.transaction = await this.db.beginTransaction();
|
|
try {
|
|
try {
|
|
- const data = { id: id, tender_id: tender_id, rpt_id: rpt_id, sid: sid, rel_content: JSON.stringify(relArr) };
|
|
|
|
|
|
+ const data = { id, tender_id, rpt_id, sid, rel_content: JSON.stringify(relArr) };
|
|
rst = await this.transaction.update(this.tableName, data);
|
|
rst = await this.transaction.update(this.tableName, data);
|
|
- this.transaction.commit();
|
|
|
|
|
|
+ await this.transaction.commit();
|
|
} catch (ex) {
|
|
} catch (ex) {
|
|
console.log(ex);
|
|
console.log(ex);
|
|
// 回滚
|
|
// 回滚
|
|
@@ -170,26 +171,21 @@ module.exports = app => {
|
|
}
|
|
}
|
|
|
|
|
|
async updateMultiRoleRelationship(orgParams, newRelArr) {
|
|
async updateMultiRoleRelationship(orgParams, newRelArr) {
|
|
- let rst = false;
|
|
|
|
- this.transaction = await this.db.beginTransaction();
|
|
|
|
- try {
|
|
|
|
- // const data = { id: id, tender_id: tender_id, rpt_id: rpt_id, sid: sid, rel_content: JSON.stringify(relArr) };
|
|
|
|
- // rst = await this.transaction.update(this.tableName, data);
|
|
|
|
- // this.transaction.commit();
|
|
|
|
- for (let idx = 0; idx < orgParams.length; idx++) {
|
|
|
|
- const param = orgParams[idx];
|
|
|
|
- const data = { tender_id: param[0], sid: param[1], rpt_id: param[2] };
|
|
|
|
|
|
+ for (let idx = 0; idx < orgParams.length; idx++) {
|
|
|
|
+ const param = orgParams[idx];
|
|
|
|
+ const data = { tender_id: param[0], sid: param[1], rpt_id: param[2] };
|
|
|
|
+ this.transaction = await this.db.beginTransaction();
|
|
|
|
+ try {
|
|
await this.transaction.delete(this.tableName, data);
|
|
await this.transaction.delete(this.tableName, data);
|
|
- this.createRoleRelationship(param[0], param[2], param[0], newRelArr);
|
|
|
|
|
|
+ this.transaction.commit();
|
|
|
|
+ await this.createRoleRelationship(param[0], param[2], param[1], newRelArr);
|
|
|
|
+ } catch (ex) {
|
|
|
|
+ console.log(ex.toString());
|
|
|
|
+ // 回滚
|
|
|
|
+ await this.transaction.rollback();
|
|
}
|
|
}
|
|
- rst = true;
|
|
|
|
- this.transaction.commit();
|
|
|
|
- } catch (ex) {
|
|
|
|
- console.log(ex.toString());
|
|
|
|
- // 回滚
|
|
|
|
- await this.transaction.rollback();
|
|
|
|
}
|
|
}
|
|
- return rst;
|
|
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return RoleRptRel;
|
|
return RoleRptRel;
|