说明:1、实现api预警前端页面
This commit is contained in:
parent
093ca22344
commit
1ae208b8e1
|
|
@ -1,7 +1,7 @@
|
||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
|
|
||||||
// 查询API预警列表
|
// 查询API预警信息列表
|
||||||
export function listApiwarning(query) {
|
export function listApiwarningInfo(query) {
|
||||||
return request({
|
return request({
|
||||||
url: '/warning/apiwarning/list',
|
url: '/warning/apiwarning/list',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
|
|
@ -9,16 +9,16 @@ export function listApiwarning(query) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询API预警详细
|
// 查询API预警详细信息
|
||||||
export function getApiwarning(id) {
|
export function getApiwarningInfo(id) {
|
||||||
return request({
|
return request({
|
||||||
url: '/warning/apiwarning/' + id,
|
url: '/warning/apiwarning/' + id,
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改API预警
|
// 修改API预警信息
|
||||||
export function updateApiwarning(data) {
|
export function updateApiwarningInfo(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/warning/apiwarning/edit',
|
url: '/warning/apiwarning/edit',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
|
|
@ -26,3 +26,12 @@ export function updateApiwarning(data) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 查询API预警列表
|
||||||
|
export function listApiwarning(query) {
|
||||||
|
return request({
|
||||||
|
url: '/warning/apiwarning/apiwarnlist',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,18 +17,6 @@
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<el-row :gutter="10" class="mb8">
|
<el-row :gutter="10" class="mb8">
|
||||||
<el-col :span="1.5">
|
|
||||||
<el-button
|
|
||||||
type="success"
|
|
||||||
plain
|
|
||||||
icon="el-icon-edit"
|
|
||||||
size="mini"
|
|
||||||
:disabled="single"
|
|
||||||
@click="handleUpdate"
|
|
||||||
v-hasPermi="['warning:apiwarning:edit']"
|
|
||||||
>修改
|
|
||||||
</el-button>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button
|
||||||
type="warning"
|
type="warning"
|
||||||
|
|
@ -36,40 +24,38 @@
|
||||||
icon="el-icon-download"
|
icon="el-icon-download"
|
||||||
size="mini"
|
size="mini"
|
||||||
@click="handleExport"
|
@click="handleExport"
|
||||||
v-hasPermi="['warning:apiwarning:export']"
|
v-hasPermi="['warning:warning:export']"
|
||||||
>导出
|
>导出
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-table v-loading="loading" :data="apiwarningList" @selection-change="handleSelectionChange">
|
<el-table v-loading="loading" :data="warningList" @selection-change="handleSelectionChange">
|
||||||
<el-table-column type="selection" width="55" align="center"/>
|
<el-table-column type="selection" width="55" align="center"/>
|
||||||
<el-table-column label="API名称" align="center" prop="apiName" :show-overflow-tooltip="true"/>
|
<el-table-column label="api名称" align="center" prop="apiName" width="200px"/>
|
||||||
<el-table-column label="API地址" align="center" prop="apiUrl" :show-overflow-tooltip="true"/>
|
<el-table-column label="预警类型" align="center" prop="warningType" width="100px"/>
|
||||||
<el-table-column label="API总请求次数" align="center" prop="totalCount" :show-overflow-tooltip="true"/>
|
<el-table-column label="预警等级" align="center" prop="warningLevel" width="130px">
|
||||||
<el-table-column label="请求耗费时间" align="center" prop="requestTime" :show-overflow-tooltip="true">
|
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<span>{{scope.row.requestTime+"ms"}}</span>
|
<el-tag type="info" v-if="scope.row.warningLevel==='普通'">
|
||||||
|
{{ scope.row.warningLevel }}
|
||||||
|
</el-tag>
|
||||||
|
<el-tag type="warning" v-if="scope.row.warningLevel==='警告'">
|
||||||
|
{{ scope.row.warningLevel }}
|
||||||
|
</el-tag>
|
||||||
|
<el-tag type="danger" v-if="scope.row.warningLevel==='严重'">
|
||||||
|
{{ scope.row.warningLevel }}
|
||||||
|
</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="API每天限制请求次数" align="center" prop="limitCount" :show-overflow-tooltip="true"/>
|
<el-table-column label="预警记录信息" align="center" prop="warningMessage" :show-overflow-tooltip="true"/>
|
||||||
|
<el-table-column label="限定值" align="center" prop="limitValue" width="100px"/>
|
||||||
<el-table-column label="API每天请求次数" align="center" prop="dayCount"/>
|
<el-table-column label="实际值" align="center" prop="realValue" width="100px"/>
|
||||||
<el-table-column label="调用时间" align="center" prop="updateTime" width="180"/>
|
<el-table-column label="是否处理" align="center" prop="handle" width="100px">
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180" :show-overflow-tooltip="true">
|
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
|
<el-tag :type="scope.row.handle==='1'?'success':'danger'" size="small">
|
||||||
</template>
|
{{ scope.row.handle === 1 ? '是' : '否' }}
|
||||||
</el-table-column>
|
</el-tag>
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<el-button circle
|
|
||||||
type="primary"
|
|
||||||
icon="el-icon-edit"
|
|
||||||
@click="handleUpdate(scope.row)"
|
|
||||||
v-hasPermi="['warning:apiwarning:edit']"
|
|
||||||
></el-button>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
@ -82,26 +68,14 @@
|
||||||
@pagination="getList"
|
@pagination="getList"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 添加或修改API预警对话框 -->
|
|
||||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
|
||||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
|
||||||
<el-form-item label="请求次数" prop="limitCount">
|
|
||||||
<el-input v-model="form.limitCount" placeholder="请输入api限制请求次数每天"/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<div slot="footer" class="dialog-footer">
|
|
||||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
|
||||||
<el-button @click="cancel">取 消</el-button>
|
|
||||||
</div>
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {listApiwarning, getApiwarning, updateApiwarning} from "@/api/business/warning/apiwarning";
|
import {listApiwarning} from "@/api/business/warning/apiwarning";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Apiwarning",
|
name: "Warning",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 遮罩层
|
// 遮罩层
|
||||||
|
|
@ -116,8 +90,8 @@ export default {
|
||||||
showSearch: true,
|
showSearch: true,
|
||||||
// 总条数
|
// 总条数
|
||||||
total: 0,
|
total: 0,
|
||||||
// API预警表格数据
|
// api预警表格数据
|
||||||
apiwarningList: [],
|
warningList: [],
|
||||||
// 弹出层标题
|
// 弹出层标题
|
||||||
title: "",
|
title: "",
|
||||||
// 是否显示弹出层
|
// 是否显示弹出层
|
||||||
|
|
@ -138,11 +112,11 @@ export default {
|
||||||
this.getList();
|
this.getList();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/** 查询API预警列表 */
|
/** 查询api预警列表 */
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
listApiwarning(this.queryParams).then(response => {
|
listApiwarning(this.queryParams).then(response => {
|
||||||
this.apiwarningList = response.rows;
|
this.warningList = response.rows;
|
||||||
this.total = response.total;
|
this.total = response.total;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
});
|
});
|
||||||
|
|
@ -157,13 +131,13 @@ export default {
|
||||||
this.form = {
|
this.form = {
|
||||||
id: null,
|
id: null,
|
||||||
apiName: null,
|
apiName: null,
|
||||||
apiUrl: null,
|
warningType: null,
|
||||||
totalCount: null,
|
warningLevel: null,
|
||||||
requestTime: null,
|
warningMessage: null,
|
||||||
limitCount: null,
|
limitValue: null,
|
||||||
createTime: null,
|
realValue: null,
|
||||||
dayCount: null,
|
handle: null,
|
||||||
updateTime: null
|
createTime: null
|
||||||
};
|
};
|
||||||
this.resetForm("form");
|
this.resetForm("form");
|
||||||
},
|
},
|
||||||
|
|
@ -183,36 +157,13 @@ export default {
|
||||||
this.single = selection.length !== 1
|
this.single = selection.length !== 1
|
||||||
this.multiple = !selection.length
|
this.multiple = !selection.length
|
||||||
},
|
},
|
||||||
/** 修改按钮操作 */
|
|
||||||
handleUpdate(row) {
|
|
||||||
this.reset();
|
|
||||||
const id = row.id || this.ids
|
|
||||||
getApiwarning(id).then(response => {
|
|
||||||
this.form = response.data;
|
|
||||||
this.open = true;
|
|
||||||
this.title = "修改API预警";
|
|
||||||
});
|
|
||||||
},
|
|
||||||
/** 提交按钮 */
|
|
||||||
submitForm() {
|
|
||||||
this.$refs["form"].validate(valid => {
|
|
||||||
if (valid) {
|
|
||||||
if (this.form.id != null) {
|
|
||||||
updateApiwarning(this.form).then(response => {
|
|
||||||
this.$modal.msgSuccess("修改成功");
|
|
||||||
this.open = false;
|
|
||||||
this.getList();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
/** 导出按钮操作 */
|
/** 导出按钮操作 */
|
||||||
handleExport() {
|
handleExport() {
|
||||||
this.download('warning/apiwarning/export', {
|
this.download('warning/apiwarning/apiwarnexport', {
|
||||||
...this.queryParams
|
...this.queryParams
|
||||||
}, `apiwarning_${new Date().getTime()}.xlsx`)
|
}, `warning_${new Date().getTime()}.xlsx`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,219 @@
|
||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
|
<el-form-item label="api名称" prop="apiName">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.apiName"
|
||||||
|
placeholder="请输入api名称"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</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>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
plain
|
||||||
|
icon="el-icon-edit"
|
||||||
|
size="mini"
|
||||||
|
:disabled="single"
|
||||||
|
@click="handleUpdate"
|
||||||
|
v-hasPermi="['warning:apiwarning:edit']"
|
||||||
|
>修改
|
||||||
|
</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="warning"
|
||||||
|
plain
|
||||||
|
icon="el-icon-download"
|
||||||
|
size="mini"
|
||||||
|
@click="handleExport"
|
||||||
|
v-hasPermi="['warning:apiwarning:export']"
|
||||||
|
>导出
|
||||||
|
</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" :data="apiwarningList" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="55" align="center"/>
|
||||||
|
<el-table-column label="API名称" align="center" prop="apiName" :show-overflow-tooltip="true"/>
|
||||||
|
<el-table-column label="API地址" align="center" prop="apiUrl" :show-overflow-tooltip="true"/>
|
||||||
|
<el-table-column label="API总请求次数" align="center" prop="totalCount" :show-overflow-tooltip="true"/>
|
||||||
|
<el-table-column label="请求耗费时间" align="center" prop="requestTime" :show-overflow-tooltip="true">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{scope.row.requestTime+"ms"}}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="API每天限制请求次数" align="center" prop="limitCount" :show-overflow-tooltip="true"/>
|
||||||
|
|
||||||
|
<el-table-column label="API每天请求次数" align="center" prop="dayCount"/>
|
||||||
|
<el-table-column label="调用时间" align="center" prop="updateTime" width="180"/>
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" width="180" :show-overflow-tooltip="true">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button circle
|
||||||
|
type="primary"
|
||||||
|
icon="el-icon-edit"
|
||||||
|
@click="handleUpdate(scope.row)"
|
||||||
|
v-hasPermi="['warning:apiwarning:edit']"
|
||||||
|
></el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<pagination
|
||||||
|
v-show="total>0"
|
||||||
|
:total="total"
|
||||||
|
:page.sync="queryParams.pageNum"
|
||||||
|
:limit.sync="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- 添加或修改API预警对话框 -->
|
||||||
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||||
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||||
|
<el-form-item label="请求次数" prop="limitCount">
|
||||||
|
<el-input v-model="form.limitCount" placeholder="请输入api限制请求次数每天"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getApiwarningInfo, updateApiwarningInfo,listApiwarningInfo} from "@/api/business/warning/apiwarning";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "Apiwarning",
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 选中数组
|
||||||
|
ids: [],
|
||||||
|
// 非单个禁用
|
||||||
|
single: true,
|
||||||
|
// 非多个禁用
|
||||||
|
multiple: true,
|
||||||
|
// 显示搜索条件
|
||||||
|
showSearch: true,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// API预警表格数据
|
||||||
|
apiwarningList: [],
|
||||||
|
// 弹出层标题
|
||||||
|
title: "",
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
apiName: null,
|
||||||
|
},
|
||||||
|
// 表单参数
|
||||||
|
form: {},
|
||||||
|
// 表单校验
|
||||||
|
rules: {}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 查询API预警列表 */
|
||||||
|
getList() {
|
||||||
|
this.loading = true;
|
||||||
|
listApiwarningInfo(this.queryParams).then(response => {
|
||||||
|
this.apiwarningList = response.rows;
|
||||||
|
this.total = response.total;
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 取消按钮
|
||||||
|
cancel() {
|
||||||
|
this.open = false;
|
||||||
|
this.reset();
|
||||||
|
},
|
||||||
|
// 表单重置
|
||||||
|
reset() {
|
||||||
|
this.form = {
|
||||||
|
id: null,
|
||||||
|
apiName: null,
|
||||||
|
apiUrl: null,
|
||||||
|
totalCount: null,
|
||||||
|
requestTime: null,
|
||||||
|
limitCount: null,
|
||||||
|
createTime: null,
|
||||||
|
dayCount: null,
|
||||||
|
updateTime: null
|
||||||
|
};
|
||||||
|
this.resetForm("form");
|
||||||
|
},
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.pageNum = 1;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.resetForm("queryForm");
|
||||||
|
this.handleQuery();
|
||||||
|
},
|
||||||
|
// 多选框选中数据
|
||||||
|
handleSelectionChange(selection) {
|
||||||
|
this.ids = selection.map(item => item.id)
|
||||||
|
this.single = selection.length !== 1
|
||||||
|
this.multiple = !selection.length
|
||||||
|
},
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
handleUpdate(row) {
|
||||||
|
this.reset();
|
||||||
|
const id = row.id || this.ids
|
||||||
|
getApiwarningInfo(id).then(response => {
|
||||||
|
this.form = response.data;
|
||||||
|
this.open = true;
|
||||||
|
this.title = "修改API预警";
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 提交按钮 */
|
||||||
|
submitForm() {
|
||||||
|
this.$refs["form"].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
if (this.form.id != null) {
|
||||||
|
updateApiwarningInfo(this.form).then(response => {
|
||||||
|
this.$modal.msgSuccess("修改成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
handleExport() {
|
||||||
|
this.download('warning/apiwarning/export', {
|
||||||
|
...this.queryParams
|
||||||
|
}, `apiwarning_${new Date().getTime()}.xlsx`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
@ -11,7 +11,10 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
public enum StatusEnum {
|
public enum StatusEnum {
|
||||||
|
|
||||||
SUCCESS(1,"成功"),
|
SUCCESS(1,"成功"),
|
||||||
ERROR(2,"失败");
|
ERROR(2,"失败"),
|
||||||
|
|
||||||
|
YES(1,"是"),
|
||||||
|
NO(2,"否");
|
||||||
|
|
||||||
|
|
||||||
private String desc;
|
private String desc;
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,8 @@ public class ApiLogAspect {
|
||||||
apiWarning.setApiName(haveApiRecord.getApiName());
|
apiWarning.setApiName(haveApiRecord.getApiName());
|
||||||
apiWarning.setHandle(NO);
|
apiWarning.setHandle(NO);
|
||||||
apiWarning.setWarningLevel(WarnLevelEnum.NOEMAL.getMessage());
|
apiWarning.setWarningLevel(WarnLevelEnum.NOEMAL.getMessage());
|
||||||
if(haveApiRecord.getDayCount()>haveApiRecord.getLimitCount()*2){
|
if(haveApiRecord.getDayCount()>haveApiRecord.getLimitCount()*2 &&
|
||||||
|
haveApiRecord.getDayCount() < haveApiRecord.getLimitCount() * 3){
|
||||||
apiWarning.setWarningLevel(WarnLevelEnum.WARNING.getMessage());
|
apiWarning.setWarningLevel(WarnLevelEnum.WARNING.getMessage());
|
||||||
} else if (haveApiRecord.getDayCount() > haveApiRecord.getLimitCount() * 3) {
|
} else if (haveApiRecord.getDayCount() > haveApiRecord.getLimitCount() * 3) {
|
||||||
apiWarning.setWarningLevel(WarnLevelEnum.DANGER.getMessage());
|
apiWarning.setWarningLevel(WarnLevelEnum.DANGER.getMessage());
|
||||||
|
|
@ -188,6 +189,8 @@ public class ApiLogAspect {
|
||||||
haveApiRecord.getLimitCount(), haveApiRecord.getDayCount());
|
haveApiRecord.getLimitCount(), haveApiRecord.getDayCount());
|
||||||
apiWarning.setWarningMessage(message);
|
apiWarning.setWarningMessage(message);
|
||||||
remoteWarningCRUDFeign.saveApiWarningForRPC(apiWarning);
|
remoteWarningCRUDFeign.saveApiWarningForRPC(apiWarning);
|
||||||
|
|
||||||
|
// todo websocket实现即时推送到客户端
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@
|
||||||
api_copywriting
|
api_copywriting
|
||||||
WHERE
|
WHERE
|
||||||
content IN ( SELECT t.content FROM ( SELECT content FROM api_copywriting GROUP BY content HAVING count( content ) > 1 ) t )
|
content IN ( SELECT t.content FROM ( SELECT content FROM api_copywriting GROUP BY content HAVING count( content ) > 1 ) t )
|
||||||
AND id NOT IN ( SELECT c.id FROM ( SELECT max( id ) id FROM api_copywriting GROUP BY content HAVING count( content )> 1 ) c )
|
AND id NOT IN ( SELECT c.id FROM ( SELECT min( id ) id FROM api_copywriting GROUP BY content HAVING count( content )> 1 ) c )
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,18 @@ package com.xjs.oneenglish.factory;
|
||||||
|
|
||||||
import com.xjs.XjsOpenApiApp;
|
import com.xjs.XjsOpenApiApp;
|
||||||
import com.xjs.config.TianXingProperties;
|
import com.xjs.config.TianXingProperties;
|
||||||
|
import com.xjs.copywriting.domain.CopyWriting;
|
||||||
|
import com.xjs.copywriting.mapper.CopyWritingMapper;
|
||||||
|
import com.xjs.copywriting.service.CopyWritingService;
|
||||||
import com.xjs.oneenglish.domain.ApiEnglish;
|
import com.xjs.oneenglish.domain.ApiEnglish;
|
||||||
import com.xjs.oneenglish.domain.RequestBody;
|
import com.xjs.oneenglish.domain.RequestBody;
|
||||||
|
import org.apache.ibatis.session.ExecutorType;
|
||||||
|
import org.apache.ibatis.session.SqlSession;
|
||||||
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xiejs
|
* @author xiejs
|
||||||
* @desc
|
* @desc
|
||||||
|
|
@ -24,6 +28,11 @@ class TianXingOneEnglishFactoryTest {
|
||||||
@Autowired
|
@Autowired
|
||||||
TianXingProperties tianXingProperties;
|
TianXingProperties tianXingProperties;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CopyWritingService copyWritingService;
|
||||||
|
@Autowired
|
||||||
|
private SqlSessionFactory sqlSessionFactory;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getOneEnglish() {
|
void getOneEnglish() {
|
||||||
RequestBody requestBody = new RequestBody();
|
RequestBody requestBody = new RequestBody();
|
||||||
|
|
@ -31,4 +40,46 @@ class TianXingOneEnglishFactoryTest {
|
||||||
ApiEnglish oneEnglish = tianXingOneEnglishFactory.getOneEnglish(requestBody);
|
ApiEnglish oneEnglish = tianXingOneEnglishFactory.getOneEnglish(requestBody);
|
||||||
System.out.println(oneEnglish);
|
System.out.println(oneEnglish);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void insert() {
|
||||||
|
/*CopyWriting copyWriting = new CopyWriting();
|
||||||
|
copyWriting.setSource("xx");
|
||||||
|
copyWriting.setContent("既然看不到早上的夕阳,那就追求傍晚到日落。");
|
||||||
|
copyWriting.setType(1);
|
||||||
|
for (int i = 0; i < 100000; i++) {
|
||||||
|
copyWritingService.save(copyWriting);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/*ArrayList<CopyWriting> copyWritings = new ArrayList<>();
|
||||||
|
for (int i = 0; i < 100000; i++) {
|
||||||
|
CopyWriting copyWriting = new CopyWriting();
|
||||||
|
copyWriting.setSource("xx");
|
||||||
|
copyWriting.setContent("既然看不到早上的夕阳,那就追求傍晚到日落。");
|
||||||
|
copyWriting.setType(1);
|
||||||
|
copyWritings.add(copyWriting);
|
||||||
|
}
|
||||||
|
copyWritingService.saveBatch(copyWritings,30000);*/
|
||||||
|
SqlSession sqlSession=null;
|
||||||
|
try {
|
||||||
|
sqlSession= sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||||
|
|
||||||
|
CopyWritingMapper mapper = sqlSession.getMapper(CopyWritingMapper.class);
|
||||||
|
|
||||||
|
CopyWriting copyWriting = new CopyWriting();
|
||||||
|
copyWriting.setSource("xx");
|
||||||
|
copyWriting.setContent("既然看不到早上的夕阳,那就追求傍晚到日落。");
|
||||||
|
copyWriting.setType(1);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100000; i++) {
|
||||||
|
mapper.insert(copyWriting);
|
||||||
|
}
|
||||||
|
|
||||||
|
sqlSession.commit();
|
||||||
|
} finally {
|
||||||
|
sqlSession.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.xjs.controller;
|
package com.xjs.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
|
|
@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xiejs
|
* @author xiejs
|
||||||
|
|
@ -30,7 +32,7 @@ public class ApiWarningController extends BaseController {
|
||||||
private ApiWarningService apiWarningService;
|
private ApiWarningService apiWarningService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存 apiRecord
|
* 远程保存 apiRecord
|
||||||
*
|
*
|
||||||
* @param apiRecord api记录
|
* @param apiRecord api记录
|
||||||
* @return apiRecord
|
* @return apiRecord
|
||||||
|
|
@ -41,7 +43,7 @@ public class ApiWarningController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改
|
* 远程修改
|
||||||
*
|
*
|
||||||
* @param apiRecord api记录
|
* @param apiRecord api记录
|
||||||
* @return ApiRecord
|
* @return ApiRecord
|
||||||
|
|
@ -53,8 +55,9 @@ public class ApiWarningController extends BaseController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 远程查询api记录信息
|
* 远程查询api记录信息
|
||||||
|
*
|
||||||
* @param apiRecord
|
* @param apiRecord
|
||||||
* @return R<List<ApiRecord>>
|
* @return R<List < ApiRecord>>
|
||||||
*/
|
*/
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public R<List<ApiRecord>> selectApiRecordListForRPC(ApiRecord apiRecord) {
|
public R<List<ApiRecord>> selectApiRecordListForRPC(ApiRecord apiRecord) {
|
||||||
|
|
@ -64,60 +67,85 @@ public class ApiWarningController extends BaseController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 远程保存api预警信息
|
* 远程保存api预警信息
|
||||||
|
*
|
||||||
* @param apiWarning 预警实体类
|
* @param apiWarning 预警实体类
|
||||||
* @return R
|
* @return R
|
||||||
*/
|
*/
|
||||||
@PostMapping("saveApiwarningForRPC")
|
@PostMapping("saveApiwarningForRPC")
|
||||||
public R<ApiWarning> saveApiWarningForRPC(@RequestBody ApiWarning apiWarning) {
|
public R<ApiWarning> saveApiWarningForRPC(@RequestBody ApiWarning apiWarning) {
|
||||||
boolean save = apiWarningService.save(apiWarning);
|
boolean save = apiWarningService.save(apiWarning);
|
||||||
return save? R.ok():R.fail();
|
return save ? R.ok() : R.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询api预警列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("warning:warning:list")
|
||||||
|
@GetMapping("/apiwarnlist")
|
||||||
|
public TableDataInfo list(ApiWarning apiWarning) {
|
||||||
|
startPage();
|
||||||
|
List<ApiWarning> list = apiWarningService.list(new QueryWrapper<ApiWarning>()
|
||||||
|
.like(Objects.nonNull(apiWarning.getApiName()),"api_name", apiWarning.getApiName()));
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出api预警列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("warning:warning:export")
|
||||||
|
@Log(title = "api预警", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/apiwarnexport")
|
||||||
|
public void export(HttpServletResponse response, ApiWarning apiWarning) {
|
||||||
|
List<ApiWarning> list = apiWarningService.list(new QueryWrapper<ApiWarning>()
|
||||||
|
.like(Objects.nonNull(apiWarning.getApiName()),"api_name", apiWarning.getApiName()));
|
||||||
|
ExcelUtil<ApiWarning> util = new ExcelUtil<ApiWarning>(ApiWarning.class);
|
||||||
|
util.exportExcel(response, list, "api预警数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------代码生成------------------------------------
|
//-------------------------代码生成------------------------------------
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询API预警列表
|
* 查询API预警信息列表
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("warning:apiwarning:list")
|
@RequiresPermissions("warning:apiwarning:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(ApiRecord apiRecord)
|
public TableDataInfo list(ApiRecord apiRecord) {
|
||||||
{
|
|
||||||
startPage();
|
startPage();
|
||||||
List<ApiRecord> list = apiWarningService.selectApiRecordList(apiRecord);
|
List<ApiRecord> list = apiWarningService.selectApiRecordList(apiRecord);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出API预警列表
|
* 导出API预警信息列表
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("warning:apiwarning:export")
|
@RequiresPermissions("warning:apiwarning:export")
|
||||||
@Log(title = "API预警", businessType = BusinessType.EXPORT)
|
@Log(title = "API预警", businessType = BusinessType.EXPORT)
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, ApiRecord apiRecord)
|
public void export(HttpServletResponse response, ApiRecord apiRecord) {
|
||||||
{
|
|
||||||
List<ApiRecord> list = apiWarningService.selectApiRecordList(apiRecord);
|
List<ApiRecord> list = apiWarningService.selectApiRecordList(apiRecord);
|
||||||
ExcelUtil<ApiRecord> util = new ExcelUtil<ApiRecord>(ApiRecord.class);
|
ExcelUtil<ApiRecord> util = new ExcelUtil<ApiRecord>(ApiRecord.class);
|
||||||
util.exportExcel(response, list, "API预警数据");
|
util.exportExcel(response, list, "API预警数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取API预警详细信息
|
* 获取API预警详细信息信息
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("warning:apiwarning:query")
|
@RequiresPermissions("warning:apiwarning:query")
|
||||||
@GetMapping(value = "/{id}")
|
@GetMapping(value = "/{id}")
|
||||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||||
{
|
|
||||||
return AjaxResult.success(apiWarningService.selectApiRecordById(id));
|
return AjaxResult.success(apiWarningService.selectApiRecordById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改API预警
|
* 修改API预警信息
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("warning:apiwarning:edit")
|
@RequiresPermissions("warning:apiwarning:edit")
|
||||||
@Log(title = "API预警", businessType = BusinessType.UPDATE)
|
@Log(title = "API预警", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("edit")
|
@PutMapping("edit")
|
||||||
public AjaxResult edit(@RequestBody ApiRecord apiRecord)
|
public AjaxResult edit(@RequestBody ApiRecord apiRecord) {
|
||||||
{
|
|
||||||
return toAjax(apiWarningService.updateApiRecord(apiRecord));
|
return toAjax(apiWarningService.updateApiRecord(apiRecord));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Reference in New Issue