优化增加日志输出,不执行删除命令

This commit is contained in:
yuxueliang0813 2025-07-18 13:17:45 +08:00
parent 57ae76b7e7
commit 1ba724bf57
1 changed files with 9 additions and 0 deletions

View File

@ -4,9 +4,13 @@ import kd.bos.db.DB;
import kd.bos.db.DBRoute;
import kd.bos.form.events.AfterDoOperationEventArgs;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
public class TestDBFormPlugin extends AbstractFormPlugin {
private final static Log logger = LogFactory.getLog(TestDBFormPlugin.class);
@Override
public void afterDoOperation(AfterDoOperationEventArgs e) {
super.afterDoOperation(e);
@ -14,7 +18,12 @@ public class TestDBFormPlugin extends AbstractFormPlugin {
String dbnum = (String) this.getModel().getValue("shjh_dbnum");//标识
String sql = (String) this.getModel().getValue("shjh_sqls");//sql语句
try{
if(sql.contains("delete") || sql.contains("DELETE") || sql.contains("Delete")){
//语句包含删除命令不执行直接返回
return;
}
DB.update(DBRoute.of(dbnum), sql,null);
logger.info("执行语句:"+sql);
}catch(Exception ex){
this.getView().showMessage("执行失败:" + ex.getMessage());
}