Commit 3e628fa5 authored by zengtianlai3's avatar zengtianlai3

合并controller

parent 2d76ca93
package iot.sixiang.license.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import iot.sixiang.license.jwt.UserUtils;
import iot.sixiang.license.log.BusinessType;
import iot.sixiang.license.log.MyLog;
import iot.sixiang.license.model.ResResult;
import iot.sixiang.license.model.vo.AlarmVo;
import iot.sixiang.license.service.AlarmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author m33
* @since 2022-06-10
*/
@RestController
@RequestMapping("/iot_license/alarm")
@Api(value = "告警模块", tags = {"告警模块"})
public class AlarmController {
@Autowired
private AlarmService alarmService;
@ApiOperation(value = "获取告警列表接口", notes = "用于获取告警列表")
@GetMapping("list")
@MyLog(title = "获取告警列表", businessType = BusinessType.SELECT)
public ResResult getAlarmList() {
String userId = UserUtils.getLoginUserId();
int Id = Integer.valueOf(userId);
List<AlarmVo> alarmList = alarmService.getAlarmList(Id);
return ResResult.success().record(alarmList);
}
}
\ No newline at end of file
package iot.sixiang.license.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import iot.sixiang.license.jwt.UserUtils;
import iot.sixiang.license.log.BusinessType;
import iot.sixiang.license.log.MyLog;
import iot.sixiang.license.model.BaseResult;
import iot.sixiang.license.service.AlarmReadService;
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;
/**
* <p>
* 前端控制器
* </p>
*
* @author m33
* @since 2022-06-10
*/
@RestController
@RequestMapping("/iot_license/alarm_read")
@Api(value = "告警模块", tags = {"告警模块"})
public class AlarmReadController {
@Autowired
private AlarmReadService alarmReadService;
@ApiOperation(value = "告警已读接口", notes = "将告警信息状态设为已读")
@PostMapping("read")
@MyLog(title = "将告警信息状态设为已读", businessType = BusinessType.OTHER)
public BaseResult readAlarm(){
String id = UserUtils.getLoginUserId();
int userId = Integer.valueOf(id);
boolean res = alarmReadService.readAlarm(userId);
if (res) {
return BaseResult.success();
} else {
return BaseResult.fail();
}
}
}
package iot.sixiang.license.controller; package iot.sixiang.license.controller;
import com.alibaba.fastjson.JSONObject;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.DynamicParameter;
import com.github.xiaoymin.knife4j.annotations.DynamicParameters;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import iot.sixiang.license.entity.Server;
import iot.sixiang.license.forward.ForwardManager; import iot.sixiang.license.forward.ForwardManager;
import iot.sixiang.license.jwt.UserUtils;
import iot.sixiang.license.log.BusinessType; import iot.sixiang.license.log.BusinessType;
import iot.sixiang.license.log.MyLog; import iot.sixiang.license.log.MyLog;
import iot.sixiang.license.model.BaseResult;
import iot.sixiang.license.model.ResResult; import iot.sixiang.license.model.ResResult;
import iot.sixiang.license.model.SamMonitor; import iot.sixiang.license.model.SamMonitor;
import iot.sixiang.license.model.vo.AlarmVo;
import iot.sixiang.license.model.vo.ServerStatusVo; import iot.sixiang.license.model.vo.ServerStatusVo;
import iot.sixiang.license.operate.OperateManager; import iot.sixiang.license.operate.OperateManager;
import iot.sixiang.license.service.AlarmReadService;
import iot.sixiang.license.service.AlarmService;
import iot.sixiang.license.service.MonitorService; import iot.sixiang.license.service.MonitorService;
import iot.sixiang.license.service.ServerService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
@Slf4j @Slf4j
@RestController @RestController
...@@ -24,6 +37,12 @@ import java.util.List; ...@@ -24,6 +37,12 @@ import java.util.List;
@Api(value = "运维模块", tags = {"运维模块"}) @Api(value = "运维模块", tags = {"运维模块"})
public class OperateController { public class OperateController {
@Autowired
private AlarmService alarmService;
@Autowired
private AlarmReadService alarmReadService;
@Autowired
private ServerService serverService;
@Autowired @Autowired
private OperateManager operateManager; private OperateManager operateManager;
@Autowired @Autowired
...@@ -64,4 +83,129 @@ public class OperateController { ...@@ -64,4 +83,129 @@ public class OperateController {
ServerStatusVo serverStatus = forwardManager.getServerStatus(); ServerStatusVo serverStatus = forwardManager.getServerStatus();
return ResResult.success().record(serverStatus); return ResResult.success().record(serverStatus);
} }
@ApiOperation(value = "获取告警列表接口", notes = "用于获取告警列表")
@GetMapping("alarm/list")
@MyLog(title = "获取告警列表", businessType = BusinessType.SELECT)
public ResResult getAlarmList() {
String userId = UserUtils.getLoginUserId();
int Id = Integer.valueOf(userId);
List<AlarmVo> alarmList = alarmService.getAlarmList(Id);
return ResResult.success().record(alarmList);
}
@ApiOperation(value = "告警已读接口", notes = "将告警信息状态设为已读")
@PostMapping("alarm/read")
@MyLog(title = "将告警信息状态设为已读", businessType = BusinessType.OTHER)
public BaseResult readAlarm(){
String id = UserUtils.getLoginUserId();
int userId = Integer.valueOf(id);
boolean res = alarmReadService.readAlarm(userId);
if (res) {
return BaseResult.success();
} else {
return BaseResult.fail();
}
}
@ApiOperation(value = "统计sam总数接口", notes = "用于统计sam的总数和总在线数量")
@GetMapping("sam/count")
@MyLog(title = "统计sam总数", businessType = BusinessType.SELECT)
public ResResult getSamTotalCount() {
Map<String, SamMonitor> samMonitorMap = operateManager.getSamMonitorMap();
Map<String,Integer> map = new HashMap<>();
int totalSamCount = 0;
int totalOnlineCount = 0;
for (SamMonitor samMonitor: samMonitorMap.values()) {
totalSamCount += samMonitor.getSamCount();
totalOnlineCount += samMonitor.getOnlineCount();
}
map.put("totalSamCount",totalSamCount);
map.put("totalOnlineCount",totalOnlineCount);
return ResResult.success().record(map);
}
/**
* 添加server
* @param jsonObject
* @return
*/
@ApiOperation(value = "添加服务接口", notes = "用于添加服务")
@PostMapping("server/add")
@MyLog(title = "添加服务", optParam = "#{jsonObject}", businessType = BusinessType.INSERT)
@ApiOperationSupport(params = @DynamicParameters(name = "jsonObject",properties = {
@DynamicParameter(name = "serverIp",value = "服务Ip",required = true,dataTypeClass = String.class),
@DynamicParameter(name = "port",value = "端口",required = true,dataTypeClass = Integer.class)
}))
public BaseResult addServer(@RequestBody JSONObject jsonObject) {
String serverIp = jsonObject.getString("serverIp");
int port = jsonObject.getIntValue("port");
boolean res = serverService.addServer(serverIp,port);
if (res) {
return BaseResult.success();
} else {
return BaseResult.fail();
}
}
/**
* 删除server
* @param serverIp
* @return
*/
@MyLog(title = "删除服务", optParam = "#{serverIp}", businessType = BusinessType.DELETE)
@ApiOperation(value = "删除服务接口", notes = "删除服务")
@PostMapping("server/delete")
public BaseResult deleteServer(@RequestParam("serverIp") String serverIp) {
boolean res = serverService.deleteServer(serverIp);
if (res) {
return BaseResult.success();
} else {
return BaseResult.fail();
}
}
/**
* 修改server
* @param jsonObject
* @return
*/
@ApiOperation(value = "修改服务接口", notes = "修改服务")
@PostMapping("server/update")
@MyLog(title = "修改服务", optParam = "#{serverIp},#{port}", businessType = BusinessType.UPDATE)
@ApiOperationSupport(params = @DynamicParameters(name = "jsonObject",properties = {
@DynamicParameter(name = "serverIp",value = "服务Ip",required = true,dataTypeClass = String.class),
@DynamicParameter(name = "port",value = "端口",required = true,dataTypeClass = Integer.class)
}))
public BaseResult updateServer(@RequestBody JSONObject jsonObject) {
String serverIp = jsonObject.getString("serverIp");
int port = jsonObject.getInteger("port");
boolean res = serverService.updateServer(serverIp,port);
if (res) {
return BaseResult.success();
} else {
return BaseResult.fail();
}
}
/**
* 分页查询所有的server
* @param pageNo
* @param pageSize
* @return
*/
@ApiOperation(value = "获取服务列表接口", notes = "用于获取服务列表")
@GetMapping("server/list")
@MyLog(title = "获取服务列表", optParam = "#{pageNo},#{pageSize}", businessType = BusinessType.SELECT)
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNo",value = "当前在第几页", required = true,dataType = "int"),
@ApiImplicitParam(name = "pageSize",value = "每页显示多少页", required = true, dataType = "int")
})
public ResResult getServerList(@RequestParam("pageNo") int pageNo,
@RequestParam("pageSize") int pageSize) {
List<Server> records = serverService.getServerList(pageNo,pageSize);
return ResResult.success().record(records);
}
} }
package iot.sixiang.license.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import iot.sixiang.license.log.BusinessType;
import iot.sixiang.license.log.MyLog;
import iot.sixiang.license.model.ResResult;
import iot.sixiang.license.model.SamMonitor;
import iot.sixiang.license.operate.OperateManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
/**
* Created by m33 on 2022/6/10 16:43
*/
@Slf4j
@RestController
@RequestMapping("/iot_license/sam")
@Api(value = "sam管理模块", tags = {"sam管理模块"})
public class SamMapController {
@Autowired
public OperateManager operateManager;
@ApiOperation(value = "统计sam总数接口", notes = "用于统计sam的总数和总在线数量")
@GetMapping("count")
@MyLog(title = "统计sam总数", businessType = BusinessType.SELECT)
public ResResult getSamTotalCount() {
Map<String, SamMonitor> samMonitorMap = operateManager.getSamMonitorMap();
Map<String,Integer> map = new HashMap<>();
int totalSamCount = 0;
int totalOnlineCount = 0;
for (SamMonitor samMonitor: samMonitorMap.values()) {
totalSamCount += samMonitor.getSamCount();
totalOnlineCount += samMonitor.getOnlineCount();
}
map.put("totalSamCount",totalSamCount);
map.put("totalOnlineCount",totalOnlineCount);
return ResResult.success().record(map);
}
}
package iot.sixiang.license.controller;
import com.alibaba.fastjson.JSONObject;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.DynamicParameter;
import com.github.xiaoymin.knife4j.annotations.DynamicParameters;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import iot.sixiang.license.entity.Server;
import iot.sixiang.license.log.BusinessType;
import iot.sixiang.license.log.MyLog;
import iot.sixiang.license.model.BaseResult;
import iot.sixiang.license.model.ResResult;
import iot.sixiang.license.service.ServerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author m33
* @since 2022-06-06
*/
@RestController
@RequestMapping("/iot_license/server")
@Api(value = "服务模块", tags = {"服务模块"})
public class ServerController {
@Autowired
private ServerService serverService;
/**
* 添加server
* @param jsonObject
* @return
*/
@ApiOperation(value = "添加服务接口", notes = "用于添加服务")
@PostMapping("add")
@MyLog(title = "添加服务", optParam = "#{jsonObject}", businessType = BusinessType.INSERT)
@ApiOperationSupport(params = @DynamicParameters(name = "jsonObject",properties = {
@DynamicParameter(name = "serverIp",value = "服务Ip",required = true,dataTypeClass = String.class),
@DynamicParameter(name = "port",value = "端口",required = true,dataTypeClass = Integer.class)
}))
public BaseResult addServer(@RequestBody JSONObject jsonObject) {
String serverIp = jsonObject.getString("serverIp");
int port = jsonObject.getIntValue("port");
boolean res = serverService.addServer(serverIp,port);
if (res) {
return BaseResult.success();
} else {
return BaseResult.fail();
}
}
/**
* 删除server
* @param serverIp
* @return
*/
@MyLog(title = "删除服务", optParam = "#{serverIp}", businessType = BusinessType.DELETE)
@ApiOperation(value = "删除服务接口", notes = "删除服务")
@PostMapping("delete")
public BaseResult deleteServer(@RequestParam("serverIp") String serverIp) {
boolean res = serverService.deleteServer(serverIp);
if (res) {
return BaseResult.success();
} else {
return BaseResult.fail();
}
}
/**
* 修改server
* @param jsonObject
* @return
*/
@ApiOperation(value = "修改服务接口", notes = "修改服务")
@PostMapping("update")
@MyLog(title = "修改服务", optParam = "#{serverIp},#{port}", businessType = BusinessType.UPDATE)
@ApiOperationSupport(params = @DynamicParameters(name = "jsonObject",properties = {
@DynamicParameter(name = "serverIp",value = "服务Ip",required = true,dataTypeClass = String.class),
@DynamicParameter(name = "port",value = "端口",required = true,dataTypeClass = Integer.class)
}))
public BaseResult updateServer(@RequestBody JSONObject jsonObject) {
String serverIp = jsonObject.getString("serverIp");
int port = jsonObject.getInteger("port");
boolean res = serverService.updateServer(serverIp,port);
if (res) {
return BaseResult.success();
} else {
return BaseResult.fail();
}
}
/**
* 分页查询所有的server
* @param pageNo
* @param pageSize
* @return
*/
@ApiOperation(value = "获取服务列表接口", notes = "用于获取服务列表")
@GetMapping("list")
@MyLog(title = "获取服务列表", optParam = "#{pageNo},#{pageSize}", businessType = BusinessType.SELECT)
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNo",value = "当前在第几页", required = true,dataType = "int"),
@ApiImplicitParam(name = "pageSize",value = "每页显示多少页", required = true, dataType = "int")
})
public ResResult getServerList(@RequestParam("pageNo") int pageNo,
@RequestParam("pageSize") int pageSize) {
List<Server> records = serverService.getServerList(pageNo,pageSize);
return ResResult.success().record(records);
}
}
...@@ -22,7 +22,7 @@ import java.util.List; ...@@ -22,7 +22,7 @@ import java.util.List;
* Created by m33 on 2022/6/14 13:54 * Created by m33 on 2022/6/14 13:54
*/ */
@RestController @RestController
@RequestMapping("/iot_license/oper_log") @RequestMapping("/iot_license/log")
@Api(value = "日志模块", tags = {"日志模块"}) @Api(value = "日志模块", tags = {"日志模块"})
public class SysOperLogController { public class SysOperLogController {
...@@ -36,7 +36,7 @@ public class SysOperLogController { ...@@ -36,7 +36,7 @@ public class SysOperLogController {
* @return * @return
*/ */
@ApiOperation(value = "获取日志列表接口", notes = "用于获取日志列表") @ApiOperation(value = "获取日志列表接口", notes = "用于获取日志列表")
@GetMapping("list") @GetMapping("operate/list")
@MyLog(title = "获取日志列表", businessType = BusinessType.SELECT) @MyLog(title = "获取日志列表", businessType = BusinessType.SELECT)
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "pageNo",value = "当前在第几页", required = true,dataType = "int"), @ApiImplicitParam(name = "pageNo",value = "当前在第几页", required = true,dataType = "int"),
......
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