Commit 6f12179b authored by AfirSraftGarrier's avatar AfirSraftGarrier

修改

parent 5f66a4f5
...@@ -53,7 +53,7 @@ public class LoginController { ...@@ -53,7 +53,7 @@ public class LoginController {
String token = JwtUtil.createToken(dbUser); String token = JwtUtil.createToken(dbUser);
LoginVo loginVo = new LoginVo(); LoginVo loginVo = new LoginVo();
loginVo.setAuthorization(token); loginVo.setAuthorization(token);
return ResResult.success().record(loginVo); return ResResult.success().goRecord(loginVo);
} }
} }
return ResResult.failed().setMsgValue("用户名或密码错误"); return ResResult.failed().setMsgValue("用户名或密码错误");
......
...@@ -57,7 +57,7 @@ public class OperateController { ...@@ -57,7 +57,7 @@ public class OperateController {
@MyLog(title = "获取服务列表", businessType = BusinessType.SELECT) @MyLog(title = "获取服务列表", businessType = BusinessType.SELECT)
public ResResult<SamMonitor> getDeviceTypes() { public ResResult<SamMonitor> getDeviceTypes() {
List<SamMonitor> records = operateManager.getSamMonitorList(); List<SamMonitor> records = operateManager.getSamMonitorList();
return ResResult.success().record(records); return ResResult.success().goRecord(records);
} }
...@@ -71,10 +71,10 @@ public class OperateController { ...@@ -71,10 +71,10 @@ public class OperateController {
@ApiOperation(value = "获取并发量接口", notes = "用于获取并发量") @ApiOperation(value = "获取并发量接口", notes = "用于获取并发量")
@GetMapping("monitor/qps") @GetMapping("monitor/qps")
@MyLog(title = "获取并发量", optParam = "#{type}", businessType = BusinessType.SELECT) @MyLog(title = "获取并发量", optParam = "#{type}", businessType = BusinessType.SELECT)
@ApiImplicitParam(name = "type",value = "类型:0:今天 1:昨天 2:七天前 3:三十天前",required = true, dataType = "int") @ApiImplicitParam(name = "type", value = "类型:0:今天 1:昨天 2:七天前 3:三十天前", required = true, dataType = "int")
public ResResult<QpsVo> getQps(@RequestParam("type") int type) { public ResResult<QpsVo> getQps(@RequestParam("type") int type) {
HashMap<String, List<Integer>> monitorList = monitorService.getMonitorList(type); HashMap<String, List<Integer>> monitorList = monitorService.getMonitorList(type);
return ResResult.success().record(monitorList); return ResResult.success().goRecord(monitorList);
} }
@ApiOperation(value = "获取服务自诊断信息接口", notes = "用于获取服务诊断信息") @ApiOperation(value = "获取服务自诊断信息接口", notes = "用于获取服务诊断信息")
...@@ -83,7 +83,7 @@ public class OperateController { ...@@ -83,7 +83,7 @@ public class OperateController {
@ApiImplicitParam() @ApiImplicitParam()
public ResResult<ServerStatusVo> getDiagnosisInfo() { public ResResult<ServerStatusVo> getDiagnosisInfo() {
ServerStatusVo serverStatus = forwardManager.getServerStatus(); ServerStatusVo serverStatus = forwardManager.getServerStatus();
return ResResult.success().record(serverStatus); return ResResult.success().goRecord(serverStatus);
} }
...@@ -94,13 +94,13 @@ public class OperateController { ...@@ -94,13 +94,13 @@ public class OperateController {
String userId = UserUtils.getLoginUserId(); String userId = UserUtils.getLoginUserId();
int Id = Integer.valueOf(userId); int Id = Integer.valueOf(userId);
List<AlarmVo> alarmList = alarmService.getAlarmList(Id); List<AlarmVo> alarmList = alarmService.getAlarmList(Id);
return ResResult.success().record(alarmList); return ResResult.success().goRecord(alarmList);
} }
@ApiOperation(value = "告警已读接口", notes = "将告警信息状态设为已读") @ApiOperation(value = "告警已读接口", notes = "将告警信息状态设为已读")
@PostMapping("alarm/read") @PostMapping("alarm/read")
@MyLog(title = "将告警信息状态设为已读", businessType = BusinessType.OTHER) @MyLog(title = "将告警信息状态设为已读", businessType = BusinessType.OTHER)
public BaseResult readAlarm(){ public BaseResult readAlarm() {
String id = UserUtils.getLoginUserId(); String id = UserUtils.getLoginUserId();
int userId = Integer.valueOf(id); int userId = Integer.valueOf(id);
boolean res = alarmReadService.readAlarm(userId); boolean res = alarmReadService.readAlarm(userId);
...@@ -116,35 +116,36 @@ public class OperateController { ...@@ -116,35 +116,36 @@ public class OperateController {
@MyLog(title = "统计sam总数", businessType = BusinessType.SELECT) @MyLog(title = "统计sam总数", businessType = BusinessType.SELECT)
public ResResult<SamVo> getSamTotalCount() { public ResResult<SamVo> getSamTotalCount() {
Map<String, SamMonitor> samMonitorMap = operateManager.getSamMonitorMap(); Map<String, SamMonitor> samMonitorMap = operateManager.getSamMonitorMap();
Map<String,Integer> map = new HashMap<>(); Map<String, Integer> map = new HashMap<>();
int totalSamCount = 0; int totalSamCount = 0;
int totalOnlineCount = 0; int totalOnlineCount = 0;
for (SamMonitor samMonitor: samMonitorMap.values()) { for (SamMonitor samMonitor : samMonitorMap.values()) {
totalSamCount += samMonitor.getSamCount(); totalSamCount += samMonitor.getSamCount();
totalOnlineCount += samMonitor.getOnlineCount(); totalOnlineCount += samMonitor.getOnlineCount();
} }
SamVo samVo = new SamVo(); SamVo samVo = new SamVo();
samVo.setTotalOnlineCount(totalOnlineCount); samVo.setTotalOnlineCount(totalOnlineCount);
samVo.setTotalSamCount(totalSamCount); samVo.setTotalSamCount(totalSamCount);
return ResResult.success().record(samVo); return ResResult.success().goRecord(samVo);
} }
/** /**
* 添加server * 添加server
*
* @param jsonObject * @param jsonObject
* @return * @return
*/ */
@ApiOperation(value = "添加服务接口", notes = "用于添加服务") @ApiOperation(value = "添加服务接口", notes = "用于添加服务")
@PostMapping("server/add") @PostMapping("server/add")
@MyLog(title = "添加服务", optParam = "#{jsonObject}", businessType = BusinessType.INSERT) @MyLog(title = "添加服务", optParam = "#{jsonObject}", businessType = BusinessType.INSERT)
@ApiOperationSupport(params = @DynamicParameters(name = "jsonObject",properties = { @ApiOperationSupport(params = @DynamicParameters(name = "jsonObject", properties = {
@DynamicParameter(name = "serverIp",value = "服务Ip",required = true,dataTypeClass = String.class), @DynamicParameter(name = "serverIp", value = "服务Ip", required = true, dataTypeClass = String.class),
@DynamicParameter(name = "port",value = "端口",required = true,dataTypeClass = Integer.class) @DynamicParameter(name = "port", value = "端口", required = true, dataTypeClass = Integer.class)
})) }))
public BaseResult addServer(@RequestBody JSONObject jsonObject) { public BaseResult addServer(@RequestBody JSONObject jsonObject) {
String serverIp = jsonObject.getString("serverIp"); String serverIp = jsonObject.getString("serverIp");
int port = jsonObject.getIntValue("port"); int port = jsonObject.getIntValue("port");
boolean res = serverService.addServer(serverIp,port); boolean res = serverService.addServer(serverIp, port);
if (res) { if (res) {
return BaseResult.success(); return BaseResult.success();
} else { } else {
...@@ -154,6 +155,7 @@ public class OperateController { ...@@ -154,6 +155,7 @@ public class OperateController {
/** /**
* 删除server * 删除server
*
* @param serverIp * @param serverIp
* @return * @return
*/ */
...@@ -171,20 +173,21 @@ public class OperateController { ...@@ -171,20 +173,21 @@ public class OperateController {
/** /**
* 修改server * 修改server
*
* @param jsonObject * @param jsonObject
* @return * @return
*/ */
@ApiOperation(value = "修改服务接口", notes = "修改服务") @ApiOperation(value = "修改服务接口", notes = "修改服务")
@PostMapping("server/update") @PostMapping("server/update")
@MyLog(title = "修改服务", optParam = "#{serverIp},#{port}", businessType = BusinessType.UPDATE) @MyLog(title = "修改服务", optParam = "#{serverIp},#{port}", businessType = BusinessType.UPDATE)
@ApiOperationSupport(params = @DynamicParameters(name = "jsonObject",properties = { @ApiOperationSupport(params = @DynamicParameters(name = "jsonObject", properties = {
@DynamicParameter(name = "serverIp",value = "服务Ip",required = true,dataTypeClass = String.class), @DynamicParameter(name = "serverIp", value = "服务Ip", required = true, dataTypeClass = String.class),
@DynamicParameter(name = "port",value = "端口",required = true,dataTypeClass = Integer.class) @DynamicParameter(name = "port", value = "端口", required = true, dataTypeClass = Integer.class)
})) }))
public BaseResult updateServer(@RequestBody JSONObject jsonObject) { public BaseResult updateServer(@RequestBody JSONObject jsonObject) {
String serverIp = jsonObject.getString("serverIp"); String serverIp = jsonObject.getString("serverIp");
int port = jsonObject.getInteger("port"); int port = jsonObject.getInteger("port");
boolean res = serverService.updateServer(serverIp,port); boolean res = serverService.updateServer(serverIp, port);
if (res) { if (res) {
return BaseResult.success(); return BaseResult.success();
} else { } else {
...@@ -195,6 +198,7 @@ public class OperateController { ...@@ -195,6 +198,7 @@ public class OperateController {
/** /**
* 分页查询所有的server * 分页查询所有的server
*
* @param pageNo * @param pageNo
* @param pageSize * @param pageSize
* @return * @return
...@@ -203,12 +207,12 @@ public class OperateController { ...@@ -203,12 +207,12 @@ public class OperateController {
@GetMapping("server/list") @GetMapping("server/list")
@MyLog(title = "获取服务列表", optParam = "#{pageNo},#{pageSize}", businessType = BusinessType.SELECT) @MyLog(title = "获取服务列表", optParam = "#{pageNo},#{pageSize}", businessType = BusinessType.SELECT)
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "pageNo",value = "当前在第几页", required = true,dataType = "int"), @ApiImplicitParam(name = "pageNo", value = "当前在第几页", required = true, dataType = "int"),
@ApiImplicitParam(name = "pageSize",value = "每页显示多少条", required = true, dataType = "int") @ApiImplicitParam(name = "pageSize", value = "每页显示多少条", required = true, dataType = "int")
}) })
public ResResult<List<Server>> getServerList(@RequestParam("pageNo") int pageNo, public ResResult<List<Server>> getServerList(@RequestParam("pageNo") int pageNo,
@RequestParam("pageSize") int pageSize) { @RequestParam("pageSize") int pageSize) {
List<Server> records = serverService.getServerList(pageNo,pageSize); List<Server> records = serverService.getServerList(pageNo, pageSize);
return ResResult.success().record(records); return ResResult.success().goRecord(records);
} }
} }
...@@ -30,46 +30,51 @@ public class ResResult<T> { ...@@ -30,46 +30,51 @@ public class ResResult<T> {
/** /**
* code = 200 * code = 200
* msg = 操作成功 * msg = 操作成功
*
* @return * @return
*/ */
public static ResResult success() { public static ResResult success() {
return new ResResult(ResultCode.SUCCESS.getCode(),ResultCode.SUCCESS.getMsg()); return new ResResult(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMsg());
} }
/** /**
* code = 400 * code = 400
* msg = 服务异常 * msg = 服务异常
*
* @return * @return
*/ */
public static ResResult serverException() { public static ResResult serverException() {
return new ResResult(ResultCode.SERVER_EXCEPTION.getCode(),ResultCode.SERVER_EXCEPTION.getMsg()); return new ResResult(ResultCode.SERVER_EXCEPTION.getCode(), ResultCode.SERVER_EXCEPTION.getMsg());
} }
/** /**
* code = 401 * code = 401
* msg = 暂未登录或token已经过期 * msg = 暂未登录或token已经过期
*
* @return * @return
*/ */
public static ResResult unauthorized() { public static ResResult unauthorized() {
return new ResResult(ResultCode.UNAUTHORIZED.getCode(),ResultCode.UNAUTHORIZED.getMsg()); return new ResResult(ResultCode.UNAUTHORIZED.getCode(), ResultCode.UNAUTHORIZED.getMsg());
} }
/** /**
* code = 402 * code = 402
* msg = 参数校验失败 * msg = 参数校验失败
*
* @return * @return
*/ */
public static ResResult validate_failed() { public static ResResult validate_failed() {
return new ResResult(ResultCode.VALIDATE_FAILED.getCode(),ResultCode.VALIDATE_FAILED.getMsg()); return new ResResult(ResultCode.VALIDATE_FAILED.getCode(), ResultCode.VALIDATE_FAILED.getMsg());
} }
/** /**
* code = 403 * code = 403
* msg = 操作失败(数据库增删改查等失败) * msg = 操作失败(数据库增删改查等失败)
*
* @return * @return
*/ */
public static ResResult failed() { public static ResResult failed() {
return new ResResult(ResultCode.SUCCESS.getCode(),ResultCode.SUCCESS.getMsg()); return new ResResult(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMsg());
} }
...@@ -83,7 +88,7 @@ public class ResResult<T> { ...@@ -83,7 +88,7 @@ public class ResResult<T> {
return this; return this;
} }
public ResResult record(T data){ public ResResult goRecord(T data) {
this.record = data; this.record = data;
return this; return this;
} }
......
...@@ -70,7 +70,6 @@ Slashdot allowed tags taken from "Reply" page: ...@@ -70,7 +70,6 @@ Slashdot allowed tags taken from "Reply" page:
<attribute name="href" onInvalid="filterTag"> <attribute name="href" onInvalid="filterTag">
<regexp-list> <regexp-list>
<regexp name="onsiteURL"/> <regexp name="onsiteURL"/>
<regexp name="offsiteURL"/>
</regexp-list> </regexp-list>
</attribute> </attribute>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment