package com.product.data.center.controller;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import com.product.core.controller.support.AbstractBaseController;
|
import com.product.core.entity.FieldSetEntity;
|
import com.product.core.exception.BaseException;
|
import com.product.data.center.config.ErrorCode;
|
import com.product.data.center.service.JournalManagerService;
|
import com.product.module.sys.version.ApiVersion;
|
import com.product.util.BaseUtil;
|
|
/**
|
* 监控
|
* @author 86151
|
*
|
*/
|
@RequestMapping("/api/monitor")
|
@RestController
|
public class MonitorController extends AbstractBaseController{
|
|
@Autowired
|
JournalManagerService journalManagerService;
|
|
/**
|
* 左侧分组
|
* @param request
|
* @return
|
*/
|
@PostMapping("/list-monitor/{version}")
|
@ApiVersion(1)
|
public String listMonitor(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
|
return OK_List(journalManagerService.journalServerView());
|
} catch (BaseException e) {
|
e.printStackTrace();
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return error(ErrorCode.MONITOR_LIST_LEFT_GROUP_FAIL);
|
}
|
}
|
|
/**
|
* 右侧视图
|
* @param request
|
* @return
|
*/
|
@PostMapping("/find-monitor/{version}")
|
@ApiVersion(1)
|
public String findMonitorView(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
|
return OK_List(journalManagerService.groupCountErrorLog(fse));
|
} catch (BaseException e) {
|
e.printStackTrace();
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return error(ErrorCode.MONITOR_LIST_RIGHT_VIEW_FAIL);
|
}
|
}
|
|
/**
|
* 日志列表
|
* @param request
|
* @return
|
*/
|
@PostMapping("/list-log/{version}")
|
@ApiVersion(1)
|
public String listLogInfo(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
|
if(BaseUtil.strIsNull(fse.getString("cpage"))|| BaseUtil.strIsNull(fse.getString("pagesize"))) {
|
fse.setValue("cpage", 1);
|
fse.setValue("pagesize", 20);
|
}
|
return OK_List(journalManagerService.listJournal(fse, false));
|
} catch (BaseException e) {
|
e.printStackTrace();
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return error(ErrorCode.MONITOR_LIST_LOG_FAIL);
|
}
|
}
|
|
/**
|
* 错误日志列表
|
* @param request
|
* @return
|
*/
|
@PostMapping("/list-error-log/{version}")
|
@ApiVersion(1)
|
public String listErrorLogInfo(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
|
if(BaseUtil.strIsNull(fse.getString("cpage"))|| BaseUtil.strIsNull(fse.getString("pagesize"))) {
|
fse.setValue("cpage", 1);
|
fse.setValue("pagesize", 20);
|
}
|
return OK_List(journalManagerService.listJournal(fse, true));
|
} catch (BaseException e) {
|
e.printStackTrace();
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return error(ErrorCode.MONITOR_LIST_ERROR_LOG_FAIL);
|
}
|
}
|
|
/**
|
* 日志详情
|
* @param request
|
* @return
|
*/
|
@PostMapping("/find-log/{version}")
|
@ApiVersion(1)
|
public String findLogInfo(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
|
return OK_List(journalManagerService.findJournal(fse));
|
} catch (BaseException e) {
|
e.printStackTrace();
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return error(ErrorCode.MONITOR_FIND_LOG_FAIL);
|
}
|
}
|
|
/**
|
* 错误日志重新处理
|
* @param request
|
* @return
|
*/
|
@PostMapping("/reprocess-log/{version}")
|
@ApiVersion(1)
|
public String reprocessLog(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
|
journalManagerService.secondOperation(fse.getUUID());
|
return OK();
|
} catch (BaseException e) {
|
e.printStackTrace();
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return error(ErrorCode.LOGMONITOR_OPERATE_FAIL+e.getMessage());
|
}
|
}
|
|
/**
|
* 错误日志标识处理
|
* @param request
|
* @return
|
*/
|
@PostMapping("/identification-log/{version}")
|
@ApiVersion(1)
|
public String identificationLog(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
|
|
journalManagerService.signOperation(fse.getUUID());
|
return OK();
|
} catch (BaseException e) {
|
e.printStackTrace();
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return error(ErrorCode.MONITOR_SIGN_ERROR_LOG_FAIL);
|
}
|
}
|
}
|