标签:hashmap ever obj 无限 val validator inter str rem
用户表id字段为unsign int最多可存42亿的记录
// 获取他的上线sys_user_ref
int depth = 0;
int leader_uid = 0;
String leaders = "";
String leaders_reverse = "";
if(Validator.isNotNullOrEmpty(user.getRefeerUserId())) {
SysUserRefEntity leader = sysUserRefDao.queryObject(user.getRefeerUserId());
depth = leader.getDepth();
leader_uid = leader.getUid();
leaders = leader.getLeaders();
leaders_reverse = leader.getLeadersReverse();
}
/**
* lbnnbs: 如果上线操过2500层则截断
* 因为操过2500层的上线本身的leaders就是已经截断过的了,所以可以直接截断上线的leaders的最高层uid就可以
*/
if(depth > 2500) {
leaders = leaders.substring(leaders.indexOf("/") + 1);
leaders_reverse = leaders_reverse.substring(0, leaders_reverse.lastIndexOf("/", leaders_reverse.length() - 2) + 1);
}
Map<String, Object> umap = new HashMap<String, Object>();
umap.put("uid", user_id);
umap.put("depth", depth + 1);
umap.put("leaders", leaders + leader_uid + "/");
umap.put("leaders_reverse", leader_uid + "/" + leaders_reverse);
sysUserRefDao.save(umap);
标签:hashmap ever obj 无限 val validator inter str rem
原文地址:https://www.cnblogs.com/lbnnbs/p/12935037.html