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