Commit 3268b285 authored by zengtianlai3's avatar zengtianlai3

完善响应接口

parent 3e628fa5
......@@ -76,7 +76,7 @@ public class ApplyController {
@ApiImplicitParam(name = "pageSize",value = "每页显示多少页", required = true, dataType = "int"),
@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 = "appName",required = false) String appName) {
PageInfoModel<AppVo> records = applyService.getAppList(pageNo,pageSize,appName);
......
......@@ -78,7 +78,7 @@ public class DeviceController {
@ApiImplicitParam(name = "appName",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 = "appName",required = false) String appName,
@RequestParam(value = "userName",required = false) String userName) {
......@@ -102,7 +102,7 @@ public class DeviceController {
@ApiImplicitParam(name = "appName", 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 = "appName", required = false) String appName,
@RequestParam(value = "userName", required = false) String userName) {
......
......@@ -10,6 +10,7 @@ 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.model.vo.LoginVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -46,16 +47,15 @@ public class LoginController {
@ApiImplicitParam(name = "userName",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()) {
if (dbUser.getUserName().equals(userName) && dbUser.getPassword().equals(password)) {
log.info("登录成功!生成token!");
String token = JwtUtil.createToken(dbUser);
Map<String, String> map = new HashMap<>();
map.put("authorization", token);
return ResResult.success().record(map);
LoginVo loginVo = new LoginVo();
loginVo.setAuthorization(token);
return ResResult.success().record(loginVo);
}
}
return ResResult.fail().msg("用户名或密码错误");
......
......@@ -17,6 +17,8 @@ import iot.sixiang.license.model.BaseResult;
import iot.sixiang.license.model.ResResult;
import iot.sixiang.license.model.SamMonitor;
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.operate.OperateManager;
import iot.sixiang.license.service.AlarmReadService;
......@@ -53,7 +55,7 @@ public class OperateController {
@ApiOperation(value = "服务接口", notes = "用于获取服务列表")
@GetMapping("monitor/server")
@MyLog(title = "获取服务列表", businessType = BusinessType.SELECT)
public ResResult getDeviceTypes() {
public ResResult<SamMonitor> getDeviceTypes() {
List<SamMonitor> records = operateManager.getSamMonitorList();
return ResResult.success().record(records);
......@@ -70,7 +72,7 @@ public class OperateController {
@GetMapping("monitor/qps")
@MyLog(title = "获取并发量", optParam = "#{type}", businessType = BusinessType.SELECT)
@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);
return ResResult.success().record(monitorList);
}
......@@ -79,7 +81,7 @@ public class OperateController {
@GetMapping("diagnosis/server")
@MyLog(title = "获取服务诊断信息", businessType = BusinessType.SELECT)
@ApiImplicitParam()
public ResResult getDiagnosisInfo() {
public ResResult<ServerStatusVo> getDiagnosisInfo() {
ServerStatusVo serverStatus = forwardManager.getServerStatus();
return ResResult.success().record(serverStatus);
}
......@@ -88,7 +90,7 @@ public class OperateController {
@ApiOperation(value = "获取告警列表接口", notes = "用于获取告警列表")
@GetMapping("alarm/list")
@MyLog(title = "获取告警列表", businessType = BusinessType.SELECT)
public ResResult getAlarmList() {
public ResResult<List<AlarmVo>> getAlarmList() {
String userId = UserUtils.getLoginUserId();
int Id = Integer.valueOf(userId);
List<AlarmVo> alarmList = alarmService.getAlarmList(Id);
......@@ -112,7 +114,7 @@ public class OperateController {
@ApiOperation(value = "统计sam总数接口", notes = "用于统计sam的总数和总在线数量")
@GetMapping("sam/count")
@MyLog(title = "统计sam总数", businessType = BusinessType.SELECT)
public ResResult getSamTotalCount() {
public ResResult<SamVo> getSamTotalCount() {
Map<String, SamMonitor> samMonitorMap = operateManager.getSamMonitorMap();
Map<String,Integer> map = new HashMap<>();
int totalSamCount = 0;
......@@ -121,9 +123,10 @@ public class OperateController {
totalSamCount += samMonitor.getSamCount();
totalOnlineCount += samMonitor.getOnlineCount();
}
map.put("totalSamCount",totalSamCount);
map.put("totalOnlineCount",totalOnlineCount);
return ResResult.success().record(map);
SamVo samVo = new SamVo();
samVo.setTotalOnlineCount(totalOnlineCount);
samVo.setTotalSamCount(totalSamCount);
return ResResult.success().record(samVo);
}
/**
......@@ -203,7 +206,7 @@ public class OperateController {
@ApiImplicitParam(name = "pageNo",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) {
List<Server> records = serverService.getServerList(pageNo,pageSize);
return ResResult.success().record(records);
......
......@@ -42,7 +42,7 @@ public class SysOperLogController {
@ApiImplicitParam(name = "pageNo",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) {
PageInfoModel<SysOperLog> records = sysOperLogService.getOperLogList(pageNo,pageSize);
int total = records.getTotal();
......
......@@ -118,16 +118,16 @@ public class UserController {
@ApiImplicitParam(name = "userName",value = "用户名"),
@ApiImplicitParam(name = "company",value = "公司名")
})
public PageResult getUserList(@RequestParam(value = "pageNo", defaultValue = "0") int pageNo,
@RequestParam(value = "pageSize",defaultValue = "0") int pageSize,
@RequestParam(value = "userName",required = false) String userName,
@RequestParam(value = "company",required = false) String company) {
public PageResult<UserVo> getUserList(@RequestParam(value = "pageNo", defaultValue = "0") int pageNo,
@RequestParam(value = "pageSize",defaultValue = "0") int pageSize,
@RequestParam(value = "userName",required = false) String userName,
@RequestParam(value = "company",required = false) String company) {
PageInfoModel<UserVo> records = userService.getUserList(pageNo,pageSize,userName,company);
int total = records.getTotal();
int pages = total/pageSize;//pages为总页数
int mod = total%pageSize;
if(mod!=0){
pages = pages +1;
pages = pages + 1;
}
List<UserVo> result = records.getResult();
return new PageResult(200,"查找成功",pageNo,pages,total,result);
......
......@@ -4,17 +4,17 @@ package iot.sixiang.license.model;
import lombok.Data;
@Data
public class PageResult {
public class PageResult<T> {
private int code;
private String msg;
private int pageNo;
private int pages;
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();
this.code = code;
this.msg = msg;
......
......@@ -11,10 +11,10 @@ import lombok.Data;
* @date 2022-06-08
*/
@Data
public class ResResult {
public class ResResult<T> {
private int code;
private String msg;
private Object record;
private T record;
public static ResResult success() {
ResResult respResult = new ResResult();
......@@ -40,7 +40,7 @@ public class ResResult {
return this;
}
public ResResult record(Object data){
public ResResult record(T data){
this.record = data;
return this;
}
......
package iot.sixiang.license.model.vo;
import io.swagger.annotations.ApiModelProperty;
import iot.sixiang.license.entity.Alarm;
import lombok.Data;
......@@ -10,10 +11,13 @@ import lombok.Data;
@Data
public class AlarmVo extends Alarm {
@ApiModelProperty("警告等级")
private int level;
@ApiModelProperty("警告描述")
private String levelDescribe;
@ApiModelProperty("已读标记")
private int readFlag;
}
package iot.sixiang.license.model.vo;
import io.swagger.annotations.ApiModelProperty;
import iot.sixiang.license.entity.Apply;
import lombok.Data;
......@@ -10,13 +11,18 @@ import lombok.Data;
@Data
public class AppVo extends Apply {
@ApiModelProperty("设备数量")
public int deviceCount;
@ApiModelProperty("用户名")
public String userName;
@ApiModelProperty("公司名")
public String company;
@ApiModelProperty("设备编号")
public String sn;
@ApiModelProperty("设备Id")
public int deviceId;
}
package iot.sixiang.license.model.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
public class DeviceDetailVo extends DeviceVo {
private int status;//当前状态,0 offline,1 online
private String online;//上线时间
private String offline;//下线时间
@ApiModelProperty("当前状态,0 offline,1 online")
private int status;
@ApiModelProperty("上线时间")
private String online;
@ApiModelProperty("下线时间")
private String offline;
}
package iot.sixiang.license.model.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
......@@ -12,12 +13,16 @@ public class DeviceVo implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("设备Id")
private int deviceId;
@ApiModelProperty("应用名")
private String appName;
@ApiModelProperty("用户名")
private String userName;
@ApiModelProperty("设备编号")
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;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
......@@ -9,15 +10,21 @@ import lombok.Data;
@Data
public class ResourceVo {
@ApiModelProperty("用户名")
private String userName;
@ApiModelProperty("密码")
private String password;
@ApiModelProperty("公司名")
private String company;
@ApiModelProperty("应用名")
private String appName;
@ApiModelProperty("应用key")
private String appKey;
@ApiModelProperty("设备编号")
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;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
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;
import io.swagger.annotations.ApiModelProperty;
import iot.sixiang.license.entity.User;
import lombok.Data;
......@@ -8,5 +9,7 @@ import lombok.Data;
*/
@Data
public class UserVo extends User {
@ApiModelProperty("应用数量")
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