Commit 0a6eb0e7 by wnb0128

车家智能数据服务 用户数据重复请求加锁--think.wang

1 parent c80df7ec
......@@ -17,4 +17,6 @@ public class Constants {
public final static String SCENE_CONTENT_DEVICE = "scene_content_device";
public final static int REDIS_CACHE_TIME = 3; //redis缓存时间
}
......@@ -6,6 +6,8 @@ import com.alibaba.nacos.common.utils.MD5Utils;
import com.glsx.plat.common.utils.HttpUtils;
import com.glsx.plat.common.utils.StringUtils;
import com.glsx.plat.core.web.R;
import com.glsx.plat.redis.utils.RedisUtils;
import com.glsx.smart.constant.Constants;
import com.glsx.smart.dao.entity.SmartUserRelation;
import com.glsx.smart.service.SmartUserRelationService;
import lombok.extern.slf4j.Slf4j;
......@@ -37,6 +39,9 @@ public class UserRelationController {
private String syncUser;
@Autowired
private RedisUtils redisUtils;
@Autowired
private SmartUserRelationService userRelationService;
@ResponseBody
......@@ -63,6 +68,12 @@ public class UserRelationController {
@RequestMapping(value = "/login", method = {RequestMethod.POST})
public R login(@RequestBody SmartUserRelation userRelation){
log.info("/user/login保存数据参数:{}", JSON.toJSONString(userRelation));
String key = new StringBuffer(userRelation.getPhone())
.append(userRelation.getChannel()).toString();
if(redisUtils.hasKey(key)){
return R.ok();
}
redisUtils.setex(key, key, Constants.REDIS_CACHE_TIME);
SmartUserRelation request = new SmartUserRelation();
request.setPhone(userRelation.getPhone());
request.setChannel(userRelation.getChannel()); //涂鸦
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!