mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-11-30 10:58:14 +08:00
修改监控状态日志
This commit is contained in:
parent
e77a9162e3
commit
16e093a75e
@ -12,6 +12,7 @@
|
||||
6. 支持配置是否记录请求、响应日志【consoleLog.reqXss、consoleLog.reqResponse】
|
||||
7. 新增日志记录最大记录条数【默认100000】
|
||||
8. 【Server】layui 升级到2.5.4
|
||||
9. 【Server】新增项目监控功能
|
||||
|
||||
### 解决BUG、优化功能
|
||||
|
||||
|
@ -98,23 +98,11 @@ public class MonitorListController extends BaseServerController {
|
||||
return JsonMessage.getString(200, "删除成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加或修改监控
|
||||
*/
|
||||
@RequestMapping(value = "updateMonitor", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||
@ResponseBody
|
||||
@UrlPermission(value = Role.ServerManager, optType = UserOperateLogV1.OptType.EditMonitor)
|
||||
public String updateMonitor(String id,
|
||||
@ValidatorConfig(@ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "监控名称不能为空")) String name) {
|
||||
String notify = getParameter("notify");
|
||||
int cycle = getParameterInt("cycle", MonitorModel.Cycle.five.getCode());
|
||||
String status = getParameter("status");
|
||||
String autoRestart = getParameter("autoRestart");
|
||||
private String checkNotifyData(String notify, List<MonitorModel.Notify> notifies) {
|
||||
JSONArray notifyArray = JSONArray.parseArray(notify);
|
||||
if (notify == null || notifyArray.size() <= 0) {
|
||||
if (notify == null || notifyArray.isEmpty()) {
|
||||
return JsonMessage.getString(400, "请至少选择一种通知方式");
|
||||
}
|
||||
List<MonitorModel.Notify> notifies = new ArrayList<>();
|
||||
for (int i = 0; i < notifyArray.size(); i++) {
|
||||
JSONObject jsonObject = notifyArray.getJSONObject(i);
|
||||
int style = jsonObject.getIntValue("style");
|
||||
@ -153,6 +141,26 @@ public class MonitorListController extends BaseServerController {
|
||||
}
|
||||
notifies.add(new MonitorModel.Notify(style, value));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加或修改监控
|
||||
*/
|
||||
@RequestMapping(value = "updateMonitor", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||
@ResponseBody
|
||||
@UrlPermission(value = Role.ServerManager, optType = UserOperateLogV1.OptType.EditMonitor)
|
||||
public String updateMonitor(String id,
|
||||
@ValidatorConfig(@ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "监控名称不能为空")) String name,
|
||||
String notify) {
|
||||
int cycle = getParameterInt("cycle", MonitorModel.Cycle.five.getCode());
|
||||
String status = getParameter("status");
|
||||
String autoRestart = getParameter("autoRestart");
|
||||
List<MonitorModel.Notify> notifies = new ArrayList<>();
|
||||
String error = checkNotifyData(notify, notifies);
|
||||
if (error != null) {
|
||||
return error;
|
||||
}
|
||||
String projects = getParameter("projects");
|
||||
JSONArray projectsArray = JSONArray.parseArray(projects);
|
||||
if (projectsArray == null || projectsArray.size() <= 0) {
|
||||
@ -175,7 +183,7 @@ public class MonitorListController extends BaseServerController {
|
||||
monitorModel.setStatus(start);
|
||||
monitorModel.setNotify(notifies);
|
||||
monitorModel.setName(name);
|
||||
monitorModel.setModifyTime(DateUtil.date().getTime());
|
||||
|
||||
if (StrUtil.isEmpty(id)) {
|
||||
//添加监控
|
||||
id = IdUtil.objectId();
|
||||
@ -194,6 +202,7 @@ public class MonitorListController extends BaseServerController {
|
||||
*/
|
||||
@RequestMapping(value = "changeStatus", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||
@ResponseBody
|
||||
@UrlPermission(value = Role.ServerManager, optType = UserOperateLogV1.OptType.ChangeStatusMonitor)
|
||||
public String changeStatus(@ValidatorConfig(@ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "id不能为空")) String id,
|
||||
String status, String type) {
|
||||
MonitorModel monitorModel = monitorService.getItem(id);
|
||||
|
@ -263,6 +263,7 @@ public class UserOperateLogV1 extends BaseJsonModel {
|
||||
|
||||
EditMonitor(54, "修改监控"),
|
||||
DelMonitor(55, "删除监控"),
|
||||
ChangeStatusMonitor(56, "修改监控状态"),
|
||||
;
|
||||
private int code;
|
||||
private String desc;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.keepbx.jpom.service.monitor;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.jiangzeyin.common.DefaultSystemLog;
|
||||
import cn.keepbx.jpom.common.BaseOperService;
|
||||
import cn.keepbx.jpom.model.data.MonitorModel;
|
||||
@ -85,6 +86,7 @@ public class MonitorService extends BaseOperService<MonitorModel> {
|
||||
@Override
|
||||
public boolean updateItem(MonitorModel monitorModel) {
|
||||
try {
|
||||
monitorModel.setModifyTime(DateUtil.date().getTime());
|
||||
updateJson(ServerConfigBean.MONITOR_FILE, monitorModel.toJson());
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
|
@ -163,7 +163,6 @@
|
||||
return false;
|
||||
}
|
||||
sendData.notify = JSON.stringify(notify);
|
||||
console.log(sendData);
|
||||
loadingAjax({
|
||||
url: data.form.action,
|
||||
data: sendData,
|
||||
@ -243,4 +242,4 @@
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user