parent
789e228055
commit
4c7b6ba667
|
|
@ -39,7 +39,7 @@ public interface RemoteWarningCRUDFeign {
|
|||
R<ApiWarning> saveApiWarningForRPC(@RequestBody ApiWarning apiWarning);
|
||||
|
||||
@GetMapping("/apiwarning/getApiNameForRPC")
|
||||
R<List<String>> getApiName();
|
||||
R<List<String>> getApiNameForRPC();
|
||||
|
||||
@GetMapping("/apistatistics/")
|
||||
R<List<ApiRecord>> selectApiRecordListForRPC();
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class RemoteWarningCRUDFactory implements FallbackFactory<RemoteWarningCR
|
|||
}
|
||||
|
||||
@Override
|
||||
public R<List<String>> getApiName() {
|
||||
public R<List<String>> getApiNameForRPC() {
|
||||
log.error("调用预警服务api预警查询所有api名称接口失败,执行降级处理----");
|
||||
return R.fail();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,3 +60,11 @@ export function AllHaveRead() {
|
|||
method: 'put',
|
||||
})
|
||||
}
|
||||
|
||||
//获取所有api名称
|
||||
export function getApiName() {
|
||||
return request({
|
||||
url: '/warning/apiwarning/getApiName' ,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="70px">
|
||||
<el-form-item label="接口名称" prop="apiName">
|
||||
<el-form-item label="API名称" prop="apiName">
|
||||
<el-select
|
||||
v-model="queryParams.apiName"
|
||||
placeholder="请输入"
|
||||
|
|
@ -130,7 +130,7 @@
|
|||
|
||||
<el-table v-loading="loading" :data="logList" border height="585" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center"/>
|
||||
<el-table-column label="接口名称" align="center" prop="apiName" :show-overflow-tooltip="true"/>
|
||||
<el-table-column label="API名称" align="center" prop="apiName" :show-overflow-tooltip="true"/>
|
||||
<el-table-column label="请求URL" align="center" prop="url" :show-overflow-tooltip="true"/>
|
||||
<el-table-column label="请求方法" align="center" prop="method" :show-overflow-tooltip="true"/>
|
||||
<el-table-column label="请求参数" align="center" prop="request" :show-overflow-tooltip="true">
|
||||
|
|
|
|||
|
|
@ -2,13 +2,18 @@
|
|||
<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
|
||||
<el-select
|
||||
v-model="queryParams.apiName"
|
||||
placeholder="请输入api名称"
|
||||
placeholder="请输入"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
style="width: 180px">
|
||||
<el-option
|
||||
v-for="index in apiName"
|
||||
:key="index"
|
||||
:label="index"
|
||||
:value="index"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
|
|
@ -96,7 +101,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import {listApiwarning,clearAll,AllHaveRead } from "@/api/business/warning/apiwarning";
|
||||
import {listApiwarning,clearAll,AllHaveRead,getApiName } from "@/api/business/warning/apiwarning";
|
||||
|
||||
export default {
|
||||
name: "Warning",
|
||||
|
|
@ -128,14 +133,23 @@ export default {
|
|||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {}
|
||||
|
||||
//api名称
|
||||
apiName: [],
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
this.getApiName();
|
||||
},
|
||||
methods: {
|
||||
//获取所有api名称
|
||||
getApiName() {
|
||||
getApiName().then(res => {
|
||||
this.apiName = res.data
|
||||
})
|
||||
},
|
||||
|
||||
//全部标记已读
|
||||
AllHaveRead() {
|
||||
AllHaveRead().then(res =>{
|
||||
|
|
|
|||
|
|
@ -2,13 +2,18 @@
|
|||
<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
|
||||
<el-select
|
||||
v-model="queryParams.apiName"
|
||||
placeholder="请输入api名称"
|
||||
placeholder="请输入"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
style="width: 180px">
|
||||
<el-option
|
||||
v-for="index in apiName"
|
||||
:key="index"
|
||||
:label="index"
|
||||
:value="index"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
|
|
@ -86,7 +91,7 @@
|
|||
<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-input v-model.number="form.limitCount" placeholder="请输入api限制请求次数每天"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
|
|
@ -98,7 +103,12 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { getApiwarningInfo, updateApiwarningInfo,listApiwarningInfo} from "@/api/business/warning/apiwarning";
|
||||
import {
|
||||
getApiwarningInfo,
|
||||
updateApiwarningInfo,
|
||||
listApiwarningInfo,
|
||||
getApiName
|
||||
} from "@/api/business/warning/apiwarning";
|
||||
|
||||
export default {
|
||||
name: "Apiwarning",
|
||||
|
|
@ -131,13 +141,29 @@ export default {
|
|||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {}
|
||||
rules: {
|
||||
limitCount: [
|
||||
{required: true, message: "请求次数", trigger: "blur"},
|
||||
{type: 'number',min: 0, max: 9999, message: '必须数字!且数字在 0 到 9999 之间!', trigger: 'blur'}
|
||||
],
|
||||
},
|
||||
|
||||
//api名称
|
||||
apiName: [],
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
this.getApiName();
|
||||
},
|
||||
methods: {
|
||||
//获取所有api名称
|
||||
getApiName() {
|
||||
getApiName().then(res => {
|
||||
this.apiName = res.data
|
||||
})
|
||||
},
|
||||
|
||||
/** 查询API预警列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public class ApiLogServiceImpl extends ServiceImpl<ApiLogMapper,ApiLog> implemen
|
|||
|
||||
@Override
|
||||
public List<String> getApiName() {
|
||||
R<List<String>> apiName = remoteWarningCRUDFeign.getApiName();
|
||||
R<List<String>> apiName = remoteWarningCRUDFeign.getApiNameForRPC();
|
||||
if (apiName.getCode() == HttpStatus.SUCCESS) {
|
||||
return apiName.getData();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,10 +16,13 @@ import com.xjs.domain.ApiRecord;
|
|||
import com.xjs.domain.ApiWarning;
|
||||
import com.xjs.server.WebSocketServer;
|
||||
import com.xjs.service.ApiWarningService;
|
||||
import com.xjs.validation.group.SelectGroup;
|
||||
import com.xjs.validation.group.UpdateGroup;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
|
@ -108,6 +111,19 @@ public class ApiWarningController extends BaseController {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有Api名称
|
||||
* @return api名称
|
||||
*/
|
||||
@GetMapping("getApiName")
|
||||
@ApiOperation("获取所有Api名称")
|
||||
@RequiresPermissions("warning:warning:list")
|
||||
public R<List<String>> getApiName() {
|
||||
List<String> apiNameList = apiWarningService.getApiName();
|
||||
return R.ok(apiNameList);
|
||||
}
|
||||
|
||||
|
||||
//--------------------内部调用rpc-----------------------------------
|
||||
|
||||
/**
|
||||
|
|
@ -161,7 +177,7 @@ public class ApiWarningController extends BaseController {
|
|||
*/
|
||||
@GetMapping("getApiNameForRPC")
|
||||
@ApiOperation("远程获取所有Api名称")
|
||||
public R<List<String>> getApiName() {
|
||||
public R<List<String>> getApiNameForRPC() {
|
||||
List<String> apiNameList = apiWarningService.getApiName();
|
||||
return R.ok(apiNameList);
|
||||
}
|
||||
|
|
@ -219,7 +235,7 @@ public class ApiWarningController extends BaseController {
|
|||
@RequiresPermissions("warning:apiwarning:list")
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("查询API预警信息列表")
|
||||
public TableDataInfo list(ApiRecord apiRecord) {
|
||||
public TableDataInfo list(@Validated({SelectGroup.class}) ApiRecord apiRecord) {
|
||||
startPage();
|
||||
List<ApiRecord> list = apiWarningService.selectApiRecordList(apiRecord);
|
||||
return getDataTable(list);
|
||||
|
|
@ -255,7 +271,7 @@ public class ApiWarningController extends BaseController {
|
|||
@Log(title = "API预警", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("edit")
|
||||
@ApiOperation("修改API预警信息")
|
||||
public AjaxResult edit(@RequestBody ApiRecord apiRecord) {
|
||||
public AjaxResult edit(@Validated({UpdateGroup.class}) @RequestBody ApiRecord apiRecord) {
|
||||
return toAjax(apiWarningService.updateApiRecord(apiRecord));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,14 @@ import com.baomidou.mybatisplus.annotation.FieldFill;
|
|||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.core.annotation.Excel;
|
||||
import com.xjs.validation.group.SelectGroup;
|
||||
import com.xjs.validation.group.UpdateGroup;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
|
@ -29,6 +35,7 @@ public class ApiRecord implements Serializable {
|
|||
* api名称
|
||||
*/
|
||||
@Excel(name = "api名称")
|
||||
@Size(max = 20, message = "请控制api名称长度在20字符", groups = { SelectGroup.class})
|
||||
private String apiName;
|
||||
|
||||
/**
|
||||
|
|
@ -53,6 +60,9 @@ public class ApiRecord implements Serializable {
|
|||
* api限制请求次数每天
|
||||
*/
|
||||
@Excel(name = "api限制请求次数每天")
|
||||
@NotNull(message = "api每天限制请求次数不能为空",groups = UpdateGroup.class)
|
||||
@Max(value = 9999,message = "超过最大值!api每天限制请求次数最大为9999",groups = UpdateGroup.class)
|
||||
@Min(value = 0,message = "低于最小值!api每天限制请求次数最小为0",groups = UpdateGroup.class)
|
||||
private Long limitCount;
|
||||
|
||||
@Excel(name = "api每天请求次数")
|
||||
|
|
|
|||
Loading…
Reference in New Issue