1、预警功能一键清空实现

pull/254/head
xjs 4 years ago
parent 0b08527e0c
commit bb4c812c17

@ -43,3 +43,12 @@ export function handleWarning(id) {
method: 'put',
})
}
// 清空预警记录信息
export function clearAll() {
return request({
url: '/warning/apiwarning/all',
method: 'delete',
})
}

@ -10,7 +10,7 @@
<div class="right-menu">
<el-badge :value="warnData.count" class=" hover-effect share-button" v-hasPermi="['warning:warning:handle']">
<el-popover v-hasPermi="['warning:warning:handle']"
<el-popover
placement="bottom"
width="220"
v-model="visible">
@ -153,7 +153,7 @@ export default {
var json = eval("(" + str + ")");
if (json.apiName !== undefined && json.warningMessage !== undefined) {
let data = json.apiName + "-" + json.warningMessage;
this.visible = true
// this.visible = true
return data
}
}

@ -39,7 +39,7 @@ export default class SocketService {
return console.log("您的浏览器不支持WebSocket");
}
//网关转发
let wsUrl = 'ws://localhost:8080/warning/warning/api';
let wsUrl = 'ws://localhost:8080/warning/webSocket/warning/api';
wsUrl += `/${store.getters.name}`
this.ws = new WebSocket(wsUrl)

@ -28,6 +28,17 @@
>导出
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-delete-solid"
size="mini"
@click="clearAll"
v-hasPermi="['warning:warning:remove']"
>清空
</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
@ -73,7 +84,7 @@
</template>
<script>
import {listApiwarning} from "@/api/business/warning/apiwarning";
import {listApiwarning,clearAll } from "@/api/business/warning/apiwarning";
export default {
name: "Warning",
@ -113,6 +124,14 @@ export default {
this.getList();
},
methods: {
//
clearAll() {
clearAll().then(res =>{
this.$modal.msgSuccess("清空"+res.data+"条");
this.getList();
})
},
/** 查询api预警列表 */
getList() {
this.loading = true;

@ -167,6 +167,16 @@ public class ApiWarningController extends BaseController {
util.exportExcel(response, list, "api预警数据");
}
@RequiresPermissions("warning:warning:remove")
@Log(title = "api预警", businessType = BusinessType.DELETE)
@DeleteMapping("all")
@ApiOperation("清空已处理api预警列表")
public R<Object> clearAll() {
Integer integer = apiWarningService.clearAll();
return integer > 0 ? R.ok(integer) : R.fail();
}
//-------------------------代码生成------------------------------------

@ -10,4 +10,11 @@ import com.xjs.domain.ApiWarning;
*/
public interface ApiWarningMapper extends BaseMapper<ApiWarning> {
/**
*
* @return Integer
*/
Integer clearAll();
}

@ -28,7 +28,7 @@ import static com.xjs.consts.RedisConst.WEBSOCKET;
* @since 2022-01-13
*/
@Log4j2
@ServerEndpoint("/warning/api/{userId}")
@ServerEndpoint("/webSocket/warning/api/{userId}")
@Component
public class WebSocketServer {
/**

@ -38,6 +38,12 @@ public interface ApiWarningService extends IService<ApiWarning> {
*/
List<ApiRecord> selectApiRecordListByUrl(ApiRecord apiRecord);
/**
*
* @return int
*/
Integer clearAll();
//---------------------代码生成---------------------------------
/**

@ -24,6 +24,8 @@ public class ApiWarningServiceImpl extends ServiceImpl<ApiWarningMapper, ApiWarn
@Resource
private ApiRecordMapper apiRecordMapper;
@Resource
private ApiWarningMapper apiWarningMapper;
@Override
public Boolean saveApiRecord(ApiRecord apiRecord) {
@ -52,6 +54,11 @@ public class ApiWarningServiceImpl extends ServiceImpl<ApiWarningMapper, ApiWarn
.eq("api_name", apiRecord.getApiName()));
}
@Override
public Integer clearAll() {
return apiWarningMapper.clearAll();
}
//------------------------代码生成-------------------------------

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xjs.mapper.ApiWarningMapper">
<delete id="clearAll">
delete
from api_warning
where handle = 1
</delete>
</mapper>
Loading…
Cancel
Save