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;
}
if(username.length() < 8) {
return username.substring(0, username.length() / 2) + "****";
} else {
return username.substring(0, 7) + "****";
}
int showChars = Math.min(8, username.length() / 2 + 1);
showChars = Math.min(username.length(), showChars);
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.github.pagehelper.PageInfo;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
/**
@ -20,24 +19,16 @@ public interface DisposeDeviceManager {
*
* @param dev the dev
* @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,
NoSuchMethodException, InvocationTargetException;
MulReturnType<ErrorCode, Long> addDisposeDevice(DisposeDevice dev);
/**
* Upgrade dispose device mul return type.
*
* @param dev the dev
* @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,
InvocationTargetException;
MulReturnType<ErrorCode, Long> upgradeDisposeDevice(DisposeDevice dev);
/**
* Change dispose device status mul return type.

View File

@ -415,14 +415,6 @@ public class UserAccountManagerImpl implements UserAccountManager {
// 本机曾经登录过
if (userAccountCache.containsKey(token)) {
user = userAccountCache.get(token);
// 超时
if(tokenTimeout(user.getLastAccess())) {
return ErrorCode.ERR_TOKENTIMEOUT;
}
return ErrorCode.ERR_OK;
} else {
user = userAccountMapper.getUserByToken(token);
@ -435,14 +427,20 @@ public class UserAccountManagerImpl implements UserAccountManager {
if (user.getToken().length() == 0) {
return ErrorCode.ERR_LOGOUT;
}
}
// 检测用户名是否匹配
if(!user.getUsername().equals(username)) {
return ErrorCode.ERR_USERNOTFOUND;
}
// 超时
if (tokenTimeout(user.getLastAccess())) {
return ErrorCode.ERR_TOKENTIMEOUT;
}
return ErrorCode.ERR_OK;
}
}
/**
* Token timeout boolean.

View File

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

View File

@ -1,17 +1,17 @@
package com.dispose.pojo.dto.protocol.base;
/**
* The type Valid groups.
* The interface Valid groups.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
public class ValidGroups {
public interface ValidGroups {
/**
* The interface Protocol common valid.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
public interface ProtocolCommonValid {
interface ProtocolCommonValid {
}
/**
@ -19,7 +19,7 @@ public class ValidGroups {
*
* @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>
*/
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>
*/
public interface AddDeviceValid extends UpgradeDeviceValid {
interface AddDeviceValid extends UpgradeDeviceValid {
}
/**
@ -46,7 +51,7 @@ public class ValidGroups {
*
* @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>
*/
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 javax.annotation.Resource;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
@ -45,7 +44,7 @@ public class DisposeDeviceManagerServiceImpl implements DisposeDeviceManagerServ
MulReturnType<ErrorCode, Long> ret = disposeDeviceManager.addDisposeDevice(v);
v.setId(ret.getSecondParam());
rspList.add(new MulReturnType<>(ret.getFirstParam(), v));
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
} catch (Exception e) {
rspList.add(new MulReturnType<>(ErrorCode.ERR_SYSTEMEXCEPTION, v));
}
});
@ -68,7 +67,7 @@ public class DisposeDeviceManagerServiceImpl implements DisposeDeviceManagerServ
MulReturnType<ErrorCode, Long> ret = disposeDeviceManager.upgradeDisposeDevice(v);
v.setId(ret.getSecondParam());
rspList.add(new MulReturnType<>(ret.getFirstParam(), v));
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
} catch (Exception e) {
rspList.add(new MulReturnType<>(ErrorCode.ERR_SYSTEMEXCEPTION, v));
}
});
@ -89,7 +88,6 @@ public class DisposeDeviceManagerServiceImpl implements DisposeDeviceManagerServ
for (Long v : ids) {
DisposeDevice dev = new DisposeDevice();
MulReturnType<ErrorCode, ObjectStatus> ret = disposeDeviceManager.changeDisposeDeviceStatus(v,
ObjectStatus.DELETED);