Search in sources :

Example 21 with QueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project CSKY by SHU-Silence.

the class SearchServiceImpl method getSearchHistoryByUId.

@Override
public ResultVO getSearchHistoryByUId(Integer uid) {
    QueryWrapper<Search> wrapper = new QueryWrapper<>();
    wrapper.eq("uid", uid).orderByAsc("id").last("LIMIT 10");
    List<Search> searches = searchMapper.selectList(wrapper);
    ArrayList<String> textList = new ArrayList<>();
    for (Search search : searches) {
        textList.add(search.getText());
    }
    return new ResultVO(ResStatus.OK, "搜索历史返回成功", textList);
}
Also used : ResultVO(shu.java.csky.vo.ResultVO) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) Search(shu.java.csky.entity.Search) ArrayList(java.util.ArrayList)

Example 22 with QueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project CSKY by SHU-Silence.

the class TagServiceImpl method addTagName.

@Override
public ResultVO addTagName(String tagName) {
    QueryWrapper<TagName> tagNameQueryWrapper = new QueryWrapper<>();
    tagNameQueryWrapper.eq("tag_name", tagName);
    Long count = tagNameMapper.selectCount(tagNameQueryWrapper);
    if (count > 0) {
        return new ResultVO(ResStatus.NO, "改标签已存在", null);
    }
    TagName tagName1 = new TagName();
    tagName1.setTagName(tagName);
    tagNameMapper.insert(tagName1);
    return new ResultVO(ResStatus.OK, "添加成功", tagName1);
}
Also used : ResultVO(shu.java.csky.vo.ResultVO) TagName(shu.java.csky.entity.TagName) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)

Example 23 with QueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project CSKY by SHU-Silence.

the class TeacherServiceImpl method fuzzyQueryTeacher.

@Override
public ResultVO fuzzyQueryTeacher(TeacherPageParam teacherPageParam) {
    String text = teacherPageParam.getText();
    Integer uid = teacherPageParam.getUid();
    if (text == null)
        return new ResultVO(ResStatus.OK, "text为空", null);
    QueryWrapper<Teachers> wrapper = new QueryWrapper<>();
    wrapper.eq("schoolId", teacherPageParam.getSid()).and(wr -> {
        wr.like("tname", text).or().like("studydir", text).or().like("eduresume", text).or().like("proresume", text).or().like("tURL", text);
    }).orderByAsc("id");
    IPage<Teachers> teachersPage = new Page<>();
    BeanUtils.copyProperties(teacherPageParam, teachersPage);
    teachersMapper.selectPage(teachersPage, wrapper);
    TeacherPageVo teacherPageVo = new TeacherPageVo();
    BeanUtils.copyProperties(teachersPage, teacherPageVo);
    ArrayList<TeacherVo> teacherVos = new ArrayList<>();
    for (Teachers record : teachersPage.getRecords()) {
        TeacherVo teacherVo = new TeacherVo();
        BeanUtils.copyProperties(record, teacherVo);
        teacherVos.add(teacherVo);
    }
    // 若查到数据,插入search表
    if (!teacherVos.isEmpty() && (uid != null))
        searchMapper.insert(new Search(0, uid, text));
    teacherPageVo.setTeacherVoList(teacherVos);
    return new ResultVO(ResStatus.OK, "教师模糊查询分页信息返回成功", teacherPageVo);
}
Also used : ResultVO(shu.java.csky.vo.ResultVO) TeacherPageParam(shu.java.csky.vo.param.TeacherPageParam) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) TeacherVo(shu.java.csky.vo.TeacherVo) SearchMapper(shu.java.csky.dao.SearchMapper) Resource(javax.annotation.Resource) ResultVO(shu.java.csky.vo.ResultVO) TeacherService(shu.java.csky.TeacherService) Search(shu.java.csky.entity.Search) TeachersMapper(shu.java.csky.dao.TeachersMapper) ArrayList(java.util.ArrayList) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) Teachers(shu.java.csky.entity.Teachers) ResStatus(shu.java.csky.vo.ResStatus) List(java.util.List) TeacherPageVo(shu.java.csky.vo.page.TeacherPageVo) Service(org.springframework.stereotype.Service) IPage(com.baomidou.mybatisplus.core.metadata.IPage) BeanUtils(org.springframework.beans.BeanUtils) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) ArrayList(java.util.ArrayList) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage) Teachers(shu.java.csky.entity.Teachers) Search(shu.java.csky.entity.Search) TeacherVo(shu.java.csky.vo.TeacherVo) TeacherPageVo(shu.java.csky.vo.page.TeacherPageVo)

Example 24 with QueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project CSKY by SHU-Silence.

the class UserServiceImpl method userRegister.

@Override
public ResultVO userRegister(String name, String pwd, String email) {
    // 1.根据用户查询,这个用户是否已经被注册
    if (isRegister(name)) {
        return new ResultVO(ResStatus.NO, "用户名已经被注册!", null);
    }
    // 2.如果没有被注册则进行保存操作
    String md5Pwd = MD5Utils.md5(pwd);
    User u = new User();
    u.setUsername(name);
    u.setPassword(md5Pwd);
    // 3. 设置随机头像
    List<Avatar> avatarList = avatarMapper.selectList(null);
    u.setUserImg(avatarList.get(new Random().nextInt(avatarList.size())).getSrc());
    u.setUserEmail(email);
    u.setUserRegtime(new Date());
    u.setUserModtime(new Date());
    // 执行保存操作
    int count = userMapper.insert(u);
    if (count == 1) {
        User user = userMapper.selectOne(new QueryWrapper<User>().eq("username", u.getUsername()));
        user.setPassword(null);
        return new ResultVO(ResStatus.OK, "注册成功!", user);
    }
    return new ResultVO(ResStatus.NO, "注册失败!", null);
}
Also used : ResultVO(shu.java.csky.vo.ResultVO) User(shu.java.csky.entity.User) Random(java.util.Random) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) Avatar(shu.java.csky.entity.Avatar) Date(java.util.Date)

Example 25 with QueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project solon-examples by noear.

the class PlusServiceTest method selectOne.

@Test
public void selectOne() {
    AppxModel app = appServicePlus.getOne(new QueryWrapper<AppxModel>().eq("app_id", 2));
    System.out.println(app);
    assert app != null;
    assert app.getAppId() == 2;
}
Also used : QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) AppxModel(demo4031.model.AppxModel) SolonTest(org.noear.solon.test.SolonTest) Test(org.junit.Test)

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