修复兼容性问题
This commit is contained in:
1 parent
8635a512b8
commit
0a16b23895
7 files changed
+70
-24
No files matched your search
+2
-2
@@ -50,9 +50,9 @@ buildNumber.properties
|
||||
.settings
|
||||
bin/
|
||||
logs/
|
||||
db/
|
||||
crabc-web/
|
||||
.classpathc
|
||||
|
||||
开发计划.md
|
||||
|
||||
####################### idea ##############################
|
||||
.idea
|
||||
|
||||
-1
@@ -32,7 +32,6 @@ public class BaseDataServiceImpl implements IBaseDataService {
|
||||
|
||||
@Override
|
||||
public PreviewVO sqlPreview(String datasourceId,String datasourceType, String schema, String sql) {
|
||||
StatementMapper statementMapper = dataSourceManager.getStatementMapper(datasourceId);
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
// 数据源类型
|
||||
if (datasourceType != null) {
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ public class IBaseApiLogServiceImpl implements IBaseApiLogService {
|
||||
|
||||
@Override
|
||||
public PageInfo page(ApiLogParam param) {
|
||||
PageHelper.startPage(param.getPageNum(), param.getPageSize());
|
||||
PageHelper.startPage(param.getPageNum(), param.getPageSize(), false);
|
||||
List<BaseApiLog> list = baseApiLogMapper.selectList(param);
|
||||
return new PageInfo<>(list, param.getPageNum(), param.getPageSize());
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ public class ApiThreadLocal {
|
||||
* 清除
|
||||
*/
|
||||
public static void remove(){
|
||||
log.info("<-- 清除上下文API信息");
|
||||
apiInfo.remove();
|
||||
}
|
||||
}
|
||||
@@ -198,7 +198,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
b.version
|
||||
FROM
|
||||
base_api_info b
|
||||
left join base_sys_user u on b.create_by = u.user_id
|
||||
left join base_sys_user u on b.create_by = CAST(u.user_id AS VARCHAR)
|
||||
WHERE
|
||||
b.api_id =#{apiId}
|
||||
</select>
|
||||
|
||||
@@ -36,8 +36,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and app_name like concat('%',#{appName},'%')
|
||||
</if>
|
||||
<if test="startTime !=null and startTime !='' and endTime !=null and endTime !=''">
|
||||
and request_time >=#{startTime}
|
||||
and request_time <=#{endTime}
|
||||
and request_time >=CAST(#{startTime} AS TIMESTAMP)
|
||||
and request_time <=CAST(#{endTime} AS TIMESTAMP)
|
||||
</if>
|
||||
</where>
|
||||
order by log_id desc
|
||||
@@ -113,8 +113,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and app_name like concat('%',#{appName},'%')
|
||||
</if>
|
||||
<if test="startTime !=null and startTime !='' and endTime !=null and endTime !=''">
|
||||
and request_time >=#{startTime}
|
||||
and request_time <=#{endTime}
|
||||
and request_time >=CAST(#{startTime} AS TIMESTAMP)
|
||||
and request_time <=CAST(#{endTime} AS TIMESTAMP)
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
@@ -124,20 +124,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
count(1) AS totalCount,
|
||||
sum(case when request_status = 'success' then 1 else 0 end) AS successCount,
|
||||
sum(case when request_status = 'fail' then 1 else 0 end) AS failCount,
|
||||
avg(ifnull(cost_time, 0)) AS avgCostTime,
|
||||
max(ifnull(cost_time, 0)) AS maxCostTime
|
||||
avg(COALESCE(cost_time, 0)) AS avgCostTime,
|
||||
max(COALESCE(cost_time, 0)) AS maxCostTime
|
||||
FROM
|
||||
base_api_log
|
||||
<include refid="statisticsWhere" />
|
||||
</select>
|
||||
|
||||
<select id="selectDailyTrend" resultType="cn.crabc.core.app.entity.vo.ApiLogDailyTrendVO">
|
||||
<select id="selectDailyTrend" resultType="cn.crabc.core.app.entity.vo.ApiLogDailyTrendVO" databaseId="mysql">
|
||||
SELECT
|
||||
DATE_FORMAT(request_time,'%Y-%m-%d') AS statisticDate,
|
||||
count(1) AS totalCount,
|
||||
sum(case when request_status = 'success' then 1 else 0 end) AS successCount,
|
||||
sum(case when request_status = 'fail' then 1 else 0 end) AS failCount,
|
||||
avg(ifnull(cost_time, 0)) AS avgCostTime
|
||||
avg(COALESCE(cost_time, 0)) AS avgCostTime
|
||||
FROM
|
||||
base_api_log
|
||||
<include refid="statisticsWhere" />
|
||||
@@ -145,19 +145,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
ORDER BY statisticDate ASC
|
||||
</select>
|
||||
|
||||
<select id="selectDailyTrend" resultType="cn.crabc.core.app.entity.vo.ApiLogDailyTrendVO" databaseId="postgresql">
|
||||
SELECT
|
||||
TO_CHAR(request_time,'YYYY-MM-DD') AS statisticDate,
|
||||
count(1) AS totalCount,
|
||||
sum(case when request_status = 'success' then 1 else 0 end) AS successCount,
|
||||
sum(case when request_status = 'fail' then 1 else 0 end) AS failCount,
|
||||
avg(COALESCE(cost_time, 0)) AS avgCostTime
|
||||
FROM
|
||||
base_api_log
|
||||
<include refid="statisticsWhere" />
|
||||
GROUP BY TO_CHAR(request_time,'YYYY-MM-DD')
|
||||
ORDER BY statisticDate ASC
|
||||
</select>
|
||||
|
||||
<select id="selectStatusStats" resultType="cn.crabc.core.app.entity.vo.ApiLogGroupCountVO">
|
||||
SELECT
|
||||
ifnull(request_status, 'unknown') AS groupKey,
|
||||
ifnull(request_status, 'unknown') AS groupName,
|
||||
COALESCE(request_status, 'unknown') AS groupKey,
|
||||
COALESCE(request_status, 'unknown') AS groupName,
|
||||
count(1) AS count
|
||||
FROM
|
||||
base_api_log
|
||||
<include refid="statisticsWhere" />
|
||||
GROUP BY ifnull(request_status, 'unknown')
|
||||
GROUP BY COALESCE(request_status, 'unknown')
|
||||
ORDER BY count DESC
|
||||
</select>
|
||||
|
||||
<select id="selectTopApis" resultType="cn.crabc.core.app.entity.vo.ApiLogGroupCountVO">
|
||||
<select id="selectTopApis" resultType="cn.crabc.core.app.entity.vo.ApiLogGroupCountVO" databaseId="mysql">
|
||||
SELECT
|
||||
ifnull(cast(api_id as char), api_path) AS groupKey,
|
||||
ifnull(api_name, api_path) AS groupName,
|
||||
@@ -171,7 +185,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
LIMIT 10
|
||||
</select>
|
||||
|
||||
<select id="selectTopCostApis" resultType="cn.crabc.core.app.entity.vo.ApiLogGroupCountVO">
|
||||
<select id="selectTopApis" resultType="cn.crabc.core.app.entity.vo.ApiLogGroupCountVO" databaseId="postgresql">
|
||||
SELECT
|
||||
COALESCE(CAST(api_id AS VARCHAR), api_path) AS groupKey,
|
||||
COALESCE(api_name, api_path) AS groupName,
|
||||
api_path AS apiPath,
|
||||
count(1) AS count
|
||||
FROM
|
||||
base_api_log
|
||||
<include refid="statisticsWhere" />
|
||||
GROUP BY api_id, api_name, api_path
|
||||
ORDER BY count DESC
|
||||
LIMIT 10
|
||||
</select>
|
||||
|
||||
<select id="selectTopCostApis" resultType="cn.crabc.core.app.entity.vo.ApiLogGroupCountVO" databaseId="mysql">
|
||||
SELECT
|
||||
ifnull(cast(api_id as char), api_path) AS groupKey,
|
||||
ifnull(api_name, api_path) AS groupName,
|
||||
@@ -187,16 +215,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
LIMIT 10
|
||||
</select>
|
||||
|
||||
<select id="selectTopCostApis" resultType="cn.crabc.core.app.entity.vo.ApiLogGroupCountVO" databaseId="postgresql">
|
||||
SELECT
|
||||
COALESCE(CAST(api_id AS VARCHAR), api_path) AS groupKey,
|
||||
COALESCE(api_name, api_path) AS groupName,
|
||||
api_path AS apiPath,
|
||||
count(1) AS count,
|
||||
avg(COALESCE(cost_time, 0)) AS avgCostTime,
|
||||
max(COALESCE(cost_time, 0)) AS maxCostTime
|
||||
FROM
|
||||
base_api_log
|
||||
<include refid="statisticsWhere" />
|
||||
GROUP BY api_id, api_name, api_path
|
||||
ORDER BY avgCostTime DESC, maxCostTime DESC, count DESC
|
||||
LIMIT 10
|
||||
</select>
|
||||
|
||||
<!-- IP访问量Top10,按request_ip分组统计调用量 -->
|
||||
<select id="selectTopIps" resultType="cn.crabc.core.app.entity.vo.ApiLogGroupCountVO">
|
||||
SELECT
|
||||
ifnull(request_ip, 'unknown') AS groupKey,
|
||||
ifnull(request_ip, 'unknown') AS groupName,
|
||||
COALESCE(request_ip, 'unknown') AS groupKey,
|
||||
COALESCE(request_ip, 'unknown') AS groupName,
|
||||
count(1) AS count
|
||||
FROM
|
||||
base_api_log
|
||||
<include refid="statisticsWhere" />
|
||||
GROUP BY ifnull(request_ip, 'unknown')
|
||||
GROUP BY COALESCE(request_ip, 'unknown')
|
||||
ORDER BY count DESC
|
||||
LIMIT 10
|
||||
</select>
|
||||
|
||||
+6
-2
@@ -46,7 +46,7 @@ public class JdbcStatement implements StatementMapper<Map<String, Object>> {
|
||||
private static final Logger log = LoggerFactory.getLogger(JdbcStatement.class);
|
||||
private static final String[] SCRIPT_TAGS = {"</if>","</foreach>","</where>","</set>","</choose>","</when>","</trim>","</otherwise"};
|
||||
private final BaseDataHandleMapper baseMapper;
|
||||
private static final int PAGE_SIZE = 100;
|
||||
private static final int PAGE_SIZE = 1000;
|
||||
private static final int PAGE_NUM = 1;
|
||||
private final Configuration myBatisConfiguration = new Configuration();
|
||||
|
||||
@@ -78,7 +78,11 @@ public class JdbcStatement implements StatementMapper<Map<String, Object>> {
|
||||
Object pageSetup = paramsMap.get(BaseConstant.PAGE_SETUP);
|
||||
int pageCount = pageSetup != null ? Integer.parseInt(pageSetup.toString()) : 0;
|
||||
|
||||
if (pageCount != 0 && !checkPage(sql)) {
|
||||
// 页面预览结果不需要查询总数
|
||||
if ("preview".equals(execType)) {
|
||||
PageHelper.startPage(pageNum, pageSize, false);
|
||||
pageHelperStarted = true;
|
||||
}else if (pageCount != 0 && !checkPage(sql)) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
pageHelperStarted = true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user