|
|
@ -1,5 +1,6 @@
|
|
|
|
package com.xjs.controller;
|
|
|
|
package com.xjs.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.ruoyi.common.core.domain.R;
|
|
|
|
import com.ruoyi.common.core.domain.R;
|
|
|
@ -44,6 +45,71 @@ public class ApiWarningController extends BaseController {
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private RedisService redisService;
|
|
|
|
private RedisService redisService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 处理预警单个预警
|
|
|
|
|
|
|
|
* @param id 预警id
|
|
|
|
|
|
|
|
* @return R
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@PutMapping("handle/{id}")
|
|
|
|
|
|
|
|
@RequiresPermissions("warning:warning:handle")
|
|
|
|
|
|
|
|
@ApiOperation("处理预警单个预警")
|
|
|
|
|
|
|
|
@Log(title = "处理单个预警")
|
|
|
|
|
|
|
|
public R<Object> handleWarning(@PathVariable("id") Long id) {
|
|
|
|
|
|
|
|
ApiWarning apiWarning = new ApiWarning();
|
|
|
|
|
|
|
|
apiWarning.setId(id);
|
|
|
|
|
|
|
|
apiWarning.setHandle(YES);
|
|
|
|
|
|
|
|
return apiWarningService.updateById(apiWarning)?R.ok():R.fail();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 查询api预警列表
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@RequiresPermissions("warning:warning:list")
|
|
|
|
|
|
|
|
@GetMapping("/apiwarnlist")
|
|
|
|
|
|
|
|
@ApiOperation("查询api预警列表")
|
|
|
|
|
|
|
|
public TableDataInfo list(ApiWarning apiWarning) {
|
|
|
|
|
|
|
|
startPage();
|
|
|
|
|
|
|
|
List<ApiWarning> list = apiWarningService.list(new QueryWrapper<ApiWarning>()
|
|
|
|
|
|
|
|
.orderByDesc("create_time")
|
|
|
|
|
|
|
|
.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")
|
|
|
|
|
|
|
|
@ApiOperation("导出api预警列表")
|
|
|
|
|
|
|
|
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预警数据");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@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();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequiresPermissions("warning:warning:handleAll")
|
|
|
|
|
|
|
|
@PutMapping("handleAll")
|
|
|
|
|
|
|
|
@ApiOperation("全部标记已读")
|
|
|
|
|
|
|
|
@Log(title = "全部标记已读")
|
|
|
|
|
|
|
|
public R<Object> AllHaveRead() {
|
|
|
|
|
|
|
|
Integer integer = apiWarningService.AllHaveRead();
|
|
|
|
|
|
|
|
return integer > 0 ? R.ok(integer) : R.fail();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------内部调用rpc-----------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 远程保存 apiRecord
|
|
|
|
* 远程保存 apiRecord
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -81,6 +147,14 @@ public class ApiWarningController extends BaseController {
|
|
|
|
return R.ok(apiRecords);
|
|
|
|
return R.ok(apiRecords);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("findRecordListForRPC")
|
|
|
|
|
|
|
|
@ApiOperation("远程查询预警信息")
|
|
|
|
|
|
|
|
public R<JSONArray> findRecordListForRPC() {
|
|
|
|
|
|
|
|
List<ApiRecord> apiRecordList = apiWarningService.selectApiRecordList(new ApiRecord());
|
|
|
|
|
|
|
|
JSONArray jo= (JSONArray) JSONArray.toJSON(apiRecordList);
|
|
|
|
|
|
|
|
return R.ok(jo);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 远程获取所有Api名称
|
|
|
|
* 远程获取所有Api名称
|
|
|
|
* @return api名称
|
|
|
|
* @return api名称
|
|
|
@ -92,21 +166,7 @@ public class ApiWarningController extends BaseController {
|
|
|
|
return R.ok(apiNameList);
|
|
|
|
return R.ok(apiNameList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 处理预警单个预警
|
|
|
|
|
|
|
|
* @param id 预警id
|
|
|
|
|
|
|
|
* @return R
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@PutMapping("handle/{id}")
|
|
|
|
|
|
|
|
@RequiresPermissions("warning:warning:handle")
|
|
|
|
|
|
|
|
@ApiOperation("处理预警单个预警")
|
|
|
|
|
|
|
|
@Log(title = "处理单个预警")
|
|
|
|
|
|
|
|
public R<Object> handleWarning(@PathVariable("id") Long id) {
|
|
|
|
|
|
|
|
ApiWarning apiWarning = new ApiWarning();
|
|
|
|
|
|
|
|
apiWarning.setId(id);
|
|
|
|
|
|
|
|
apiWarning.setHandle(YES);
|
|
|
|
|
|
|
|
return apiWarningService.updateById(apiWarning)?R.ok():R.fail();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 远程保存api预警信息并websocket推送
|
|
|
|
* 远程保存api预警信息并websocket推送
|
|
|
@ -148,51 +208,6 @@ public class ApiWarningController extends BaseController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 查询api预警列表
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@RequiresPermissions("warning:warning:list")
|
|
|
|
|
|
|
|
@GetMapping("/apiwarnlist")
|
|
|
|
|
|
|
|
@ApiOperation("查询api预警列表")
|
|
|
|
|
|
|
|
public TableDataInfo list(ApiWarning apiWarning) {
|
|
|
|
|
|
|
|
startPage();
|
|
|
|
|
|
|
|
List<ApiWarning> list = apiWarningService.list(new QueryWrapper<ApiWarning>()
|
|
|
|
|
|
|
|
.orderByDesc("create_time")
|
|
|
|
|
|
|
|
.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")
|
|
|
|
|
|
|
|
@ApiOperation("导出api预警列表")
|
|
|
|
|
|
|
|
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预警数据");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@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();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequiresPermissions("warning:warning:handleAll")
|
|
|
|
|
|
|
|
@PutMapping("handleAll")
|
|
|
|
|
|
|
|
@ApiOperation("全部标记已读")
|
|
|
|
|
|
|
|
@Log(title = "全部标记已读")
|
|
|
|
|
|
|
|
public R<Object> AllHaveRead() {
|
|
|
|
|
|
|
|
Integer integer = apiWarningService.AllHaveRead();
|
|
|
|
|
|
|
|
return integer > 0 ? R.ok(integer) : R.fail();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------代码生成------------------------------------
|
|
|
|
//-------------------------代码生成------------------------------------
|
|
|
|