Commit b0cd12b9 authored by 赵啸非's avatar 赵啸非

历久设备展示

parent 3fdaabf0
...@@ -2,6 +2,7 @@ package com.mortals.xhx.base.framework.interceptor; ...@@ -2,6 +2,7 @@ package com.mortals.xhx.base.framework.interceptor;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth; import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.framework.service.IAuthTokenService; import com.mortals.framework.service.IAuthTokenService;
import com.mortals.framework.service.IUser; import com.mortals.framework.service.IUser;
import com.mortals.framework.util.AESUtil; import com.mortals.framework.util.AESUtil;
...@@ -19,6 +20,9 @@ import javax.servlet.http.HttpServletRequest; ...@@ -19,6 +20,9 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import static com.mortals.xhx.common.key.ErrorCode.*;
import static com.mortals.xhx.common.key.ErrorCode.ERROR_USER_OPERATION_CONTENT;
/** /**
* 用户权限验证,基于token * 用户权限验证,基于token
* *
...@@ -59,23 +63,23 @@ public class AuthUserInterceptor extends BaseInterceptor { ...@@ -59,23 +63,23 @@ public class AuthUserInterceptor extends BaseInterceptor {
//需要校验权限 //需要校验权限
boolean auth = this.checkAuth(request, uri, config.getSecurityKey()); boolean auth = this.checkAuth(request, uri, config.getSecurityKey());
if (!auth) { if (!auth) {
//校验token不正常
String token = authTokenService.getToken(request);
if(ObjectUtils.isEmpty(token)){
ServletUtils.renderString(response, JSONObject.toJSONString(Rest.fail(ERROR_TOKEN_UNAUTHORIZED, ERROR_TOKEN_UNAUTHORIZED_CONTENT)));
return false;
}
//不存在时候 如果是管理员也不做拦截 //不存在时候 如果是管理员也不做拦截
IUser loginUser = authTokenService.getLoginUser(request); IUser loginUser = authTokenService.getLoginUser(request);
//loginUser.isManager() if (ObjectUtils.isEmpty(loginUser)) {
if(ObjectUtils.isEmpty(loginUser)){ ServletUtils.renderString(response, JSONObject.toJSONString(Rest.fail(ERROR_TOKEN_EXPIRED, ERROR_TOKEN_EXPIRED_CONTENT)));
ret.put("code", -1);
ret.put("msg", "用户未登录或登录失效,请重新登录");
ServletUtils.renderString(response, JSONObject.toJSONString(ret));
return false; return false;
}else if(loginUser.isAdmin()||loginUser.getUserType()==1){ } else if (loginUser.isAdmin() || loginUser.getUserType() == 1) {
return super.preHandle(request, response, handler); return super.preHandle(request, response, handler);
} else { } else {
ret.put("code", -1); ServletUtils.renderString(response, JSONObject.toJSONString(Rest.fail(ERROR_USER_OPERATION, ERROR_USER_OPERATION_CONTENT)));
ret.put("msg", "用户无该操作权限!");
ServletUtils.renderString(response, JSONObject.toJSONString(ret));
return false; return false;
} }
} }
} }
} catch (Exception e) { } catch (Exception e) {
......
...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.ap.CookieService; import com.mortals.framework.ap.CookieService;
import com.mortals.framework.ap.GlobalSysInfo; import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.ap.SysConstains; import com.mortals.framework.ap.SysConstains;
import com.mortals.framework.common.Rest;
import com.mortals.framework.service.IAuthTokenService; import com.mortals.framework.service.IAuthTokenService;
import com.mortals.framework.service.ICacheService; import com.mortals.framework.service.ICacheService;
import com.mortals.framework.service.IUser; import com.mortals.framework.service.IUser;
...@@ -34,6 +35,9 @@ import javax.servlet.http.HttpServletResponse; ...@@ -34,6 +35,9 @@ import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import static com.mortals.xhx.common.key.ErrorCode.ERROR_TOKEN_EXPIRED;
import static com.mortals.xhx.common.key.ErrorCode.ERROR_TOKEN_EXPIRED_CONTENT;
@RestController @RestController
@Slf4j @Slf4j
@RequestMapping("login") @RequestMapping("login")
...@@ -139,7 +143,7 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi ...@@ -139,7 +143,7 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
JSONObject ret = new JSONObject(); JSONObject ret = new JSONObject();
IUser user = this.getCurUser(); IUser user = this.getCurUser();
if (user == null) { if (user == null) {
return ""; return JSONObject.toJSONString(Rest.fail(ERROR_TOKEN_EXPIRED, ERROR_TOKEN_EXPIRED_CONTENT));
} }
Set<String> urls = resourceService.findUrlSetByUserId(user.getId()); Set<String> urls = resourceService.findUrlSetByUserId(user.getId());
List<MenuEntity> outlookBarList = menuService.findTreeMenu(user, urls); List<MenuEntity> outlookBarList = menuService.findTreeMenu(user, urls);
......
...@@ -33,7 +33,6 @@ public interface ErrorCode { ...@@ -33,7 +33,6 @@ public interface ErrorCode {
public static final String ERROR_TOKEN_EXPIRED = "登陆过期,请重新登录";
public static final String ERROR_TRADE_PWD_OVER_THREE_TIME = "支付密码错误,请15分钟后再试"; public static final String ERROR_TRADE_PWD_OVER_THREE_TIME = "支付密码错误,请15分钟后再试";
public static final String ERROR_TRADE_PWD_ERROR = "支付密码错误,请重试"; public static final String ERROR_TRADE_PWD_ERROR = "支付密码错误,请重试";
public static final String ERROR_EMPTY_PWD_ERROR = "请设置登录密码"; public static final String ERROR_EMPTY_PWD_ERROR = "请设置登录密码";
...@@ -111,4 +110,13 @@ public interface ErrorCode { ...@@ -111,4 +110,13 @@ public interface ErrorCode {
public static final int TOKEN_AUTH_FAIL = 1010; public static final int TOKEN_AUTH_FAIL = 1010;
public static final String TOKEN_AUTH_FAIL_CONTENT = "token认证失败!"; public static final String TOKEN_AUTH_FAIL_CONTENT = "token认证失败!";
public static final int ERROR_TOKEN_EXPIRED = 9001;
public static final String ERROR_TOKEN_EXPIRED_CONTENT = "用户登录过期,请重新登录!";
public static final int ERROR_TOKEN_UNAUTHORIZED = 9002;
public static final String ERROR_TOKEN_UNAUTHORIZED_CONTENT = "token不正确或已过期";
public static final int ERROR_USER_OPERATION = 9009;
public static final String ERROR_USER_OPERATION_CONTENT = "用户无该操作权限!";
} }
...@@ -202,7 +202,9 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe ...@@ -202,7 +202,9 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
protected int doListAfter(DeviceEntity query, Map<String, Object> model, Context context) throws AppException { protected int doListAfter(DeviceEntity query, Map<String, Object> model, Context context) throws AppException {
//统计当前站点设备情况 //统计当前站点设备情况
if (!ObjectUtils.isEmpty(query.getSiteId())) { if (!ObjectUtils.isEmpty(query.getSiteId())) {
List<DeviceEntity> deviceEntityList = this.service.find(query, context); DeviceQuery deviceQuery = new DeviceQuery();
deviceQuery.setSiteId(query.getSiteId());
List<DeviceEntity> deviceEntityList = this.service.find(deviceQuery, context);
if (!ObjectUtils.isEmpty(deviceEntityList)) { if (!ObjectUtils.isEmpty(deviceEntityList)) {
model.put("totalCount", deviceEntityList.size()); model.put("totalCount", deviceEntityList.size());
model.put("onlineCount", deviceEntityList.stream().filter(f -> f.getDeviceStatus() == DeviceStatusEnum.在线.getValue()).count()); model.put("onlineCount", deviceEntityList.stream().filter(f -> f.getDeviceStatus() == DeviceStatusEnum.在线.getValue()).count());
......
...@@ -131,7 +131,7 @@ public class SitestatServiceImpl extends AbstractCRUDServiceImpl<SitestatDao, Si ...@@ -131,7 +131,7 @@ public class SitestatServiceImpl extends AbstractCRUDServiceImpl<SitestatDao, Si
// String token = context.getUser().getToken(); // String token = context.getUser().getToken();
String resp = siteFeign.siteTree(token); String resp = siteFeign.siteTree(token);
//log.info("treeResp:"+resp); log.info("treeResp:"+resp);
return resp; return resp;
} }
...@@ -145,7 +145,7 @@ public class SitestatServiceImpl extends AbstractCRUDServiceImpl<SitestatDao, Si ...@@ -145,7 +145,7 @@ public class SitestatServiceImpl extends AbstractCRUDServiceImpl<SitestatDao, Si
Long onlineCount = deviceList.stream().filter(f -> f.getDeviceStatus() == DeviceStatusEnum.在线.getValue()).count(); Long onlineCount = deviceList.stream().filter(f -> f.getDeviceStatus() == DeviceStatusEnum.在线.getValue()).count();
Long offlineCount = deviceList.stream().filter(f -> f.getDeviceStatus() == DeviceStatusEnum.离线.getValue()).count(); Long offlineCount = deviceList.stream().filter(f -> f.getDeviceStatus() == DeviceStatusEnum.离线.getValue()).count();
Long unActiveCount = deviceList.stream().filter(f -> f.getDeviceStatus() == DeviceStatusEnum.未激活.getValue()).count(); Long unActiveCount = deviceList.stream().filter(f -> f.getDeviceStatus() == DeviceStatusEnum.未激活.getValue()).count();
Long stopCount = deviceList.stream().filter(f -> f.getEnabled() == YesNoEnum.YES.getValue()).count(); Long stopCount = deviceList.stream().filter(f -> f.getEnabled() == YesNoEnum.NO.getValue()).count();
entity.setOnlineCount(onlineCount.intValue()); entity.setOnlineCount(onlineCount.intValue());
entity.setOfflineCount(offlineCount.intValue()); entity.setOfflineCount(offlineCount.intValue());
......
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