|
@@ -673,32 +673,40 @@ module.exports = app => {
|
|
|
if (data._csrf_j !== undefined) {
|
|
|
delete data._csrf_j;
|
|
|
}
|
|
|
- const updateData = {
|
|
|
- id,
|
|
|
- };
|
|
|
- if (data.cooperation !== undefined && data.cooperation !== null) {
|
|
|
- updateData.cooperation = data.cooperation;
|
|
|
- delete data.cooperation;
|
|
|
- } else {
|
|
|
- updateData.cooperation = 0;
|
|
|
- }
|
|
|
- const notice_again = {
|
|
|
- checked: data.again_all !== undefined && data.again_all !== null,
|
|
|
- sp: {},
|
|
|
- };
|
|
|
- delete data.again_all;
|
|
|
- for (const sp in noticeAgainConst.sp) {
|
|
|
- notice_again.sp[sp] = data['again_' + sp] !== undefined && data['again_' + sp] !== null;
|
|
|
- delete data['again_' + sp];
|
|
|
+ let result = false;
|
|
|
+ const transaction = await this.db.beginTransaction();
|
|
|
+ try {
|
|
|
+ const updateData = {
|
|
|
+ id,
|
|
|
+ };
|
|
|
+ if (data.cooperation !== undefined && data.cooperation !== null) {
|
|
|
+ updateData.cooperation = data.cooperation;
|
|
|
+ delete data.cooperation;
|
|
|
+ } else {
|
|
|
+ updateData.cooperation = 0;
|
|
|
+ }
|
|
|
+ const notice_again = {
|
|
|
+ checked: data.again_all !== undefined && data.again_all !== null,
|
|
|
+ sp: {},
|
|
|
+ };
|
|
|
+ delete data.again_all;
|
|
|
+ for (const sp in noticeAgainConst.sp) {
|
|
|
+ notice_again.sp[sp] = data['again_' + sp] !== undefined && data['again_' + sp] !== null;
|
|
|
+ delete data['again_' + sp];
|
|
|
+ }
|
|
|
+ // 应该暂对应的重新发送的开关通知,并重新
|
|
|
+ await this.ctx.service.noticeAgain.updateUserNoticeAgain(transaction, id, notice_again);
|
|
|
+ updateData.notice_again = JSON.stringify(notice_again);
|
|
|
+ delete data.id;
|
|
|
+ updateData.permission = JSON.stringify(data);
|
|
|
+
|
|
|
+ const operate = await transaction.update(this.tableName, updateData);
|
|
|
+ result = operate.affectedRows > 0;
|
|
|
+ await transaction.commit();
|
|
|
+ } catch (err) {
|
|
|
+ await transaction.rollback();
|
|
|
+ throw err;
|
|
|
}
|
|
|
- updateData.notice_again = JSON.stringify(notice_again);
|
|
|
- delete data.id;
|
|
|
- updateData.permission = JSON.stringify(data);
|
|
|
-
|
|
|
- const operate = await this.db.update(this.tableName, updateData);
|
|
|
-
|
|
|
- const result = operate.affectedRows > 0;
|
|
|
-
|
|
|
return result;
|
|
|
}
|
|
|
|