use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project forum by saysky.
the class RoleServiceImpl method findByRoleName.
@Override
public Role findByRoleName(String roleName) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("role", roleName);
return roleMapper.selectOne(queryWrapper);
}
use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project cooperation by daniellePie.
the class UserServiceImpl method register.
@Override
public Result register(register registerParam) {
String account = registerParam.getAccount();
String nickname = registerParam.getNickname();
String password = registerParam.getPassword();
String phone = registerParam.getPhone();
// 可以加盐以使md5安全
String pwd = DigestUtils.md5DigestAsHex(password.getBytes(StandardCharsets.UTF_8));
// 先查找账号是否重复,再向数据库添加信息
QueryWrapper<users> usersQueryWrapper = new QueryWrapper<users>();
usersQueryWrapper.eq("account", account);
users users = userMapper.selectOne(usersQueryWrapper);
if (users == null) {
// 没有找到,可以正常注册
Date date = new Date();
musicForum.bean.users user_create = new users();
user_create.setCreate_date(date);
user_create.setAccount(account);
user_create.setNickname(nickname);
user_create.setPassword(pwd);
user_create.setPhone(phone);
// 可能需要单独处理show
user_create.setShow(0);
// 单独处理头像,单独写一个方法,七牛云服务器
user_create.setAvator(dafaultAvatorPath);
userMapper.insert(user_create);
return Result.success(null);
} else {
// 重复了
return Result.fail(ErrorCode.ACCOUNT_ALREADY_EXIST.getCode(), ErrorCode.ACCOUNT_ALREADY_EXIST.getMsg());
}
}
use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project spring-boot-learning-demo by rookie-ricardo.
the class CustomUserDetailsService method loadUserByUsername.
@Override
public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
log.debug("开始登陆验证,用户名为: {}", s);
// 根据用户名验证用户
QueryWrapper<UserInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(UserInfo::getUsername, s);
UserInfo userInfo = userService.getOne(queryWrapper);
if (userInfo == null) {
throw new UsernameNotFoundException("用户名不存在,登陆失败。");
}
// 构建UserDetail对象
UserDetail userDetail = new UserDetail();
userDetail.setUserInfo(userInfo);
List<RoleInfo> roleInfoList = roleInfoService.listRoleByUserId(userInfo.getId());
userDetail.setRoleInfoList(roleInfoList);
return userDetail;
}
use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project code by lastwhispers.
the class ShardingJDBCTest method queryCourse.
@Test
public void queryCourse() {
// select * from course
QueryWrapper<Course> wrapper = new QueryWrapper<>();
wrapper.orderByDesc("cid");
// wrapper.eq("cid",730100102537940992L);
// wrapper.in("cid",730100102537940992L,730100102990925824L);
List<Course> courses = courseMapper.selectList(wrapper);
System.out.println("条数:" + courses.size());
for (Course course : courses) {
System.out.println("查询结果:" + course);
}
}
use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project EVA-API by PKAQ-LAB.
the class RoleService method listRole.
/**
* 查询角色列表
* @param roleEntity
* @return
*/
public IPage<RoleEntity> listRole(RoleEntity roleEntity, Integer page, Integer pageSize) {
page = null != page ? page : 1;
pageSize = null != pageSize ? pageSize : 10;
// 查询条件
QueryWrapper<RoleEntity> wrapper = new QueryWrapper<>(roleEntity);
// 分页条件
Page pagination = new Page();
pagination.setCurrent(page);
pagination.setSize(pageSize);
return this.mapper.selectPage(pagination, wrapper);
}
Aggregations