Commit c3f5d0af authored by hezhen's avatar hezhen

Merge branch 'master-customer-management' into dev

# Conflicts:
#	ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/biz/AppUserRelationBiz.java
parents 03fee680 06453fa3
......@@ -21,6 +21,10 @@ import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.github.wxiaoqi.security.admin.mapper.AppUserRelationMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import java.time.Instant;
......@@ -62,6 +66,47 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
@Autowired
private AppStaffUserBiz staffUserBiz;
private static final HashMap<Integer, Boolean> map = new HashMap<>();
private static final HashMap<Integer, Boolean> parentMap = new HashMap<>();
private static final Object obj = new Object();
private static final Object parentObj = new Object();
private boolean lock(Integer userId) {
synchronized (obj) {
if (map.get(userId) == null) {
map.put(userId, true);
return true;
}
}
return false;
}
private boolean parentLock(Integer userId) {
log.info("---进锁前---parentId===="+userId);
synchronized (parentObj) {
log.info("---进锁---parentId===="+userId);
if (parentMap.get(userId) == null) {
log.info("---进锁处理---parentId===="+userId);
parentMap.put(userId, true);
return true;
}
}
return false;
}
private void unParentLock(Integer userId) {
log.info("---解锁处理---parentId===="+userId);
synchronized (parentObj) {
parentMap.remove(userId);
}
}
private void unLock(Integer userId) {
synchronized (obj) {
map.remove(userId);
}
}
/**
* 关系绑定
* 规则A->B (B无有效上线+无有效下线)
......@@ -69,6 +114,7 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
* @param userId
* @param parentId
*/
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public void bindRelation(Integer userId,Integer parentId,Integer type){
try {
if (userId.equals(parentId)){
......
......@@ -393,16 +393,50 @@ public class AppPermissionService {
}
/*public void test(){
public void test(){
Example example=new Example(AppUserLogin.class);
example.createCriteria().andEqualTo("imUserid",0);
List<AppUserLogin> list=appUserLoginBiz.selectByExample(example);
for (AppUserLogin userLogin:list){
for (AppUserLogin userLogin:list) {
Long now = System.currentTimeMillis() / 1000;
Integer userId = userLogin.getId();
String username = userLogin.getUsername();
String ip = getIp();
String nickname = SystemConfig.USER_NIKENAME_DEFAULT + (int) ((Math.random() * 9 + 1) * 100000);
AppUserDetail rsUserDetail = new AppUserDetail();
rsUserDetail.setUserid(userId);
rsUserDetail = appUserDetailBiz.selectOne(rsUserDetail);
if (rsUserDetail == null) {
rsUserDetail.setUserid(userId);
rsUserDetail.setNickname(nickname);
rsUserDetail.setHeadimgurl(SystemConfig.USER_HEADER_URL_DEFAULT); // 默认路径,待写
rsUserDetail.setCreatetime(now);
rsUserDetail.setUpdatetime(now);
rsUserDetail.setIsdel(0);
rsUserDetail.setCrtHost(ip);
//生成邀请码 长度改为8 不然重复率太高
rsUserDetail.setCode(ReferralCodeUtil.encode(userId));
appUserDetailBiz.insertSelective(rsUserDetail);
} else {
nickname=rsUserDetail.getNickname();
}
Map<String, Object> map = registerIm(userLogin.getUsername(), userLogin.getPassword(), nickname);
if (map != null) {
Integer imUserId = Integer.parseInt(map.get("userId").toString());
String imPassword = map.get("password").toString();
if (imUserId != null && imUserId > 0 && StringUtils.isNotBlank(imPassword)) {
AppUserLogin userLogin1 = new AppUserLogin();
userLogin1.setId(userId);
userLogin1.setImPassword(imPassword);
userLogin1.setImUserid(imUserId);
userLogin1.setUsername(username);
appUserLoginBiz.updateSelectiveById(userLogin1);
log.info(username + "----userLogin updateSelectiveById---username=====" + username + "----imPassword====" + imPassword);
}
}
}
}*/
}
private void sendQueue(String username, String password, String headimgurl, String nickname, String mobilecode, String openId, String unionid, Integer type, String code, String activityCode, Integer userid,Integer sign) {
try {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment