Commit 27f45898 authored by zengtianlai3's avatar zengtianlai3

Merge branch 'm33' into 'master'

完善响应接口

See merge request !28
parents 3e628fa5 3268b285
...@@ -76,7 +76,7 @@ public class ApplyController { ...@@ -76,7 +76,7 @@ public class ApplyController {
@ApiImplicitParam(name = "pageSize",value = "每页显示多少页", required = true, dataType = "int"), @ApiImplicitParam(name = "pageSize",value = "每页显示多少页", required = true, dataType = "int"),
@ApiImplicitParam(name = "appName",value = "应用名") @ApiImplicitParam(name = "appName",value = "应用名")
}) })
public PageResult getUserList(@RequestParam(value = "pageNo", defaultValue = "0") int pageNo, public PageResult<AppVo> getUserList(@RequestParam(value = "pageNo", defaultValue = "0") int pageNo,
@RequestParam(value = "pageSize", defaultValue = "0") int pageSize, @RequestParam(value = "pageSize", defaultValue = "0") int pageSize,
@RequestParam(value = "appName",required = false) String appName) { @RequestParam(value = "appName",required = false) String appName) {
PageInfoModel<AppVo> records = applyService.getAppList(pageNo,pageSize,appName); PageInfoModel<AppVo> records = applyService.getAppList(pageNo,pageSize,appName);
......
...@@ -78,7 +78,7 @@ public class DeviceController { ...@@ -78,7 +78,7 @@ public class DeviceController {
@ApiImplicitParam(name = "appName",value = "应用名"), @ApiImplicitParam(name = "appName",value = "应用名"),
@ApiImplicitParam(name = "userName",value = "用户名") @ApiImplicitParam(name = "userName",value = "用户名")
}) })
public PageResult getDeviceList(@RequestParam(value = "pageNo", defaultValue = "0") int pageNo, public PageResult<DeviceVo> getDeviceList(@RequestParam(value = "pageNo", defaultValue = "0") int pageNo,
@RequestParam(value = "pageSize", defaultValue = "0") int pageSize, @RequestParam(value = "pageSize", defaultValue = "0") int pageSize,
@RequestParam(value = "appName",required = false) String appName, @RequestParam(value = "appName",required = false) String appName,
@RequestParam(value = "userName",required = false) String userName) { @RequestParam(value = "userName",required = false) String userName) {
...@@ -102,7 +102,7 @@ public class DeviceController { ...@@ -102,7 +102,7 @@ public class DeviceController {
@ApiImplicitParam(name = "appName", value = "应用名"), @ApiImplicitParam(name = "appName", value = "应用名"),
@ApiImplicitParam(name = "userName", value = "用户名") @ApiImplicitParam(name = "userName", value = "用户名")
}) })
public PageResult getDeviceDetailList(@RequestParam(value = "pageNo", defaultValue = "0") int pageNo, public PageResult<DeviceDetailVo> getDeviceDetailList(@RequestParam(value = "pageNo", defaultValue = "0") int pageNo,
@RequestParam(value = "pageSize", defaultValue = "0") int pageSize, @RequestParam(value = "pageSize", defaultValue = "0") int pageSize,
@RequestParam(value = "appName", required = false) String appName, @RequestParam(value = "appName", required = false) String appName,
@RequestParam(value = "userName", required = false) String userName) { @RequestParam(value = "userName", required = false) String userName) {
......
...@@ -10,6 +10,7 @@ import iot.sixiang.license.log.BusinessType; ...@@ -10,6 +10,7 @@ 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.BaseResult;
import iot.sixiang.license.model.ResResult; import iot.sixiang.license.model.ResResult;
import iot.sixiang.license.model.vo.LoginVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -46,16 +47,15 @@ public class LoginController { ...@@ -46,16 +47,15 @@ public class LoginController {
@ApiImplicitParam(name = "userName",value = "用户名",required = true), @ApiImplicitParam(name = "userName",value = "用户名",required = true),
@ApiImplicitParam(name = "password",value = "密码",required = true) @ApiImplicitParam(name = "password",value = "密码",required = true)
}) })
public ResResult login(@RequestParam("userName") String userName, @RequestParam("password") String password) { public ResResult<LoginVo> login(@RequestParam("userName") String userName, @RequestParam("password") String password) {
for (LoginUser dbUser : userMap.values()) { for (LoginUser dbUser : userMap.values()) {
if (dbUser.getUserName().equals(userName) && dbUser.getPassword().equals(password)) { if (dbUser.getUserName().equals(userName) && dbUser.getPassword().equals(password)) {
log.info("登录成功!生成token!"); log.info("登录成功!生成token!");
String token = JwtUtil.createToken(dbUser); String token = JwtUtil.createToken(dbUser);
Map<String, String> map = new HashMap<>(); LoginVo loginVo = new LoginVo();
map.put("authorization", token); loginVo.setAuthorization(token);
return ResResult.success().record(loginVo);
return ResResult.success().record(map);
} }
} }
return ResResult.fail().msg("用户名或密码错误"); return ResResult.fail().msg("用户名或密码错误");
......
...@@ -17,6 +17,8 @@ import iot.sixiang.license.model.BaseResult; ...@@ -17,6 +17,8 @@ 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.AlarmVo;
import iot.sixiang.license.model.vo.QpsVo;
import iot.sixiang.license.model.vo.SamVo;
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.AlarmReadService;
...@@ -53,7 +55,7 @@ public class OperateController { ...@@ -53,7 +55,7 @@ public class OperateController {
@ApiOperation(value = "服务接口", notes = "用于获取服务列表") @ApiOperation(value = "服务接口", notes = "用于获取服务列表")
@GetMapping("monitor/server") @GetMapping("monitor/server")
@MyLog(title = "获取服务列表", businessType = BusinessType.SELECT) @MyLog(title = "获取服务列表", businessType = BusinessType.SELECT)
public ResResult getDeviceTypes() { public ResResult<SamMonitor> getDeviceTypes() {
List<SamMonitor> records = operateManager.getSamMonitorList(); List<SamMonitor> records = operateManager.getSamMonitorList();
return ResResult.success().record(records); return ResResult.success().record(records);
...@@ -70,7 +72,7 @@ public class OperateController { ...@@ -70,7 +72,7 @@ public class OperateController {
@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 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().record(monitorList);
} }
...@@ -79,7 +81,7 @@ public class OperateController { ...@@ -79,7 +81,7 @@ public class OperateController {
@GetMapping("diagnosis/server") @GetMapping("diagnosis/server")
@MyLog(title = "获取服务诊断信息", businessType = BusinessType.SELECT) @MyLog(title = "获取服务诊断信息", businessType = BusinessType.SELECT)
@ApiImplicitParam() @ApiImplicitParam()
public ResResult getDiagnosisInfo() { public ResResult<ServerStatusVo> getDiagnosisInfo() {
ServerStatusVo serverStatus = forwardManager.getServerStatus(); ServerStatusVo serverStatus = forwardManager.getServerStatus();
return ResResult.success().record(serverStatus); return ResResult.success().record(serverStatus);
} }
...@@ -88,7 +90,7 @@ public class OperateController { ...@@ -88,7 +90,7 @@ public class OperateController {
@ApiOperation(value = "获取告警列表接口", notes = "用于获取告警列表") @ApiOperation(value = "获取告警列表接口", notes = "用于获取告警列表")
@GetMapping("alarm/list") @GetMapping("alarm/list")
@MyLog(title = "获取告警列表", businessType = BusinessType.SELECT) @MyLog(title = "获取告警列表", businessType = BusinessType.SELECT)
public ResResult getAlarmList() { public ResResult<List<AlarmVo>> getAlarmList() {
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);
...@@ -112,7 +114,7 @@ public class OperateController { ...@@ -112,7 +114,7 @@ public class OperateController {
@ApiOperation(value = "统计sam总数接口", notes = "用于统计sam的总数和总在线数量") @ApiOperation(value = "统计sam总数接口", notes = "用于统计sam的总数和总在线数量")
@GetMapping("sam/count") @GetMapping("sam/count")
@MyLog(title = "统计sam总数", businessType = BusinessType.SELECT) @MyLog(title = "统计sam总数", businessType = BusinessType.SELECT)
public ResResult 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;
...@@ -121,9 +123,10 @@ public class OperateController { ...@@ -121,9 +123,10 @@ public class OperateController {
totalSamCount += samMonitor.getSamCount(); totalSamCount += samMonitor.getSamCount();
totalOnlineCount += samMonitor.getOnlineCount(); totalOnlineCount += samMonitor.getOnlineCount();
} }
map.put("totalSamCount",totalSamCount); SamVo samVo = new SamVo();
map.put("totalOnlineCount",totalOnlineCount); samVo.setTotalOnlineCount(totalOnlineCount);
return ResResult.success().record(map); samVo.setTotalSamCount(totalSamCount);
return ResResult.success().record(samVo);
} }
/** /**
...@@ -203,7 +206,7 @@ public class OperateController { ...@@ -203,7 +206,7 @@ public class OperateController {
@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 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().record(records);
......
...@@ -42,7 +42,7 @@ public class SysOperLogController { ...@@ -42,7 +42,7 @@ public class SysOperLogController {
@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 PageResult getOperLogList(@RequestParam(value = "pageNo", defaultValue = "0") int pageNo, public PageResult<SysOperLog> getOperLogList(@RequestParam(value = "pageNo", defaultValue = "0") int pageNo,
@RequestParam(value = "pageSize",defaultValue = "0") int pageSize) { @RequestParam(value = "pageSize",defaultValue = "0") int pageSize) {
PageInfoModel<SysOperLog> records = sysOperLogService.getOperLogList(pageNo,pageSize); PageInfoModel<SysOperLog> records = sysOperLogService.getOperLogList(pageNo,pageSize);
int total = records.getTotal(); int total = records.getTotal();
......
...@@ -118,7 +118,7 @@ public class UserController { ...@@ -118,7 +118,7 @@ public class UserController {
@ApiImplicitParam(name = "userName",value = "用户名"), @ApiImplicitParam(name = "userName",value = "用户名"),
@ApiImplicitParam(name = "company",value = "公司名") @ApiImplicitParam(name = "company",value = "公司名")
}) })
public PageResult getUserList(@RequestParam(value = "pageNo", defaultValue = "0") int pageNo, public PageResult<UserVo> getUserList(@RequestParam(value = "pageNo", defaultValue = "0") int pageNo,
@RequestParam(value = "pageSize",defaultValue = "0") int pageSize, @RequestParam(value = "pageSize",defaultValue = "0") int pageSize,
@RequestParam(value = "userName",required = false) String userName, @RequestParam(value = "userName",required = false) String userName,
@RequestParam(value = "company",required = false) String company) { @RequestParam(value = "company",required = false) String company) {
...@@ -127,7 +127,7 @@ public class UserController { ...@@ -127,7 +127,7 @@ public class UserController {
int pages = total/pageSize;//pages为总页数 int pages = total/pageSize;//pages为总页数
int mod = total%pageSize; int mod = total%pageSize;
if(mod!=0){ if(mod!=0){
pages = pages +1; pages = pages + 1;
} }
List<UserVo> result = records.getResult(); List<UserVo> result = records.getResult();
return new PageResult(200,"查找成功",pageNo,pages,total,result); return new PageResult(200,"查找成功",pageNo,pages,total,result);
......
...@@ -4,17 +4,17 @@ package iot.sixiang.license.model; ...@@ -4,17 +4,17 @@ package iot.sixiang.license.model;
import lombok.Data; import lombok.Data;
@Data @Data
public class PageResult { public class PageResult<T> {
private int code; private int code;
private String msg; private String msg;
private int pageNo; private int pageNo;
private int pages; private int pages;
private int total; private int total;
private Object record; private T record;
public PageResult(int code, String msg, int pageNo,int pages, int total, Object record) { public PageResult(int code, String msg, int pageNo,int pages, int total, T record) {
super(); super();
this.code = code; this.code = code;
this.msg = msg; this.msg = msg;
......
...@@ -11,10 +11,10 @@ import lombok.Data; ...@@ -11,10 +11,10 @@ import lombok.Data;
* @date 2022-06-08 * @date 2022-06-08
*/ */
@Data @Data
public class ResResult { public class ResResult<T> {
private int code; private int code;
private String msg; private String msg;
private Object record; private T record;
public static ResResult success() { public static ResResult success() {
ResResult respResult = new ResResult(); ResResult respResult = new ResResult();
...@@ -40,7 +40,7 @@ public class ResResult { ...@@ -40,7 +40,7 @@ public class ResResult {
return this; return this;
} }
public ResResult record(Object data){ public ResResult record(T data){
this.record = data; this.record = data;
return this; return this;
} }
......
package iot.sixiang.license.model.vo; package iot.sixiang.license.model.vo;
import io.swagger.annotations.ApiModelProperty;
import iot.sixiang.license.entity.Alarm; import iot.sixiang.license.entity.Alarm;
import lombok.Data; import lombok.Data;
...@@ -10,10 +11,13 @@ import lombok.Data; ...@@ -10,10 +11,13 @@ import lombok.Data;
@Data @Data
public class AlarmVo extends Alarm { public class AlarmVo extends Alarm {
@ApiModelProperty("警告等级")
private int level; private int level;
@ApiModelProperty("警告描述")
private String levelDescribe; private String levelDescribe;
@ApiModelProperty("已读标记")
private int readFlag; private int readFlag;
} }
package iot.sixiang.license.model.vo; package iot.sixiang.license.model.vo;
import io.swagger.annotations.ApiModelProperty;
import iot.sixiang.license.entity.Apply; import iot.sixiang.license.entity.Apply;
import lombok.Data; import lombok.Data;
...@@ -10,13 +11,18 @@ import lombok.Data; ...@@ -10,13 +11,18 @@ import lombok.Data;
@Data @Data
public class AppVo extends Apply { public class AppVo extends Apply {
@ApiModelProperty("设备数量")
public int deviceCount; public int deviceCount;
@ApiModelProperty("用户名")
public String userName; public String userName;
@ApiModelProperty("公司名")
public String company; public String company;
@ApiModelProperty("设备编号")
public String sn; public String sn;
@ApiModelProperty("设备Id")
public int deviceId; public int deviceId;
} }
package iot.sixiang.license.model.vo; package iot.sixiang.license.model.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.Date;
@Data @Data
public class DeviceDetailVo extends DeviceVo { public class DeviceDetailVo extends DeviceVo {
private int status;//当前状态,0 offline,1 online
private String online;//上线时间 @ApiModelProperty("当前状态,0 offline,1 online")
private String offline;//下线时间 private int status;
@ApiModelProperty("上线时间")
private String online;
@ApiModelProperty("下线时间")
private String offline;
} }
package iot.sixiang.license.model.vo; package iot.sixiang.license.model.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
...@@ -12,12 +13,16 @@ public class DeviceVo implements Serializable { ...@@ -12,12 +13,16 @@ public class DeviceVo implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty("设备Id")
private int deviceId; private int deviceId;
@ApiModelProperty("应用名")
private String appName; private String appName;
@ApiModelProperty("用户名")
private String userName; private String userName;
@ApiModelProperty("设备编号")
private String sn; private String sn;
} }
package iot.sixiang.license.model.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* Created by m33 on 2022/6/14 18:51
*/
@Data
public class LoginVo {
@ApiModelProperty("token")
private String authorization;
}
package iot.sixiang.license.model.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* Created by m33 on 2022/6/14 19:02
*/
@Data
public class QpsVo {
@ApiModelProperty("x轴")
private List<Integer> x;
@ApiModelProperty("y轴")
private List<Integer> y;
}
package iot.sixiang.license.model.vo; package iot.sixiang.license.model.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
/** /**
...@@ -9,15 +10,21 @@ import lombok.Data; ...@@ -9,15 +10,21 @@ import lombok.Data;
@Data @Data
public class ResourceVo { public class ResourceVo {
@ApiModelProperty("用户名")
private String userName; private String userName;
@ApiModelProperty("密码")
private String password; private String password;
@ApiModelProperty("公司名")
private String company; private String company;
@ApiModelProperty("应用名")
private String appName; private String appName;
@ApiModelProperty("应用key")
private String appKey; private String appKey;
@ApiModelProperty("设备编号")
private String sn; private String sn;
} }
\ No newline at end of file
package iot.sixiang.license.model.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* Created by m33 on 2022/6/14 18:56
*/
@Data
public class SamVo {
@ApiModelProperty("总Sam数量")
private int totalSamCount;
@ApiModelProperty("总在线数量")
private int totalOnlineCount;
}
package iot.sixiang.license.model.vo; package iot.sixiang.license.model.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@Data @Data
public class ServerStatusVo { public class ServerStatusVo {
private int count;//服务实时工作通道数量
private int status;//诊断状态,通道数量小于100流畅,100-500正常,500以上拥挤 @ApiModelProperty("服务实时工作通道数量")
private int count;
@ApiModelProperty("诊断状态,通道数量小于100流畅,100-500正常,500以上拥挤")
private int status;
} }
package iot.sixiang.license.model.vo; package iot.sixiang.license.model.vo;
import io.swagger.annotations.ApiModelProperty;
import iot.sixiang.license.entity.User; import iot.sixiang.license.entity.User;
import lombok.Data; import lombok.Data;
...@@ -8,5 +9,7 @@ import lombok.Data; ...@@ -8,5 +9,7 @@ import lombok.Data;
*/ */
@Data @Data
public class UserVo extends User { public class UserVo extends User {
@ApiModelProperty("应用数量")
public int appCount; public int appCount;
} }
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