|
@ -34,6 +34,8 @@ import org.springframework.transaction.annotation.Propagation; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.xhtmlrenderer.css.parser.property.PrimitivePropertyBuilders; |
|
|
import org.xhtmlrenderer.css.parser.property.PrimitivePropertyBuilders; |
|
|
|
|
|
|
|
|
|
|
|
import java.security.NoSuchAlgorithmException; |
|
|
|
|
|
import java.security.spec.InvalidKeySpecException; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
import java.util.HashMap; |
|
|
import java.util.HashMap; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
@ -376,10 +378,10 @@ public class UserService implements IUserService { |
|
|
userSignVo.setUserId(theAuth.getUserId()); |
|
|
userSignVo.setUserId(theAuth.getUserId()); |
|
|
userSignVo.setAuthId(theAuth.getId()); |
|
|
userSignVo.setAuthId(theAuth.getId()); |
|
|
} else { |
|
|
} else { |
|
|
throw new BaseException("密码错误"); |
|
|
throw new BaseException(CodeEnum.PASSWORD_ERROR); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
throw new BaseException("找不到该用户"); |
|
|
throw new BaseException(CodeEnum.NOT_ACCOUNT); |
|
|
} |
|
|
} |
|
|
return userSignVo; |
|
|
return userSignVo; |
|
|
} |
|
|
} |
|
@ -508,7 +510,7 @@ public class UserService implements IUserService { |
|
|
/** |
|
|
/** |
|
|
* 微信登陆后天添加用户和认证方式 |
|
|
* 微信登陆后天添加用户和认证方式 |
|
|
* |
|
|
* |
|
|
* @return |
|
|
* @return 认证信息 |
|
|
*/ |
|
|
*/ |
|
|
private SysAuth wxRegist(String identifier, String credential, WebConstant.IDENTIFY_TYPE identifyType) { |
|
|
private SysAuth wxRegist(String identifier, String credential, WebConstant.IDENTIFY_TYPE identifyType) { |
|
|
//1.添加user
|
|
|
//1.添加user
|
|
@ -549,19 +551,19 @@ public class UserService implements IUserService { |
|
|
Long refreshTokenExpired = null; |
|
|
Long refreshTokenExpired = null; |
|
|
|
|
|
|
|
|
switch (clientType) { |
|
|
switch (clientType) { |
|
|
case Wxmp: //token(2hours) refreshToken(null)
|
|
|
case Wxmp: |
|
|
//tokenExpired = 3600 * 1000L * 2;
|
|
|
//tokenExpired = 3600 * 1000L * 2;
|
|
|
tokenExpired = 3600 * 1000L * 24; |
|
|
tokenExpired = 3600 * 1000L * 24; |
|
|
break; |
|
|
break; |
|
|
case H5: //token(2hours) refreshToken(null)
|
|
|
case H5: |
|
|
// tokenExpired = 3600 * 1000L * 2;
|
|
|
// tokenExpired = 3600 * 1000L * 2;
|
|
|
tokenExpired = 3600 * 1000L * 24; |
|
|
tokenExpired = 3600 * 1000L * 24; |
|
|
break; |
|
|
break; |
|
|
case Android: //token(2hours) refreshToken(30天)
|
|
|
case Android: |
|
|
tokenExpired = 3600 * 1000L * 2; |
|
|
tokenExpired = 3600 * 1000L * 2; |
|
|
refreshTokenExpired = 3600 * 1000L * 24 * 30; |
|
|
refreshTokenExpired = 3600 * 1000L * 24 * 30; |
|
|
break; |
|
|
break; |
|
|
case IOS: //token(2hours) refreshToken(30天)
|
|
|
case IOS: |
|
|
tokenExpired = 3600 * 1000L * 2; |
|
|
tokenExpired = 3600 * 1000L * 2; |
|
|
refreshTokenExpired = 3600 * 1000L * 24 * 30; |
|
|
refreshTokenExpired = 3600 * 1000L * 24 * 30; |
|
|
break; |
|
|
break; |
|
@ -601,7 +603,7 @@ public class UserService implements IUserService { |
|
|
* 发送验证码 |
|
|
* 发送验证码 |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public UserVo.SmsCode getSignInSmsCode(String phone, Integer client) throws Exception { |
|
|
public UserVo.SmsCode getSignInSmsCode(String phone, Integer client) { |
|
|
//获取登陆客户端类型
|
|
|
//获取登陆客户端类型
|
|
|
WebConstant.CLIENT_TYPE client_type = null; |
|
|
WebConstant.CLIENT_TYPE client_type = null; |
|
|
if (ObjectUtil.isNotNull(client)) { |
|
|
if (ObjectUtil.isNotNull(client)) { |
|
@ -809,20 +811,19 @@ public class UserService implements IUserService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public boolean tokenNotExistInCache(Long authId) throws Exception { |
|
|
public boolean tokenNotExistInCache(Long authId) { |
|
|
return !redisUtil.hasKey(RedisKeyManager.getTokenCachedKey(authId)); |
|
|
return !redisUtil.hasKey(RedisKeyManager.getTokenCachedKey(authId)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 微信绑定新手机号(没有账号,注册) |
|
|
* 微信绑定新手机号(没有账号,注册) |
|
|
* |
|
|
* |
|
|
* @param currentUserId |
|
|
* @param currentUserId userId |
|
|
* @param wxPhone |
|
|
* @param wxPhone 手机号和验证码 |
|
|
* @return |
|
|
* @return 用户id和认证类型 |
|
|
* @throws Exception |
|
|
|
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public UserVo.UserSign bindingNewPhone(Long currentUserId, UserDto.WxBindingPhone wxPhone) throws Exception { |
|
|
public UserVo.UserSign bindingNewPhone(Long currentUserId, UserDto.WxBindingPhone wxPhone) { |
|
|
if (isSmsCodeCorrect(wxPhone.getPhone(), wxPhone.getSmsCode())) { |
|
|
if (isSmsCodeCorrect(wxPhone.getPhone(), wxPhone.getSmsCode())) { |
|
|
//查找该用户以前绑定的手机
|
|
|
//查找该用户以前绑定的手机
|
|
|
SysAuthExample authExample = new SysAuthExample(); |
|
|
SysAuthExample authExample = new SysAuthExample(); |
|
@ -833,7 +834,7 @@ public class UserService implements IUserService { |
|
|
throw new BaseException(CodeEnum.ALREADY_BINDING_PHONE); |
|
|
throw new BaseException(CodeEnum.ALREADY_BINDING_PHONE); |
|
|
} else { |
|
|
} else { |
|
|
//改手机对应账户,如果有,提示
|
|
|
//改手机对应账户,如果有,提示
|
|
|
List<SysAuth> phoneList = null; |
|
|
List<SysAuth> phoneList; |
|
|
SysAuth theAuth = null; |
|
|
SysAuth theAuth = null; |
|
|
SysAuthExample phoneExample = new SysAuthExample(); |
|
|
SysAuthExample phoneExample = new SysAuthExample(); |
|
|
phoneExample.createCriteria().andIdentifyTypeEqualTo((byte) WebConstant.IDENTIFY_TYPE.Phone.value) |
|
|
phoneExample.createCriteria().andIdentifyTypeEqualTo((byte) WebConstant.IDENTIFY_TYPE.Phone.value) |
|
@ -842,7 +843,6 @@ public class UserService implements IUserService { |
|
|
if (CollectionUtil.isNotEmpty(phoneList)) { |
|
|
if (CollectionUtil.isNotEmpty(phoneList)) { |
|
|
throw new BaseException(CodeEnum.MERGE_WX_PHONE); |
|
|
throw new BaseException(CodeEnum.MERGE_WX_PHONE); |
|
|
} else { |
|
|
} else { |
|
|
// throw new BaseException(CodeEnum.NOT_REGISTER);
|
|
|
|
|
|
//绑定 添加auth
|
|
|
//绑定 添加auth
|
|
|
SysAuth auth = new SysAuth(); |
|
|
SysAuth auth = new SysAuth(); |
|
|
auth.setId(snowflake.nextId()); |
|
|
auth.setId(snowflake.nextId()); |
|
@ -920,8 +920,8 @@ public class UserService implements IUserService { |
|
|
/** |
|
|
/** |
|
|
* 判断验证码是否有效 |
|
|
* 判断验证码是否有效 |
|
|
*/ |
|
|
*/ |
|
|
private Boolean isSmsCodeCorrect(String phone, String smsCode) throws Exception { |
|
|
private Boolean isSmsCodeCorrect(String phone, String smsCode) { |
|
|
Boolean correct = false; |
|
|
boolean correct = false; |
|
|
if (redisUtil.hasKey(RedisKeyManager.getSigninSmsKey(phone))) { |
|
|
if (redisUtil.hasKey(RedisKeyManager.getSigninSmsKey(phone))) { |
|
|
if (smsCode.equals(redisUtil.get(RedisKeyManager.getSigninSmsKey(phone)).toString())) { |
|
|
if (smsCode.equals(redisUtil.get(RedisKeyManager.getSigninSmsKey(phone)).toString())) { |
|
|
correct = true; |
|
|
correct = true; |
|
@ -950,25 +950,48 @@ public class UserService implements IUserService { |
|
|
auth.setCredential(ShiroKit.md5(passwordDto.getPassword(), auth.getSalt())); |
|
|
auth.setCredential(ShiroKit.md5(passwordDto.getPassword(), auth.getSalt())); |
|
|
authDao.updateByPrimaryKeySelective(auth); |
|
|
authDao.updateByPrimaryKeySelective(auth); |
|
|
} else { |
|
|
} else { |
|
|
throw new BaseException("新密码不能和旧密码相同"); |
|
|
throw new BaseException(CodeEnum.NEW_PASSWORD_REPEAT_OLD); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
throw new BaseException("该手机号未绑定账号"); |
|
|
throw new BaseException(CodeEnum.PHONE_ERR); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
throw new BaseException("该手机号未注册"); |
|
|
throw new BaseException(CodeEnum.PHONE_ERR); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
throw new BaseException("验证信息错误"); |
|
|
throw new BaseException(CodeEnum.SMS_CODE_CORRECT); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void updatePasswordByAccount(UserDto.UpdatePasswordByAccount passwordDto) throws Exception{ |
|
|
|
|
|
if (passwordDto.getPasswordOld().equalsIgnoreCase(passwordDto.getPasswordNew())){ |
|
|
|
|
|
throw new BaseException(CodeEnum.NEW_PASSWORD_REPEAT_OLD); |
|
|
|
|
|
} |
|
|
|
|
|
//检查账号和密码是否正确
|
|
|
|
|
|
SysAuthExample authExample = new SysAuthExample(); |
|
|
|
|
|
authExample.createCriteria() |
|
|
|
|
|
.andIdentifyTypeEqualTo((byte) WebConstant.IDENTIFY_TYPE.Account.value) |
|
|
|
|
|
.andIdentifierEqualTo(passwordDto.getAccount()); |
|
|
|
|
|
List<SysAuth> authList = authDao.selectByExample(authExample); |
|
|
|
|
|
if (CollectionUtil.isEmpty(authList)) { |
|
|
|
|
|
throw new BaseException(CodeEnum.NOT_ACCOUNT); |
|
|
|
|
|
} |
|
|
|
|
|
SysAuth sysAuth = authList.get(0); |
|
|
|
|
|
if (ShiroKit.authenticate(passwordDto.getPasswordOld(), sysAuth.getCredential(), sysAuth.getSalt())) { |
|
|
|
|
|
//修改密码
|
|
|
|
|
|
sysAuth.setCredential(ShiroKit.md5(passwordDto.getPasswordNew(), sysAuth.getSalt())); |
|
|
|
|
|
authDao.updateByPrimaryKeySelective(sysAuth); |
|
|
|
|
|
} else { |
|
|
|
|
|
throw new BaseException(CodeEnum.PASSWORD_ERROR); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 通过用户查找手机号 |
|
|
* 通过用户查找手机号 |
|
|
* |
|
|
* @param userId userId |
|
|
* @param userId |
|
|
* @return 用户名 |
|
|
* @return |
|
|
|
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public String getPhone(Long userId) { |
|
|
public String getPhone(Long userId) { |
|
@ -1031,36 +1054,25 @@ public class UserService implements IUserService { |
|
|
if(ObjectUtil.isNull(role)){ |
|
|
if(ObjectUtil.isNull(role)){ |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
List<Long> userIdList = new ArrayList<>(); |
|
|
List<Long> userIdList; |
|
|
if(role.getName().equalsIgnoreCase(WebConstant.ROLE_NAME.AllMember.phase)){ |
|
|
if(role.getName().equalsIgnoreCase(WebConstant.ROLE_NAME.AllMember.phase)){ |
|
|
userIdList = memberRoleDao.selectUserIdByProjectId(role.getProjectId()); |
|
|
userIdList = memberRoleDao.selectUserIdByProjectId(role.getProjectId()); |
|
|
}else { |
|
|
}else { |
|
|
userIdList = memberRoleDao.selectUserIdByRoleId(roleId); |
|
|
userIdList = memberRoleDao.selectUserIdByRoleId(roleId); |
|
|
} |
|
|
} |
|
|
// List<Long> userIdList = new ArrayList<>();
|
|
|
|
|
|
// ProMemberRoleExample proMemberRoleExample = new ProMemberRoleExample();
|
|
|
|
|
|
// proMemberRoleExample.createCriteria().andRoleIdEqualTo(roleId);
|
|
|
|
|
|
// List<ProMemberRole> memberRoleList = memberRoleDao.selectByExample(proMemberRoleExample);
|
|
|
|
|
|
// if (CollectionUtil.isNotEmpty(memberRoleList)) {
|
|
|
|
|
|
// for (ProMemberRole memberRole : memberRoleList) {
|
|
|
|
|
|
// ProMember member = memberDao.selectByPrimaryKey(memberRole.getMemberId());
|
|
|
|
|
|
// Long userId = member.getUserId();
|
|
|
|
|
|
// userIdList.add(userId);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
return userIdList; |
|
|
return userIdList; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 查询用户是否关注此项目 |
|
|
* 查询用户是否关注此项目 |
|
|
* |
|
|
* |
|
|
* @param currentUserId |
|
|
* @param currentUserId userId |
|
|
* @param projectId |
|
|
* @param projectId 项目id |
|
|
* @return |
|
|
* @return 是否关注此项目 |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public Boolean getIsAttention(Long currentUserId, Long projectId) { |
|
|
public Boolean getIsAttention(Long currentUserId, Long projectId) { |
|
|
Boolean isAttention = false; |
|
|
boolean isAttention = false; |
|
|
if (ObjectUtil.isNotNull(sysProjectDao.selectByPrimaryKey(projectId))) { |
|
|
if (ObjectUtil.isNotNull(sysProjectDao.selectByPrimaryKey(projectId))) { |
|
|
UserAttentionExample attentionExample = new UserAttentionExample(); |
|
|
UserAttentionExample attentionExample = new UserAttentionExample(); |
|
|
attentionExample.createCriteria().andProjectIdEqualTo(projectId).andUserIdEqualTo(currentUserId); |
|
|
attentionExample.createCriteria().andProjectIdEqualTo(projectId).andUserIdEqualTo(currentUserId); |
|
@ -1077,8 +1089,8 @@ public class UserService implements IUserService { |
|
|
/** |
|
|
/** |
|
|
* 用户关注某个项目 |
|
|
* 用户关注某个项目 |
|
|
* |
|
|
* |
|
|
* @param currentUserId |
|
|
* @param currentUserId userId |
|
|
* @param projectIdDto |
|
|
* @param projectIdDto 项目id |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public void userAttentionProject(Long currentUserId, ProjectDto.ProjectIdDto projectIdDto) { |
|
|
public void userAttentionProject(Long currentUserId, ProjectDto.ProjectIdDto projectIdDto) { |
|
@ -1122,12 +1134,6 @@ public class UserService implements IUserService { |
|
|
log.info("用户已存在,直接返回user"); |
|
|
log.info("用户已存在,直接返回user"); |
|
|
return userDao.selectByPrimaryKey(authList.get(0).getUserId()).getId(); |
|
|
return userDao.selectByPrimaryKey(authList.get(0).getUserId()).getId(); |
|
|
} |
|
|
} |
|
|
// int i = 0;
|
|
|
|
|
|
// 用户已存在 = true
|
|
|
|
|
|
// boolean userExist = userService.findAccount(signup.getAccount());
|
|
|
|
|
|
// while (userExist) {
|
|
|
|
|
|
// userExist = userService.findAccount(signup.getAccount() + "_" + (++i));
|
|
|
|
|
|
// }
|
|
|
|
|
|
UserDto.UserSignup up = new UserDto.UserSignup(); |
|
|
UserDto.UserSignup up = new UserDto.UserSignup(); |
|
|
up.setAccount(signup.getAccount()); |
|
|
up.setAccount(signup.getAccount()); |
|
|
up.setPassword(WebConstant.Regist.PASSWORD); |
|
|
up.setPassword(WebConstant.Regist.PASSWORD); |
|
@ -1165,8 +1171,8 @@ public class UserService implements IUserService { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 通过userId查找账号 |
|
|
* 通过userId查找账号 |
|
|
* @param userId |
|
|
* @param userId userId |
|
|
* @return |
|
|
* @return 账号 |
|
|
*/ |
|
|
*/ |
|
|
private String selectAccountByUserId(Long userId) { |
|
|
private String selectAccountByUserId(Long userId) { |
|
|
String account = null; |
|
|
String account = null; |
|
@ -1212,9 +1218,9 @@ public class UserService implements IUserService { |
|
|
/** |
|
|
/** |
|
|
* 合并账号 |
|
|
* 合并账号 |
|
|
* |
|
|
* |
|
|
* @param currentUserId |
|
|
* @param currentUserId userId |
|
|
* @param wxPhone |
|
|
* @param wxPhone 手机号和合并方式 |
|
|
* @return |
|
|
* @return 用户id |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public UserVo.UserSign mergeByPhone(Long currentUserId, UserDto.WxMergePhone wxPhone) { |
|
|
public UserVo.UserSign mergeByPhone(Long currentUserId, UserDto.WxMergePhone wxPhone) { |
|
@ -1237,16 +1243,16 @@ public class UserService implements IUserService { |
|
|
userDao.replaceAuth(userId, currentUserId); |
|
|
userDao.replaceAuth(userId, currentUserId); |
|
|
//查询所有关联userId的数据库表 auth表 attention表 balance表 project表 member表 DeliverPostLog表 proLog表
|
|
|
//查询所有关联userId的数据库表 auth表 attention表 balance表 project表 member表 DeliverPostLog表 proLog表
|
|
|
//依次将查出的数据的旧userId 替换成新的userId
|
|
|
//依次将查出的数据的旧userId 替换成新的userId
|
|
|
|
|
|
userDao.replaceProject(userId, currentUserId); |
|
|
userDao.replaceAttention(userId, currentUserId); |
|
|
userDao.replaceAttention(userId, currentUserId); |
|
|
userDao.replaceBalance(userId, currentUserId); |
|
|
userDao.replaceBalance(userId, currentUserId); |
|
|
userDao.replaceProject(userId, currentUserId); |
|
|
|
|
|
userDao.replaceMember(userId, currentUserId); |
|
|
userDao.replaceMember(userId, currentUserId); |
|
|
userDao.replaceDeliverPostLog(userId, currentUserId); |
|
|
userDao.replaceDeliverPostLog(userId, currentUserId); |
|
|
userDao.replaceProLog(userId, currentUserId); |
|
|
userDao.replaceProLog(userId, currentUserId); |
|
|
userDao.replaceComment(userId, currentUserId); |
|
|
userDao.replaceComment(userId, currentUserId); |
|
|
//将以前的余额添加至此账号
|
|
|
//将以前的余额添加至此账号
|
|
|
SysUser oldUser = userDao.selectByPrimaryKey(userId); |
|
|
|
|
|
SysUser newUser = userDao.selectByPrimaryKey(currentUserId); |
|
|
SysUser newUser = userDao.selectByPrimaryKey(currentUserId); |
|
|
|
|
|
SysUser oldUser = userDao.selectByPrimaryKey(userId); |
|
|
if(ObjectUtil.isNotNull(oldUser) && ObjectUtil.isNotNull(newUser)) { |
|
|
if(ObjectUtil.isNotNull(oldUser) && ObjectUtil.isNotNull(newUser)) { |
|
|
updateBalance(oldUser, newUser); |
|
|
updateBalance(oldUser, newUser); |
|
|
} |
|
|
} |
|
@ -1335,7 +1341,7 @@ public class UserService implements IUserService { |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public UserVo.WxInfo updateUserInfo(Long currentUserId, UserDto.WxInfo userInfo) { |
|
|
public UserVo.WxInfo updateUserInfo(Long currentUserId, UserDto.WxInfo userInfo) { |
|
|
//通过userid查找到用户
|
|
|
//通过userId查找到用户
|
|
|
SysUser user = userDao.selectByPrimaryKey(currentUserId); |
|
|
SysUser user = userDao.selectByPrimaryKey(currentUserId); |
|
|
if (ObjectUtil.isNull(user)) { |
|
|
if (ObjectUtil.isNull(user)) { |
|
|
throw new BaseException(CodeEnum.NOT_LOGIN); |
|
|
throw new BaseException(CodeEnum.NOT_LOGIN); |
|
@ -1393,12 +1399,11 @@ public class UserService implements IUserService { |
|
|
/** |
|
|
/** |
|
|
* 更改绑定手机号(不要密码) |
|
|
* 更改绑定手机号(不要密码) |
|
|
* |
|
|
* |
|
|
* @param userId |
|
|
* @param userId userId |
|
|
* @param phoneInfo |
|
|
* @param phoneInfo 手机号和验证码 |
|
|
* @throws Exception |
|
|
|
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public UserVo.UserSign changePhoneNotPassword(Long userId, UserDto.WxBindingPhone phoneInfo) throws Exception { |
|
|
public UserVo.UserSign changePhoneNotPassword(Long userId, UserDto.WxBindingPhone phoneInfo) { |
|
|
UserVo.UserSign userSign = null; |
|
|
UserVo.UserSign userSign = null; |
|
|
if (isSmsCodeCorrect(phoneInfo.getPhone(), phoneInfo.getSmsCode())) { |
|
|
if (isSmsCodeCorrect(phoneInfo.getPhone(), phoneInfo.getSmsCode())) { |
|
|
//查找新手机号的的绑定信息
|
|
|
//查找新手机号的的绑定信息
|
|
|