REM:
1. 整理代码,修正部分语法问题
This commit is contained in:
HuangXin 2020-08-06 17:13:42 +08:00
parent 1ddccea891
commit 06540102f4
6 changed files with 37 additions and 46 deletions

View File

@ -56,10 +56,9 @@ public class PrivacyHelper {
return username; return username;
} }
if(username.length() < 8) { int showChars = Math.min(8, username.length() / 2 + 1);
return username.substring(0, username.length() / 2) + "****"; showChars = Math.min(username.length(), showChars);
} else {
return username.substring(0, 7) + "****"; return username.substring(0, showChars) + "****";
}
} }
} }

View File

@ -6,7 +6,6 @@ import com.dispose.pojo.entity.DisposeDevice;
import com.dispose.pojo.po.MulReturnType; import com.dispose.pojo.po.MulReturnType;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import java.lang.reflect.InvocationTargetException;
import java.util.List; import java.util.List;
/** /**
@ -20,24 +19,16 @@ public interface DisposeDeviceManager {
* *
* @param dev the dev * @param dev the dev
* @return the mul return type * @return the mul return type
* @throws IllegalAccessException the illegal access exception
* @throws NoSuchMethodException the no such method exception
* @throws InvocationTargetException the invocation target exception
*/ */
MulReturnType<ErrorCode, Long> addDisposeDevice(DisposeDevice dev) throws IllegalAccessException, MulReturnType<ErrorCode, Long> addDisposeDevice(DisposeDevice dev);
NoSuchMethodException, InvocationTargetException;
/** /**
* Upgrade dispose device mul return type. * Upgrade dispose device mul return type.
* *
* @param dev the dev * @param dev the dev
* @return the mul return type * @return the mul return type
* @throws IllegalAccessException the illegal access exception
* @throws NoSuchMethodException the no such method exception
* @throws InvocationTargetException the invocation target exception
*/ */
MulReturnType<ErrorCode, Long> upgradeDisposeDevice(DisposeDevice dev) throws IllegalAccessException, NoSuchMethodException, MulReturnType<ErrorCode, Long> upgradeDisposeDevice(DisposeDevice dev);
InvocationTargetException;
/** /**
* Change dispose device status mul return type. * Change dispose device status mul return type.

View File

@ -415,33 +415,31 @@ public class UserAccountManagerImpl implements UserAccountManager {
// 本机曾经登录过 // 本机曾经登录过
if (userAccountCache.containsKey(token)) { if (userAccountCache.containsKey(token)) {
user = userAccountCache.get(token); user = userAccountCache.get(token);
// 超时
if(tokenTimeout(user.getLastAccess())) {
return ErrorCode.ERR_TOKENTIMEOUT;
}
return ErrorCode.ERR_OK;
} else { } else {
user = userAccountMapper.getUserByToken(token); user = userAccountMapper.getUserByToken(token);
// 用户未登录或者已经注销 // 用户未登录或者已经注销
if(user == null) { if (user == null) {
return ErrorCode.ERR_LOGOUT; return ErrorCode.ERR_LOGOUT;
} }
// 用户未登录或者已经注销 // 用户未登录或者已经注销
if(user.getToken().length() == 0) { if (user.getToken().length() == 0) {
return ErrorCode.ERR_LOGOUT; return ErrorCode.ERR_LOGOUT;
} }
if(tokenTimeout(user.getLastAccess())) {
return ErrorCode.ERR_TOKENTIMEOUT;
}
return ErrorCode.ERR_OK;
} }
// 检测用户名是否匹配
if(!user.getUsername().equals(username)) {
return ErrorCode.ERR_USERNOTFOUND;
}
// 超时
if (tokenTimeout(user.getLastAccess())) {
return ErrorCode.ERR_TOKENTIMEOUT;
}
return ErrorCode.ERR_OK;
} }
/** /**

View File

@ -60,7 +60,7 @@ public class ProtocolRespDTO<T> extends BaseProtocolDTO<T> {
resp.setVer(ConstValue.Protocol.VERSION); resp.setVer(ConstValue.Protocol.VERSION);
resp.setCode(err.getHttpCode()); resp.setCode(err.getHttpCode());
resp.setCryptoType(ProtoCryptoType.CRYPTO_NONE.getCode()); resp.setCryptoType(crypto);
resp.setTimeStamp(System.currentTimeMillis()); resp.setTimeStamp(System.currentTimeMillis());
resp.setMsgContent(respMsg); resp.setMsgContent(respMsg);

View File

@ -1,17 +1,17 @@
package com.dispose.pojo.dto.protocol.base; package com.dispose.pojo.dto.protocol.base;
/** /**
* The type Valid groups. * The interface Valid groups.
* *
* @author <huangxin@cmhi.chinamoblie.com> * @author <huangxin@cmhi.chinamoblie.com>
*/ */
public class ValidGroups { public interface ValidGroups {
/** /**
* The interface Protocol common valid. * The interface Protocol common valid.
* *
* @author <huangxin@cmhi.chinamoblie.com> * @author <huangxin@cmhi.chinamoblie.com>
*/ */
public interface ProtocolCommonValid { interface ProtocolCommonValid {
} }
/** /**
@ -19,7 +19,7 @@ public class ValidGroups {
* *
* @author <huangxin@cmhi.chinamoblie.com> * @author <huangxin@cmhi.chinamoblie.com>
*/ */
public interface LoginReqValid extends LogoutReqValid { interface LoginReqValid extends LogoutReqValid {
} }
/** /**
@ -27,10 +27,15 @@ public class ValidGroups {
* *
* @author <huangxin@cmhi.chinamoblie.com> * @author <huangxin@cmhi.chinamoblie.com>
*/ */
public interface LogoutReqValid extends ProtocolCommonValid { interface LogoutReqValid extends ProtocolCommonValid {
} }
public interface UpgradeDeviceValid extends ProtocolCommonValid { /**
* The interface Upgrade device valid.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
interface UpgradeDeviceValid extends ProtocolCommonValid {
} }
/** /**
@ -38,7 +43,7 @@ public class ValidGroups {
* *
* @author <huangxin@cmhi.chinamoblie.com> * @author <huangxin@cmhi.chinamoblie.com>
*/ */
public interface AddDeviceValid extends UpgradeDeviceValid { interface AddDeviceValid extends UpgradeDeviceValid {
} }
/** /**
@ -46,7 +51,7 @@ public class ValidGroups {
* *
* @author <huangxin@cmhi.chinamoblie.com> * @author <huangxin@cmhi.chinamoblie.com>
*/ */
public interface IdArrayValid extends ProtocolCommonValid { interface IdArrayValid extends ProtocolCommonValid {
} }
/** /**
@ -54,6 +59,6 @@ public class ValidGroups {
* *
* @author <huangxin@cmhi.chinamoblie.com> * @author <huangxin@cmhi.chinamoblie.com>
*/ */
public interface ExplicitIdArrayValid extends IdArrayValid{ interface ExplicitIdArrayValid extends IdArrayValid {
} }
} }

View File

@ -11,7 +11,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -45,7 +44,7 @@ public class DisposeDeviceManagerServiceImpl implements DisposeDeviceManagerServ
MulReturnType<ErrorCode, Long> ret = disposeDeviceManager.addDisposeDevice(v); MulReturnType<ErrorCode, Long> ret = disposeDeviceManager.addDisposeDevice(v);
v.setId(ret.getSecondParam()); v.setId(ret.getSecondParam());
rspList.add(new MulReturnType<>(ret.getFirstParam(), v)); rspList.add(new MulReturnType<>(ret.getFirstParam(), v));
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { } catch (Exception e) {
rspList.add(new MulReturnType<>(ErrorCode.ERR_SYSTEMEXCEPTION, v)); rspList.add(new MulReturnType<>(ErrorCode.ERR_SYSTEMEXCEPTION, v));
} }
}); });
@ -68,7 +67,7 @@ public class DisposeDeviceManagerServiceImpl implements DisposeDeviceManagerServ
MulReturnType<ErrorCode, Long> ret = disposeDeviceManager.upgradeDisposeDevice(v); MulReturnType<ErrorCode, Long> ret = disposeDeviceManager.upgradeDisposeDevice(v);
v.setId(ret.getSecondParam()); v.setId(ret.getSecondParam());
rspList.add(new MulReturnType<>(ret.getFirstParam(), v)); rspList.add(new MulReturnType<>(ret.getFirstParam(), v));
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { } catch (Exception e) {
rspList.add(new MulReturnType<>(ErrorCode.ERR_SYSTEMEXCEPTION, v)); rspList.add(new MulReturnType<>(ErrorCode.ERR_SYSTEMEXCEPTION, v));
} }
}); });
@ -89,7 +88,6 @@ public class DisposeDeviceManagerServiceImpl implements DisposeDeviceManagerServ
for (Long v : ids) { for (Long v : ids) {
DisposeDevice dev = new DisposeDevice(); DisposeDevice dev = new DisposeDevice();
MulReturnType<ErrorCode, ObjectStatus> ret = disposeDeviceManager.changeDisposeDeviceStatus(v, MulReturnType<ErrorCode, ObjectStatus> ret = disposeDeviceManager.changeDisposeDeviceStatus(v,
ObjectStatus.DELETED); ObjectStatus.DELETED);