1、api日志模块查询条件优化
This commit is contained in:
parent
9a6b2104ee
commit
075d505b80
|
|
@ -37,4 +37,7 @@ public interface RemoteWarningCRUDFeign {
|
|||
@PostMapping("apiwarning/saveApiwarningForRPC")
|
||||
R<ApiWarning> saveApiWarningForRPC(@RequestBody ApiWarning apiWarning);
|
||||
|
||||
@GetMapping("apiwarning/getApiNameForRPC")
|
||||
public R<List<String>> getApiName();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,12 @@ public class RemoteWarningCRUDFactory implements FallbackFactory<RemoteWarningCR
|
|||
log.error("调用预警服务api预警查询接口失败,执行降级处理----"+apiWarning.getApiName());
|
||||
return R.fail();
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<List<String>> getApiName() {
|
||||
log.error("调用预警服务api预警查询所有api名称接口失败,执行降级处理----");
|
||||
return R.fail();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,3 +24,11 @@ export function delLog(id) {
|
|||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
//获取所有api名称
|
||||
export function getApiName() {
|
||||
return request({
|
||||
url: '/log/apilog/getApiName' ,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,96 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="70px">
|
||||
<el-form-item label="接口名称" prop="apiName">
|
||||
<el-input
|
||||
<el-select
|
||||
v-model="queryParams.apiName"
|
||||
placeholder="请输入接口名称"
|
||||
placeholder="请输入"
|
||||
clearable
|
||||
size="small"
|
||||
style="width: 150px">
|
||||
<el-option
|
||||
v-for="index in apiName"
|
||||
:key="index"
|
||||
:label="index"
|
||||
:value="index"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="请求URL" prop="url">
|
||||
<el-input
|
||||
v-model="queryParams.url"
|
||||
placeholder="请输入请求URL"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="请求参数" prop="request">
|
||||
<el-input
|
||||
v-model="queryParams.request"
|
||||
placeholder="请输入请求参数"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="响应参数" prop="response">
|
||||
<el-input
|
||||
v-model="queryParams.response"
|
||||
placeholder="请输入响应参数"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="是否成功" prop="isSuccess">
|
||||
<el-select
|
||||
v-model="queryParams.isSuccess"
|
||||
placeholder="请输入"
|
||||
clearable
|
||||
size="small"
|
||||
style="width: 150px">
|
||||
<el-option
|
||||
v-for="dict in dict.type.request_status"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="请求方法" prop="method">
|
||||
<el-select
|
||||
v-model="queryParams.method"
|
||||
placeholder="请输入"
|
||||
clearable
|
||||
size="small"
|
||||
style="width: 150px">
|
||||
<el-option
|
||||
v-for="dict in dict.type.request_method"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
|
||||
<el-form-item label="创建时间">
|
||||
<el-date-picker
|
||||
v-model="daterangeCreateTime"
|
||||
size="small"
|
||||
style="width: 240px"
|
||||
value-format="yyyy-MM-dd"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
|
|
@ -121,10 +201,11 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import {listLog, getLog, delLog} from "@/api/business/log/apilog";
|
||||
import {listLog, getLog, delLog,getApiName} from "@/api/business/log/apilog";
|
||||
|
||||
export default {
|
||||
name: "Apilog",
|
||||
dicts: ['request_status','request_method'],
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
|
|
@ -159,16 +240,35 @@ export default {
|
|||
response: {},
|
||||
|
||||
// 表单校验
|
||||
rules: {}
|
||||
rules: {},
|
||||
|
||||
//检查查询范围
|
||||
daterangeCreateTime: [],
|
||||
|
||||
//api名称
|
||||
apiName:[],
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
this.getApiName()
|
||||
},
|
||||
methods: {
|
||||
//获取所有api名称
|
||||
getApiName() {
|
||||
getApiName().then(res =>{
|
||||
this.apiName=res.data
|
||||
})
|
||||
|
||||
},
|
||||
|
||||
/** 查询日志列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
if (null != this.daterangeCreateTime && '' != this.daterangeCreateTime) {
|
||||
this.queryParams.createTime = this.daterangeCreateTime[0];
|
||||
this.queryParams.endCreateTime = this.daterangeCreateTime[1];
|
||||
}
|
||||
listLog(this.queryParams).then(response => {
|
||||
this.logList = response.rows;
|
||||
this.total = response.total;
|
||||
|
|
@ -221,6 +321,9 @@ export default {
|
|||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.daterangeCreateTime = [];
|
||||
this.queryParams.createTime=null
|
||||
this.queryParams.endCreateTime=null
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
|
|
|
|||
|
|
@ -41,6 +41,15 @@ public class ApiLogController extends BaseController {
|
|||
}
|
||||
|
||||
|
||||
@GetMapping("getApiName")
|
||||
@ApiOperation("获取所有Api名称")
|
||||
@RequiresPermissions("log:apilog:list")
|
||||
public AjaxResult getApiName() {
|
||||
List<String> apiNameList = apiLogService.getApiName();
|
||||
return AjaxResult.success(apiNameList);
|
||||
}
|
||||
|
||||
|
||||
//------------------------代码自动生成-----------------------------------
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -5,9 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
|||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.core.annotation.Excel;
|
||||
import com.xjs.annotation.MappingField;
|
||||
import com.xjs.enums.StatusEnum;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
|
@ -54,4 +53,8 @@ public class ApiLog implements Serializable
|
|||
@Excel(name = "创建时间" ,dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date endCreateTime;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,4 +46,10 @@ public interface IApiLogService extends IService<ApiLog> {
|
|||
* @return 结果
|
||||
*/
|
||||
int deleteApiLogById(Long id);
|
||||
|
||||
/**
|
||||
* 获取所有api名称
|
||||
* @return
|
||||
*/
|
||||
List<String> getApiName();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,16 @@
|
|||
package com.xjs.apilog.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.common.core.constant.HttpStatus;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.xjs.apilog.domain.ApiLog;
|
||||
import com.xjs.apilog.mapper.ApiLogMapper;
|
||||
import com.xjs.apilog.service.IApiLogService;
|
||||
import com.xjs.business.warning.RemoteWarningCRUDFeign;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -19,6 +23,8 @@ import java.util.List;
|
|||
public class ApiLogServiceImpl extends ServiceImpl<ApiLogMapper,ApiLog> implements IApiLogService {
|
||||
@Autowired
|
||||
private ApiLogMapper apiLogMapper;
|
||||
@Autowired
|
||||
private RemoteWarningCRUDFeign remoteWarningCRUDFeign;
|
||||
|
||||
//------------------------代码自动生成-----------------------------------
|
||||
|
||||
|
|
@ -65,4 +71,13 @@ public class ApiLogServiceImpl extends ServiceImpl<ApiLogMapper,ApiLog> implemen
|
|||
public int deleteApiLogById(Long id) {
|
||||
return apiLogMapper.deleteApiLogById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getApiName() {
|
||||
R<List<String>> apiName = remoteWarningCRUDFeign.getApiName();
|
||||
if (apiName.getCode() == HttpStatus.SUCCESS) {
|
||||
return apiName.getData();
|
||||
}
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<include refid="selectApiLogVo"/>
|
||||
<where>
|
||||
<if test="apiName != null and apiName != ''"> and api_name like concat('%', #{apiName}, '%')</if>
|
||||
<if test="url != null and url != ''"> and url like concat('%', #{url}, '%')</if>
|
||||
<if test="method != null and method != ''"> and method like concat('%', #{method}, '%')</if>
|
||||
<if test="request != null and request != ''"> and request like concat('%', #{request}, '%')</if>
|
||||
<if test="response != null and response != ''"> and response like concat('%', #{response}, '%')</if>
|
||||
<if test="isSuccess != null "> and is_success = #{isSuccess}</if>
|
||||
<if test="createTime != null and endCreateTime != null"> and create_time between #{createTime} and #{endCreateTime}</if>
|
||||
</where>
|
||||
order by id desc
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -81,6 +81,17 @@ public class ApiWarningController extends BaseController {
|
|||
return R.ok(apiRecords);
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程获取所有Api名称
|
||||
* @return api名称
|
||||
*/
|
||||
@GetMapping("getApiNameForRPC")
|
||||
@ApiOperation("远程获取所有Api名称")
|
||||
public R<List<String>> getApiName() {
|
||||
List<String> apiNameList = apiWarningService.getApiName();
|
||||
return R.ok(apiNameList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理预警单个预警
|
||||
* @param id 预警id
|
||||
|
|
|
|||
|
|
@ -76,4 +76,10 @@ public interface ApiWarningService extends IService<ApiWarning> {
|
|||
* @return 结果
|
||||
*/
|
||||
public int updateApiRecord(ApiRecord apiRecord);
|
||||
|
||||
/**
|
||||
* 获取所有api名称
|
||||
* @return List<String>
|
||||
*/
|
||||
List<String> getApiName();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import org.springframework.stereotype.Service;
|
|||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author xiejs
|
||||
|
|
@ -100,5 +101,13 @@ public class ApiWarningServiceImpl extends ServiceImpl<ApiWarningMapper, ApiWarn
|
|||
return apiRecordMapper.updateApiRecord(apiRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getApiName() {
|
||||
List<ApiRecord> recordList = apiRecordMapper.selectList(new QueryWrapper<ApiRecord>().orderByDesc("create_time"));
|
||||
return recordList.stream()
|
||||
.map(ApiRecord::getApiName)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue