doomiwork 3.7.5 → 3.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/controller.js +1 -1
- package/core/database/daoBase.js +17 -5
- package/core/database/mysqlbase.js +1 -1
- package/package.json +1 -1
package/core/controller.js
CHANGED
|
@@ -151,7 +151,7 @@ class controller {
|
|
|
151
151
|
if (!id) id = req.params.id;
|
|
152
152
|
if (!id) return {successed:false,errcode:-2,errmsg:'缺失批量操作的id'}
|
|
153
153
|
let batchSql = rcp.parseAndReplaceSql(req,this._daoModel.BatchSql());
|
|
154
|
-
let result = await this._daoModel.batchUpdate(batchSql,model,id)
|
|
154
|
+
let result = await this._daoModel.batchUpdate(batchSql, model, id, req.user?.id)
|
|
155
155
|
this.logUserAction(req,this._daoModel.getBusiness(),6,result.successed?0:-1);
|
|
156
156
|
return result;
|
|
157
157
|
}
|
package/core/database/daoBase.js
CHANGED
|
@@ -105,10 +105,10 @@ class mysqlDao extends dao{
|
|
|
105
105
|
////如果是逻辑删除,则只将记录的删除状态设置为1
|
|
106
106
|
if(this.tableoption.logicDelete) {
|
|
107
107
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
108
|
+
let sqlDelete = `update ${this.tableoption.tableName} set #DELETEBY# #DELETEDATE# ${this.tableoption.logicDeleteField || 'rec_isdeleted'} =1 where ${this.tableoption.primaryKey}=? ${this.tableoption.forcefilter}`;
|
|
109
|
+
sqlDelete = sqlDelete.replace('#DELETEBY#', this.tableoption.logDeleteBy?`${this.tableoption.logDeleteBy}=?,`:'')
|
|
110
|
+
sqlDelete = sqlDelete.replace('#DELETEDATE#', this.tableoption.logDeleteDate ? `${this.tableoption.logDeleteDate}=now(),` : '');
|
|
111
|
+
return sqlDelete;
|
|
112
112
|
}
|
|
113
113
|
return `delete from ${this.tableoption.tableName} where ${this.tableoption.primaryKey}=? ${this.tableoption.forcefilter}`;
|
|
114
114
|
}
|
|
@@ -128,7 +128,12 @@ class mysqlDao extends dao{
|
|
|
128
128
|
async update(Sql, model, id) {return this.executeSql(Sql, [model, id]);}
|
|
129
129
|
///删除记录
|
|
130
130
|
async delete(Sql, id,userid) {
|
|
131
|
+
if (this.tableoption.logicDelete && this.tableoption.logDeleteBy){
|
|
132
|
+
return this.executeSql(Sql, [userid,id]);
|
|
133
|
+
}
|
|
131
134
|
return this.executeSql(Sql, id);
|
|
135
|
+
///
|
|
136
|
+
//return this.executeSql(Sql, id);
|
|
132
137
|
/*if (result.successed && this.tableoption.logicDelete && userid && (this.tableoption.logDeleteBy || this.tableoption.logDeleteDate)){
|
|
133
138
|
let sqlLog = `update ${this.tableoption.tableName} set ? where ${this.tableoption.primaryKey}=? ${this.tableoption.forcefilter}`;
|
|
134
139
|
let model = {};
|
|
@@ -327,7 +332,14 @@ class mysqlDao extends dao{
|
|
|
327
332
|
* @param {*} model 需要改变的属性键值对
|
|
328
333
|
* @param {*} id 批量操作的id集合,逗号分开
|
|
329
334
|
*/
|
|
330
|
-
async batchUpdate(Sql,model,id){
|
|
335
|
+
async batchUpdate(Sql,model,id,userid){
|
|
336
|
+
////记录批量删除的人
|
|
337
|
+
if (this.tableoption.logicDelete && this.tableoption.logDeleteBy && model[this.tableoption.logicDeleteField || 'rec_isdeleted']!=null ) {
|
|
338
|
+
model[this.tableoption.logDeleteBy] = userid;
|
|
339
|
+
if (this.tableoption.logDeleteDate){
|
|
340
|
+
model[this.tableoption.logDeleteDate] = Moment().format('YYYY-MM-DD HH:mm:ss');
|
|
341
|
+
}
|
|
342
|
+
}
|
|
331
343
|
return this.executeSql(Sql, [model, id])
|
|
332
344
|
.then(result=>{
|
|
333
345
|
return {successed:true,count:result.rows.affectedRows }
|
|
@@ -45,7 +45,7 @@ class Database {
|
|
|
45
45
|
async existedSqlData(sqlCommand, parameters, conn, autoclose = true) {
|
|
46
46
|
let sqlExecute = await this.executeSql(sqlCommand, parameters, conn, autoclose);
|
|
47
47
|
if (!sqlExecute.successed) return { successed: false }
|
|
48
|
-
if (!sqlExecute.rows || sqlExecute.rows.length == 0) return {
|
|
48
|
+
if (!sqlExecute.rows || sqlExecute.rows.length == 0) return { successed: true, existed: false }
|
|
49
49
|
return { successed: true, existed: true, ...sqlExecute.rows[0] }
|
|
50
50
|
}
|
|
51
51
|
/**
|