From 7f2f5ef5637a6871f4329e464eeba97eb59e94a3 Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期三, 21 八月 2019 10:45:38 +0800 Subject: [PATCH] Merge branch 'div' of ssh://193.112.35.168:29418/fanli-server into div --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java | 24 +++++++++++++++++++++--- 1 files changed, 21 insertions(+), 3 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java index 927da3c..3d49615 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java @@ -38,6 +38,7 @@ import com.yeshi.fanli.service.inter.user.UserSystemCouponService; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.StringUtil; +import com.yeshi.fanli.util.TokenUtil; import com.yeshi.fanli.vo.msg.TokenVO; @Service @@ -83,6 +84,12 @@ tokenRecordMapper.insertSelective(record); } + + @Override + public void updateByPrimaryKeySelective(TokenRecord record) { + tokenRecordMapper.updateByPrimaryKeySelective(record); + } + @Override public TokenRecord getNearByTypeAndIdentify(String type, String identify) { return tokenRecordMapper.getNearByTypeAndIdentify(type, identify); @@ -90,12 +97,19 @@ @Override public TokenVO discernToken(String token, Long uid) throws TokenRecordException { - - // TODO token 楠岃瘉 + // 瑙f瀽鍙d护 + String parseToken = TokenUtil.parseToken(token); + if (StringUtil.isNullOrEmpty(parseToken)) + throw new TokenRecordException(1, "鏈彂鐜板彛浠�"); + TokenRecord rokenRecord = tokenRecordMapper.getByToken(token); if (rokenRecord == null) throw new TokenRecordException(1, "鍙d护涓嶅瓨鍦�"); + Long uidToken = rokenRecord.getUid(); + if (uid != null && uidToken != null && uid.longValue() == uidToken.longValue()) + throw new TokenRecordException(1, "涓嶈兘鑷繁璧犻�佺粰鑷繁"); + Date now = new Date(); Date endTimeToken = rokenRecord.getEndTime(); Integer stateTtoken = rokenRecord.getState(); @@ -264,7 +278,11 @@ TokenRecord rokenRecord = tokenRecordMapper.getByToken(token); if (rokenRecord == null) throw new TokenRecordException(1, "鍙d护宸插け鏁�"); - + + Long uidToken = rokenRecord.getUid(); + if (uidToken != null && uid.longValue() == uidToken.longValue()) + throw new TokenRecordException(1, "涓嶈兘鑷繁璧犻�佺粰鑷繁"); + Date now = new Date(); Date endTimeToken = rokenRecord.getEndTime(); if (endTimeToken != null && endTimeToken.getTime() < now.getTime()) -- Gitblit v1.8.0