use of com.qlangtech.tis.manage.biz.dal.pojo.OperationLog in project tis by qlangtech.
the class OfflineManager method editDatasourceTable.
public void editDatasourceTable(TISTable table, BasicModule action, IPluginContext pluginContext, Context context) throws Exception {
String dbName = table.getDbName();
String tableLogicName = table.getTableName();
// 检查db是否存在
DatasourceDbCriteria dbCriteria = new DatasourceDbCriteria();
dbCriteria.createCriteria().andNameEqualTo(dbName);
List<DatasourceDb> dbList = workflowDAOFacade.getDatasourceDbDAO().minSelectByExample(dbCriteria);
if (CollectionUtils.isEmpty(dbList)) {
action.addErrorMessage(context, "找不到这个数据库");
return;
}
int dbId = dbList.get(0).getId();
// 检查表是否存在
DatasourceTableCriteria tableCriteria = new DatasourceTableCriteria();
tableCriteria.createCriteria().andDbIdEqualTo(dbId).andNameEqualTo(tableLogicName);
List<DatasourceTable> tableList = workflowDAOFacade.getDatasourceTableDAO().minSelectByExample(tableCriteria);
if (CollectionUtils.isEmpty(tableList)) {
action.addErrorMessage(context, "该数据库下没有表" + tableLogicName);
return;
}
int tableId = tableList.get(0).getId();
DataSourceFactoryPluginStore dbPlugin = TIS.getDataBasePluginStore(new PostedDSProp(dbName));
dbPlugin.saveTable(tableLogicName);
// update git
// String path = dbName + "/" + tableLogicName;
// GitUtils.$().createTableDaily(table, "edit table " + table.getTableLogicName());
OperationLog operationLog = new OperationLog();
operationLog.setUsrName(action.getLoginUserName());
operationLog.setUsrId(action.getUserId());
operationLog.setOpType("editDatasourceTable");
action.addActionMessage(context, "数据库表修改成功");
action.setBizResult(context, tableId);
}
use of com.qlangtech.tis.manage.biz.dal.pojo.OperationLog in project tis by qlangtech.
the class OperationLogDAOImpl method deleteByPrimaryKey.
public int deleteByPrimaryKey(Integer opId) {
OperationLog key = new OperationLog();
key.setOpId(opId);
return this.deleteRecords("operation_log.ibatorgenerated_deleteByPrimaryKey", key);
}
use of com.qlangtech.tis.manage.biz.dal.pojo.OperationLog in project tis by qlangtech.
the class OperationLogInterceptor method doIntercept.
@Override
protected String doIntercept(ActionInvocation invocation) throws Exception {
BasicModule action = (BasicModule) invocation.getAction();
final Method method = action.getExecuteMethod();
final String result = invocation.invoke();
Func func = method.getAnnotation(Func.class);
if (func != null && !func.sideEffect()) {
return result;
}
AppDomainInfo appDomain = CheckAppDomainExistValve.getAppDomain(daoContext);
OperationLog log = new OperationLog();
log.setOpType(BasicModule.parseMehtodName());
if (StringUtils.startsWith(log.getOpType(), "doGet")) {
return result;
}
log.setCreateTime(new Date());
if (!(appDomain instanceof Nullable)) {
log.setAppName(appDomain.getAppName());
}
ActionProxy proxy = invocation.getProxy();
// log.setOpType(proxy.getMethod());
HttpServletRequest request = ServletActionContext.getRequest();
if (StringUtils.indexOf(request.getClass().getSimpleName(), "Mock") > -1) {
// 当前是测试流程的话就不需要记录日志了
return result;
}
IUser user = UserUtils.getUser(request, daoContext);
if (user == null) {
throw new IllegalStateException("user can not be null");
}
StringBuffer jsonObject = new StringBuffer();
JSONObject params = null;
Map<String, String[]> paramsMap = null;
String url = request.getRequestURL().toString();
jsonObject.append("request:");
jsonObject.append(url).append("\n");
String requestBody = null;
if (!ConfigFileContext.HTTPMethod.GET.name().equals(request.getMethod())) {
paramsMap = request.getParameterMap();
if (paramsMap.size() > 0) {
params = new JSONObject();
for (Map.Entry<String, String[]> entry : paramsMap.entrySet()) {
if (entry.getValue().length == 1) {
params.put(entry.getKey(), entry.getValue()[0]);
} else {
params.put(entry.getKey(), entry.getValue());
}
}
jsonObject.append("params:").append("\n");
jsonObject.append(params.toString(1)).append("\n");
}
try (ServletInputStream input = request.getInputStream()) {
if (!input.isFinished()) {
requestBody = IOUtils.toString(input, TisUTF8.get());
jsonObject.append("body:").append("\n");
jsonObject.append(requestBody).append("\n");
}
}
}
Context context = new MockContext();
jsonObject.append("\n=================================");
jsonObject.append("response:").append("\n");
jsonObject.append(AjaxValve.buildResultStruct(context));
log.setTabName(proxy.getActionName());
log.setUsrId(user.getId());
log.setUsrName(user.getName());
log.setOpDesc(jsonObject.toString());
operationLogDAO.insertSelective(log);
return result;
}
use of com.qlangtech.tis.manage.biz.dal.pojo.OperationLog in project tis by qlangtech.
the class OperationLogDAOImpl method loadFromWriteDB.
public OperationLog loadFromWriteDB(Integer opId) {
OperationLog key = new OperationLog();
key.setOpId(opId);
OperationLog record = this.loadFromWriterDB("operation_log.ibatorgenerated_selectByPrimaryKey", key);
return record;
}
use of com.qlangtech.tis.manage.biz.dal.pojo.OperationLog in project tis by qlangtech.
the class OperationLogDAOImpl method selectByPrimaryKey.
public OperationLog selectByPrimaryKey(Integer opId) {
OperationLog key = new OperationLog();
key.setOpId(opId);
OperationLog record = this.load("operation_log.ibatorgenerated_selectByPrimaryKey", key);
return record;
}
Aggregations