|
|
@ -14,6 +14,7 @@ import com.ccsens.tall.bean.po.*; |
|
|
|
import com.ccsens.tall.bean.vo.UserVo; |
|
|
|
import com.ccsens.tall.exception.SmsException; |
|
|
|
import com.ccsens.tall.persist.dao.*; |
|
|
|
import com.ccsens.tall.util.TallConstant; |
|
|
|
import com.ccsens.util.*; |
|
|
|
import com.ccsens.util.bean.wx.po.WxOauth2UserInfo; |
|
|
|
import com.ccsens.util.enterprisewx.WeiXinConstant; |
|
|
@ -201,15 +202,15 @@ public class UserService implements IUserService { |
|
|
|
theAuth.setIdentifier(wxOauth2UserInfo.getOpenId()); |
|
|
|
theAuth.setCredential(wxOauth2UserInfo.getUnionId()); |
|
|
|
authDao.insertSelective(theAuth); |
|
|
|
//自动添加账号密码
|
|
|
|
String accountName = RandomStringUtils.random(8, WebConstant.RANDOM_STR); |
|
|
|
SysAuth accountAuth = new SysAuth(); |
|
|
|
accountAuth.setId(snowflake.nextId()); |
|
|
|
accountAuth.setUserId(user.getId()); |
|
|
|
accountAuth.setIdentifyType((byte) WebConstant.IDENTIFY_TYPE.Account.value); |
|
|
|
accountAuth.setIdentifier("USER_" + accountName); |
|
|
|
accountAuth.setCredential("123456"); |
|
|
|
authDao.insertSelective(accountAuth); |
|
|
|
// //自动添加账号密码
|
|
|
|
// String accountName = RandomStringUtils.random(8, WebConstant.RANDOM_STR);
|
|
|
|
// SysAuth accountAuth = new SysAuth();
|
|
|
|
// accountAuth.setId(snowflake.nextId());
|
|
|
|
// accountAuth.setUserId(user.getId());
|
|
|
|
// accountAuth.setIdentifyType((byte) WebConstant.IDENTIFY_TYPE.Account.value);
|
|
|
|
// accountAuth.setIdentifier("USER_" + accountName);
|
|
|
|
// accountAuth.setCredential("123456");
|
|
|
|
// authDao.insertSelective(accountAuth);
|
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
@ -281,17 +282,17 @@ public class UserService implements IUserService { |
|
|
|
theAuth.setIdentifier(wxOauth2UserInfo.getOpenId()); |
|
|
|
theAuth.setCredential(wxOauth2UserInfo.getUnionId()); |
|
|
|
authDao.insertSelective(theAuth); |
|
|
|
//自动添加账号密码
|
|
|
|
String accountName = RandomStringUtils.random(8, WebConstant.RANDOM_STR); |
|
|
|
SysAuth accountAuth = new SysAuth(); |
|
|
|
accountAuth.setId(snowflake.nextId()); |
|
|
|
accountAuth.setUserId(user.getId()); |
|
|
|
accountAuth.setIdentifyType((byte) WebConstant.IDENTIFY_TYPE.Account.value); |
|
|
|
accountAuth.setIdentifier("USER_" + accountName); |
|
|
|
accountAuth.setSalt(ShiroKit.getRandomSalt(6)); |
|
|
|
accountAuth.setCredential(ShiroKit.md5("123456", accountAuth.getSalt())); |
|
|
|
authDao.insertSelective(accountAuth); |
|
|
|
log.info("新建用户:{},新建auth:{}", user,theAuth); |
|
|
|
// //自动添加账号密码
|
|
|
|
// String accountName = RandomStringUtils.random(8, WebConstant.RANDOM_STR);
|
|
|
|
// SysAuth accountAuth = new SysAuth();
|
|
|
|
// accountAuth.setId(snowflake.nextId());
|
|
|
|
// accountAuth.setUserId(user.getId());
|
|
|
|
// accountAuth.setIdentifyType((byte) WebConstant.IDENTIFY_TYPE.Account.value);
|
|
|
|
// accountAuth.setIdentifier("USER_" + accountName);
|
|
|
|
// accountAuth.setSalt(ShiroKit.getRandomSalt(6));
|
|
|
|
// accountAuth.setCredential(ShiroKit.md5("123456", accountAuth.getSalt()));
|
|
|
|
// authDao.insertSelective(accountAuth);
|
|
|
|
// log.info("新建用户:{},新建auth:{}", user,theAuth);
|
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
@ -408,14 +409,21 @@ public class UserService implements IUserService { |
|
|
|
private UserVo.UserSign getUserSign(String openId, String unionId, |
|
|
|
byte identifyType, String redirect) { |
|
|
|
UserVo.UserSign userSignVo; |
|
|
|
List<SysAuth> authList = null; |
|
|
|
SysAuth theAuth = null; |
|
|
|
if (ObjectUtil.isNotNull(openId)) { |
|
|
|
SysAuthExample authExample = new SysAuthExample(); |
|
|
|
authExample.createCriteria().andIdentifyTypeEqualTo(identifyType) |
|
|
|
.andIdentifierEqualTo(openId); |
|
|
|
authList = authDao.selectByExample(authExample); |
|
|
|
List<SysAuth> authList; |
|
|
|
SysAuth theAuth; |
|
|
|
if (ObjectUtil.isNull(openId)) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
String key = openId + TallConstant.LOGIN + identifyType; |
|
|
|
Object o = redisUtil.get(key); |
|
|
|
if(ObjectUtil.isNotNull(o)){ |
|
|
|
return (UserVo.UserSign)o; |
|
|
|
} |
|
|
|
|
|
|
|
SysAuthExample authExample = new SysAuthExample(); |
|
|
|
authExample.createCriteria().andIdentifierEqualTo(openId).andIdentifyTypeEqualTo(identifyType); |
|
|
|
authList = authDao.selectByExample(authExample); |
|
|
|
|
|
|
|
if (CollectionUtil.isEmpty(authList)) { |
|
|
|
List<SysAuth> sysAuthList = null; |
|
|
|
if (ObjectUtil.isNotNull(unionId) && identifyType == WebConstant.IDENTIFY_TYPE.Wxmp.value) { |
|
|
@ -448,16 +456,16 @@ public class UserService implements IUserService { |
|
|
|
theAuth.setIdentifier(openId); |
|
|
|
theAuth.setCredential(unionId); |
|
|
|
authDao.insertSelective(theAuth); |
|
|
|
//自动添加账号密码
|
|
|
|
String accountName = RandomStringUtils.random(8, WebConstant.RANDOM_STR); |
|
|
|
SysAuth accountAuth = new SysAuth(); |
|
|
|
accountAuth.setId(snowflake.nextId()); |
|
|
|
accountAuth.setUserId(user.getId()); |
|
|
|
accountAuth.setIdentifyType((byte) WebConstant.IDENTIFY_TYPE.Account.value); |
|
|
|
accountAuth.setIdentifier("USER_" + accountName); |
|
|
|
accountAuth.setSalt(ShiroKit.getRandomSalt(6)); |
|
|
|
accountAuth.setCredential(ShiroKit.md5("123456", accountAuth.getSalt())); |
|
|
|
authDao.insertSelective(accountAuth); |
|
|
|
// //自动添加账号密码
|
|
|
|
// String accountName = RandomStringUtils.random(8, WebConstant.RANDOM_STR);
|
|
|
|
// SysAuth accountAuth = new SysAuth();
|
|
|
|
// accountAuth.setId(snowflake.nextId());
|
|
|
|
// accountAuth.setUserId(user.getId());
|
|
|
|
// accountAuth.setIdentifyType((byte) WebConstant.IDENTIFY_TYPE.Account.value);
|
|
|
|
// accountAuth.setIdentifier("USER_" + accountName);
|
|
|
|
// accountAuth.setSalt(ShiroKit.getRandomSalt(6));
|
|
|
|
// accountAuth.setCredential(ShiroKit.md5("123456", accountAuth.getSalt()));
|
|
|
|
// authDao.insertSelective(accountAuth);
|
|
|
|
} |
|
|
|
// theAuth = wxRegist(openid, unionId,WebConstant.IDENTIFY_TYPE.Wxmp);
|
|
|
|
} else { |
|
|
@ -468,6 +476,8 @@ public class UserService implements IUserService { |
|
|
|
userSignVo = new UserVo.UserSign(); |
|
|
|
userSignVo.setUserId(theAuth.getUserId()); |
|
|
|
userSignVo.setAuthId(theAuth.getId()); |
|
|
|
//存入redis
|
|
|
|
redisUtil.set(key,userSignVo,TallConstant.LOGIN_TIME); |
|
|
|
return userSignVo; |
|
|
|
} |
|
|
|
|
|
|
@ -518,16 +528,16 @@ public class UserService implements IUserService { |
|
|
|
auth.setIdentifier(identifier); |
|
|
|
auth.setCredential(credential); |
|
|
|
authDao.insertSelective(auth); |
|
|
|
//自动添加账号密码
|
|
|
|
String accountName = RandomStringUtils.random(8, WebConstant.RANDOM_STR); |
|
|
|
SysAuth accountAuth = new SysAuth(); |
|
|
|
accountAuth.setId(snowflake.nextId()); |
|
|
|
accountAuth.setUserId(user.getId()); |
|
|
|
accountAuth.setIdentifyType((byte) WebConstant.IDENTIFY_TYPE.Account.value); |
|
|
|
accountAuth.setIdentifier("USER_" + accountName); |
|
|
|
accountAuth.setSalt(ShiroKit.getRandomSalt(6)); |
|
|
|
accountAuth.setCredential(ShiroKit.md5("123456", accountAuth.getSalt())); |
|
|
|
authDao.insertSelective(accountAuth); |
|
|
|
// //自动添加账号密码
|
|
|
|
// String accountName = RandomStringUtils.random(8, WebConstant.RANDOM_STR);
|
|
|
|
// SysAuth accountAuth = new SysAuth();
|
|
|
|
// accountAuth.setId(snowflake.nextId());
|
|
|
|
// accountAuth.setUserId(user.getId());
|
|
|
|
// accountAuth.setIdentifyType((byte) WebConstant.IDENTIFY_TYPE.Account.value);
|
|
|
|
// accountAuth.setIdentifier("USER_" + accountName);
|
|
|
|
// accountAuth.setSalt(ShiroKit.getRandomSalt(6));
|
|
|
|
// accountAuth.setCredential(ShiroKit.md5("123456", accountAuth.getSalt()));
|
|
|
|
// authDao.insertSelective(accountAuth);
|
|
|
|
|
|
|
|
return auth; |
|
|
|
} |
|
|
@ -1146,6 +1156,9 @@ public class UserService implements IUserService { |
|
|
|
String phone = getPhoneByRegisterType(userSignVo.getUserId(),identifyType); |
|
|
|
//获取账号
|
|
|
|
String account = selectAccountByUserId(userSignVo.getUserId()); |
|
|
|
if(StrUtil.isEmpty(account)){ |
|
|
|
account = WebConstant.DEFAULT_NICKNAME; |
|
|
|
} |
|
|
|
//获取用户的基本信息、
|
|
|
|
UserVo.WxInfo wxInfo = null; |
|
|
|
SysUser user = userDao.selectByPrimaryKey(userSignVo.getUserId()); |
|
|
|