use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project codingmore-learning by itwanger.
the class UsersServiceImpl method register.
@Override
public boolean register(Users users) {
QueryWrapper<Users> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("user_login", users.getUserLogin());
int count = this.baseMapper.selectCount(queryWrapper);
if (count > 0) {
return false;
}
users.setUserRegistered(new Date());
users.setUserType(UserType.BACKEND.getUserType());
users.setUserStatus(UserStatus.ENABLE.getStatus());
String encodePassword = passwordEncoder.encode(users.getUserPass());
users.setUserPass(encodePassword);
return save(users);
}
use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project codingmore-learning by itwanger.
the class PostsServiceImpl method getPostsById.
@Override
public PostsVo getPostsById(Long id) {
Posts posts = this.getById(id);
PostsVo postsVo = new PostsVo();
BeanUtils.copyProperties(posts, postsVo);
QueryWrapper<TermRelationships> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("object_id", posts.getId());
List<TermRelationships> termRelationshipsList = iTermRelationshipsService.list(queryWrapper);
if (termRelationshipsList.size() > 0) {
postsVo.setTermTaxonomyId(termRelationshipsList.get(0).getTermTaxonomyId());
}
return postsVo;
}
use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project springbootquickstart by Pace2Car.
the class ShiroRealm method doGetAuthenticationInfo.
/**
* 认证
*
* @param token
* @return
* @throws AuthenticationException
*/
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
logger.info("用户登录,登录信息-->{}", token);
// 获取用户的输入的账号.
String username = (String) token.getPrincipal();
// 通过username从数据库中查找 User对象,如果找到,没找到.
// 实际项目中,这里可以根据实际情况做缓存,如果不做,Shiro自己也是有时间间隔机制,2分钟内不会重复执行该方法
UUser user = uUserService.getOne(new QueryWrapper<UUser>().eq("username", username));
logger.info("用户登录,登录信息-->{}", user);
if (user == null) {
// 没有返回登录用户名对应的SimpleAuthenticationInfo对象时,就会在LoginController中抛出UnknownAccountException异常
return null;
} else {
user.setLastLoginTime(new Timestamp(System.currentTimeMillis()));
uUserService.updateById(user);
}
SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo(username, user.getPassword(), getName());
return authenticationInfo;
}
use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project aurora-mall by besscroft.
the class ResourceServiceImpl method getAllResourceTree.
@Override
public List<ResourceParam> getAllResourceTree() {
List<ResourceParam> list = new ArrayList<>();
List<AuthResourceSort> resourceSorts = authResourceSortMapper.selectList(new QueryWrapper<>());
resourceSorts.forEach(r -> {
ResourceParam resourceParam = new ResourceParam();
QueryWrapper<AuthResource> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("category_id", r.getId());
List<AuthResource> resources = this.baseMapper.selectList(queryWrapper);
resourceParam.setName(r.getCategoryName());
resourceParam.setDisabled(true);
resourceParam.setChildren(resources);
list.add(resourceParam);
});
return list;
}
use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project su-sunday-cloud by illeagalName.
the class ResourcePreloadRunner method run.
@Override
public void run(ApplicationArguments args) {
clearCache(CacheConstants.AUTHORIZATION_USER_ROLE + "*");
log.info("加载角色菜单资源开始 {}", LocalDateTime.now());
QueryWrapper<Role> roleWrapper = new QueryWrapper<>();
roleWrapper.eq("status", 0).eq("is_delete", 0);
List<Role> roles = roleMapper.selectList(roleWrapper);
roles.parallelStream().forEach(item -> {
List<Menu> menus = menuMapper.listMenusByRoleId(item.getRoleId());
RoleVO role = new RoleVO();
BeanUtils.copyProperties(item, role);
role.setMenus(menus.stream().map(Menu::getSymbol).filter(Objects::nonNull).collect(Collectors.toList()));
// 缓存起来
redisService.setObject(CacheConstants.AUTHORIZATION_USER_ROLE + role.getRoleId(), role);
});
clearCache(CacheConstants.AUTHORIZATION_USER_MENU + "*");
QueryWrapper<Menu> menuWrapper = new QueryWrapper<>();
menuWrapper.orderByAsc("parent_id", "menu_sort");
List<Menu> menus = menuMapper.selectList(menuWrapper);
menus.forEach(item -> {
MenuVO menu = new MenuVO();
BeanUtils.copyProperties(item, menu);
redisService.setObject(CacheConstants.AUTHORIZATION_USER_MENU + item.getMenuId(), menu);
});
clearCache(CacheConstants.AUTHORIZATION_USER_CLIENT + "*");
log.info("加载client资源开始 {}", LocalDateTime.now());
List<AuthClient> authClients = authClientMapper.listAuthClients();
authClients.stream().map(client -> {
ClientVO clientVO = new ClientVO();
clientVO.setClientId(client.getClientId());
clientVO.setTime(client.getAccessTokenValidity());
clientVO.setRemark(client.getRemark());
return clientVO;
}).forEach(m -> {
redisService.setObject(CacheConstants.AUTHORIZATION_USER_CLIENT + m.getClientId(), m);
});
log.info("加载资源结束 {}", LocalDateTime.now());
}
Aggregations