1
0
mirror of https://gitee.com/incloudcode/yexuejc-springboot.git synced 2025-07-19 01:59:31 +08:00

更新test

This commit is contained in:
maxf 2018-12-03 10:50:56 +08:00
parent 1c7e39a50f
commit 561002bac3
2 changed files with 12 additions and 2 deletions

View File

@ -20,7 +20,7 @@
</parent> </parent>
<properties> <properties>
<yexuejc.base.version>1.2.2</yexuejc.base.version> <yexuejc.base.version>1.2.4</yexuejc.base.version>
<repos.yexuejc.url>https://nexus.yexuejc.club/repository/</repos.yexuejc.url> <repos.yexuejc.url>https://nexus.yexuejc.club/repository/</repos.yexuejc.url>
<repos.aliyun.url>http://maven.aliyun.com/nexus/content/groups/public</repos.aliyun.url> <repos.aliyun.url>http://maven.aliyun.com/nexus/content/groups/public</repos.aliyun.url>

View File

@ -18,6 +18,7 @@ import com.yexuejc.springboot.base.security.inte.UserService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
@ -43,16 +44,25 @@ public class UserServiceImpl implements UserService {
/** /**
* 根据用户名到数据库查询用户 * 根据用户名到数据库查询用户
* <p>
* 账号未找到抛出UsernameNotFoundException异常=>会走第三方登录流程
* </p>
* *
* @param username 登录账号 * @param username 登录账号
* @return * @return
*/ */
@Override @Override
public User getConsumerByUserName(String username) { public User getConsumerByUserName(String username) {
if (StrUtil.isEmpty(username)) {
throw new UsernameNotFoundException(username);
}
QueryWrapper queryWrapper = new QueryWrapper(); QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("mobile", username); queryWrapper.eq("mobile", username);
Consumer consumer = consumerMapper.selectOne(queryWrapper); Consumer consumer = consumerMapper.selectOne(queryWrapper);
ArrayList roles = new ArrayList<>(); if (null == consumer) {
throw new UsernameNotFoundException(username);
}
ArrayList roles = new ArrayList<>();
roles.add("ROLE_CONSUMER"); roles.add("ROLE_CONSUMER");
consumer.setRoles(roles); consumer.setRoles(roles);
return consumer; return consumer;