|
|
|
@ -7,6 +7,7 @@ import com.community.pocket.entity.vo.android.*; |
|
|
|
|
import com.community.pocket.entity.vo.web.EditScore; |
|
|
|
|
import com.community.pocket.repository.BaseDao; |
|
|
|
|
import com.community.pocket.repository.CreditScoreDao; |
|
|
|
|
import com.community.pocket.repository.EmailDao; |
|
|
|
|
import com.community.pocket.util.LookupOperationUtil; |
|
|
|
|
import com.mongodb.client.result.UpdateResult; |
|
|
|
|
import org.slf4j.Logger; |
|
|
|
@ -35,6 +36,9 @@ public class UserDao extends BaseDao<MyInfo> { |
|
|
|
|
@Autowired |
|
|
|
|
private CreditScoreDao creditScoreDao; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private EmailDao emailDao; |
|
|
|
|
|
|
|
|
|
@Value("${register.credit-score}") |
|
|
|
|
private int creditScore; |
|
|
|
|
|
|
|
|
@ -122,22 +126,33 @@ public class UserDao extends BaseDao<MyInfo> { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//检查用户和邮箱是否对应
|
|
|
|
|
public boolean hasUseWithEmail(String username, String email){ |
|
|
|
|
if(!StringUtils.isEmpty(username)&&!StringUtils.isEmpty(email)){ |
|
|
|
|
return mongoTemplate.exists(new Query().addCriteria(Criteria.where("username").is(username).and("email").is(email)),entityClass()); |
|
|
|
|
}else{ |
|
|
|
|
public boolean hasUseWithEmail(String username, String email) { |
|
|
|
|
if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(email)) { |
|
|
|
|
return mongoTemplate.exists(new Query().addCriteria(Criteria.where("username").is(username).and("email").is(email)), entityClass()); |
|
|
|
|
} else { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//检查新密码是否和原密码重复
|
|
|
|
|
public boolean isNotDiffPwd(UserResetPwd userResetPwd) { |
|
|
|
|
String md5Password = DigestUtils.md5DigestAsHex(userResetPwd.getPassword().getBytes()); |
|
|
|
|
MyInfo myInfo = mongoTemplate.findById(userResetPwd.getUsername(), entityClass()); |
|
|
|
|
return myInfo != null && myInfo.getPassword().equals(md5Password) && emailDao.clearEmail(myInfo.getEmail()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//重置密码
|
|
|
|
|
public boolean resetPwd(String username,String password){ |
|
|
|
|
if(!StringUtils.isEmpty(username)&&!StringUtils.isEmpty(password)){ |
|
|
|
|
String md5Password= DigestUtils.md5DigestAsHex(password.getBytes()); |
|
|
|
|
UpdateResult result=mongoTemplate.updateFirst(new Query().addCriteria(Criteria.where("username").is(username)), Update.update("password",md5Password),entityClass()); |
|
|
|
|
public boolean resetPwd(UserResetPwd userResetPwd) { |
|
|
|
|
String username = userResetPwd.getUsername(); |
|
|
|
|
String password = userResetPwd.getPassword(); |
|
|
|
|
String md5Password = DigestUtils.md5DigestAsHex(password.getBytes()); |
|
|
|
|
if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(md5Password)) { |
|
|
|
|
UpdateResult result = mongoTemplate.updateFirst(new Query().addCriteria( |
|
|
|
|
Criteria.where("username").is(username)), |
|
|
|
|
Update.update("password", md5Password), entityClass()); |
|
|
|
|
return result.wasAcknowledged(); |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|