diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/interceptor/SignInterceptor.java b/src/main/java/com/chaozhanggui/system/cashierservice/interceptor/SignInterceptor.java index c4bf560..ad1dba3 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/interceptor/SignInterceptor.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/interceptor/SignInterceptor.java @@ -30,7 +30,7 @@ public class SignInterceptor implements HandlerInterceptor { @Autowired - RedisUtils redisUtil; + RedisUtil redisUtil; @Override @@ -57,7 +57,7 @@ public class SignInterceptor implements HandlerInterceptor { String key=RedisCst.ONLINE_USER.concat(":").concat(clientType).concat(":").concat(loginName); - String cacheToken= redisUtil.get(key)+""; + String cacheToken= redisUtil.getMessage(key); if(ObjectUtil.isEmpty(cacheToken)||!cacheToken.equals(token)){ response.setContentType(CONTENT_TYPE); response.getWriter().print(JSONUtil.toJsonStr(new Result(CodeEnum.TOENNOEXIST))); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java index e79d20a..055ee57 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java @@ -12,10 +12,7 @@ import com.chaozhanggui.system.cashierservice.model.LoginReq; import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer; import com.chaozhanggui.system.cashierservice.sign.CodeEnum; import com.chaozhanggui.system.cashierservice.sign.Result; -import com.chaozhanggui.system.cashierservice.util.MD5Util; -import com.chaozhanggui.system.cashierservice.util.RedisCst; -import com.chaozhanggui.system.cashierservice.util.RedisUtils; -import com.chaozhanggui.system.cashierservice.util.TokenUtil; +import com.chaozhanggui.system.cashierservice.util.*; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -46,7 +43,7 @@ public class LoginService { TbPlussShopStaffMapper tbPlussShopStaffMapper; @Autowired - RedisUtils redisUtil; + RedisUtil redisUtil; @Autowired TbTokenMapper tbTokenMapper; @@ -77,11 +74,12 @@ public class LoginService { } String key = RedisCst.ONLINE_USER.concat(":").concat(loginReq.getClientType()).concat(":").concat(loginReq.getLoginName()); - - String data = ""+redisUtil.get(key); - if(ObjectUtil.isNotEmpty(data)){ - return Result.fail(CodeEnum.USERHAVEDLOGIN); - } +// +// String data = redisUtil.getMessage(key); +// log.info("key:{},data:{}",key,data); +// if(ObjectUtil.isNotEmpty(data)){ +// return Result.fail(CodeEnum.USERHAVEDLOGIN); +// } TbmerchantAccount account = tbmerchantAccountMapper.selectByAccount(loginReq.getMerchantName()); if (ObjectUtil.isEmpty(account)) { @@ -115,7 +113,7 @@ public class LoginService { TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(account.getShopId())); - redisUtil.set(key, token, 365 * 24 * 60 * 60); + redisUtil.saveMessage(key, token, 365 * 24 * 60 * 60); String uuid = UUID.randomUUID().toString().replaceAll("-", ""); @@ -133,7 +131,7 @@ public class LoginService { accountMap.put("shopName", shopInfo.getShopName()); } accountMap.put("uuid", uuid); - redisUtil.set("CART:UUID:" + account.getShopId().concat(account.getId().toString()), uuid); + redisUtil.saveMessage("CART:UUID:" + account.getShopId().concat(account.getId().toString()), uuid); return Result.success(CodeEnum.SUCCESS, accountMap); } @@ -143,17 +141,17 @@ public class LoginService { String key = RedisCst.ONLINE_USER.concat(":").concat(clientType).concat(":").concat(loginName); - String cacheToken = redisUtil.get(key)+""; + String cacheToken = redisUtil.getMessage(key)+""; TbToken tbToken = tbTokenMapper.selectByToken(token); if (ObjectUtil.isEmpty(tbToken)) { - redisUtil.del(key); + redisUtil.deleteByKey(key); return Result.fail(USERNOLOGIN); } if (!"1".equals(tbToken.getStatus()) || "2".equals(tbToken.getStatus()) || "3".equals(tbToken.getStatus())) { - redisUtil.del(key); + redisUtil.deleteByKey(key); return Result.fail(USERNOLOGIN); } @@ -164,7 +162,7 @@ public class LoginService { if (!cacheToken.equals(token)) { return Result.fail(TOKENTERROR); } - redisUtil.del(key); + redisUtil.deleteByKey(key); tbToken.setStatus(status); tbToken.setUpdateTime(new Date()); tbTokenMapper.updateByPrimaryKey(tbToken);