...
|
...
|
@@ -3,8 +3,11 @@ package com.monitor.other.sqlOperate.service.impl; |
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.model.SqlOperateLogs;
|
|
|
import com.monitor.model.domain.PageBean;
|
|
|
import com.monitor.model.domain.SqlOperateModel;
|
|
|
import com.monitor.model.request.SqlOpLogsReq;
|
|
|
import com.monitor.model.response.BaseResponse;
|
|
|
import com.monitor.model.response.PageResponse;
|
|
|
import com.monitor.mysql.mapper.SqlOperateLogsMapper;
|
|
|
import com.monitor.other.sqlOperate.service.SqlOperateService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
...
|
...
|
@@ -12,6 +15,7 @@ import org.slf4j.Logger; |
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.sql.*;
|
|
|
import java.util.ArrayList;
|
...
|
...
|
@@ -490,6 +494,39 @@ public class SqlOperateServiceImpl implements SqlOperateService { |
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 分页查询sql操作日志
|
|
|
* @param request
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public BaseResponse<PageResponse<SqlOperateModel>> queryLogsByPage(SqlOpLogsReq request) {
|
|
|
try{
|
|
|
PageBean page = PageBean.initPageInfo(request.getCurrentPage(), request.getPageSize(), request);
|
|
|
// 先查询符合条件的总数量
|
|
|
int total = sqlOperateLogsMapper.selectCount(page);
|
|
|
// 数量为0 直接返回
|
|
|
if (total == 0) {
|
|
|
return new BaseResponse<>();
|
|
|
}
|
|
|
// 获取列表
|
|
|
List<SqlOperateModel> sqlOperateModels = sqlOperateLogsMapper.selectPageByParams(page);
|
|
|
if (CollectionUtils.isEmpty(sqlOperateModels)) {
|
|
|
return new BaseResponse<>();
|
|
|
}
|
|
|
PageResponse<SqlOperateModel> pageResp = new PageResponse<>();
|
|
|
pageResp.setCurrentPage(request.getCurrentPage());
|
|
|
pageResp.setPageSize(request.getPageSize());
|
|
|
pageResp.setTotal(total);
|
|
|
pageResp.setRows(sqlOperateModels);
|
|
|
return new BaseResponse<>(pageResp);
|
|
|
}catch(Exception e){
|
|
|
log.error("queryLogsByPage error", e);
|
|
|
return new BaseResponse<>(e.getMessage());
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* public static void main(String[] args){
|
...
|
...
|
|