Skip to content

Commit

Permalink
instance_tasks 增删改查增加try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
sunhaolin committed Apr 16, 2024
1 parent 2c83d20 commit c886ced
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions packages/workflow/engine/manager/instance_tasks_manager.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* @Author: [email protected]
* @Date: 2022-12-28 10:36:06
* @LastEditors: baozhoutao@steedos.com
* @LastEditTime: 2024-03-05 16:32:39
* @LastEditors: 孙浩林 sunhaolin@steedos.com
* @LastEditTime: 2024-04-16 13:14:20
* @Description:
*/
'use strict';
Expand All @@ -16,6 +16,8 @@ function _insert(taskDoc) {
const newTaskDoc = Meteor.wrapAsync(function (taskDoc, cb) {
getObject('instance_tasks').insert(taskDoc).then(function (resolve, reject) {
cb(reject, resolve);
}).catch(function (err) {
cb(err, null);
});
})(taskDoc);
return newTaskDoc
Expand All @@ -25,6 +27,8 @@ function _directInsert(taskDoc) {
const newTaskDoc = Meteor.wrapAsync(function (taskDoc, cb) {
getObject('instance_tasks').directInsert(taskDoc).then(function (resolve, reject) {
cb(reject, resolve);
}).catch(function (err) {
cb(err, null);
});
})(taskDoc);
return newTaskDoc
Expand All @@ -34,6 +38,8 @@ function _update(_id, taskDoc) {
const latestTaskDoc = Meteor.wrapAsync(function (_id, taskDoc, cb) {
getObject('instance_tasks').update(_id, taskDoc).then(function (resolve, reject) {
cb(reject, resolve);
}).catch(function (err) {
cb(err, null);
});
})(_id, taskDoc);
return latestTaskDoc
Expand All @@ -43,6 +49,8 @@ function _remove(_id) {
const result = Meteor.wrapAsync(function (_id, cb) {
getObject('instance_tasks').delete(_id).then(function (resolve, reject) {
cb(reject, resolve);
}).catch(function (err) {
cb(err, null);
});
})(_id);
return result
Expand All @@ -52,6 +60,8 @@ function _directRemove(_id) {
const result = Meteor.wrapAsync(function (_id, cb) {
getObject('instance_tasks').directDelete(_id).then(function (resolve, reject) {
cb(reject, resolve);
}).catch(function (err) {
cb(err, null);
});
})(_id);
return result
Expand All @@ -61,6 +71,8 @@ function _find(query) {
const taskDocs = Meteor.wrapAsync(function (query, cb) {
getObject('instance_tasks').find(query).then(function (resolve, reject) {
cb(reject, resolve);
}).catch(function (err) {
cb(err, null);
});
})(query);
return taskDocs
Expand All @@ -70,6 +82,8 @@ function _count(query) {
const count = Meteor.wrapAsync(function (query, cb) {
getObject('instance_tasks').count(query).then(function (resolve, reject) {
cb(reject, resolve);
}).catch(function (err) {
cb(err, null);
});
})(query);
return count
Expand All @@ -84,7 +98,7 @@ function _count(query) {
*/
function insert_instance_tasks(insId, traceId, approveId) {
const taskDoc = _makeTaskDoc(insId, traceId, approveId)
if(DISABLE_DIRECT){
if (DISABLE_DIRECT) {
return _insert(taskDoc)
}
return _directInsert(taskDoc)
Expand Down Expand Up @@ -205,10 +219,10 @@ function remove_instance_tasks_by_instance_id(insId) {
function direct_remove_many_instance_tasks(approveIds) {
const results = []
for (const aId of approveIds) {
if(DISABLE_DIRECT){
if (DISABLE_DIRECT) {
const r = _remove(aId)
results.push(r)
}else{
} else {
const r = _directRemove(aId)
results.push(r)
}
Expand Down

0 comments on commit c886ced

Please sign in to comment.