Search in sources :

Example 76 with QueryWrapper

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);
}
Also used : QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)

Example 77 with 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());
    }
}
Also used : QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) musicForum.bean.users(musicForum.bean.users) musicForum.bean.users(musicForum.bean.users) Date(java.util.Date)

Example 78 with QueryWrapper

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;
}
Also used : UsernameNotFoundException(org.springframework.security.core.userdetails.UsernameNotFoundException) UserDetail(org.example.security.auth.entity.UserDetail) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) RoleInfo(org.example.security.auth.entity.RoleInfo) UserInfo(org.example.security.auth.entity.UserInfo)

Example 79 with QueryWrapper

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);
    }
}
Also used : QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) Course(com.roy.shardingDemo.entity.Course) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 80 with QueryWrapper

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);
}
Also used : RoleEntity(io.nerv.web.sys.role.entity.RoleEntity) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) Page(io.nerv.core.mvc.util.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage)

Aggregations

QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)723 Transactional (org.springframework.transaction.annotation.Transactional)98 IPage (com.baomidou.mybatisplus.core.metadata.IPage)82 UserRolesVo (top.hcode.hoj.pojo.vo.UserRolesVo)74 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)72 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)65 ArrayList (java.util.ArrayList)61 Session (org.apache.shiro.session.Session)61 StatusFailException (top.hcode.hoj.common.exception.StatusFailException)60 StatusForbiddenException (top.hcode.hoj.common.exception.StatusForbiddenException)55 Problem (top.hcode.hoj.pojo.entity.problem.Problem)50 UpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper)45 Date (java.util.Date)44 HttpServletRequest (javax.servlet.http.HttpServletRequest)35 HashMap (java.util.HashMap)34 RequiresAuthentication (org.apache.shiro.authz.annotation.RequiresAuthentication)34 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)34 ApiOperation (io.swagger.annotations.ApiOperation)32 HttpSession (javax.servlet.http.HttpSession)31 Judge (top.hcode.hoj.pojo.entity.judge.Judge)30