Search in sources :

Example 16 with QueryWrapper

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

the class CommentServiceImpl method getCommentByArticleId.

@Override
public ResultVO getCommentByArticleId(Integer articleId, Integer userId, Page<Comment> page) {
    // 查询所有记录数
    QueryWrapper<Comment> wrapper = new QueryWrapper<>();
    wrapper.eq("article_id", articleId);
    Long count = commentMapper.selectCount(wrapper);
    // 查询所有1级评论
    wrapper.eq("level", 1).orderByDesc("praise_num").orderByDesc("create_time");
    commentMapper.selectPage(page, wrapper);
    List<Comment> commentList = page.getRecords();
    List<CommentVo> commentVoList = copyList(commentList, userId);
    CommentPageVo commentPageVo = new CommentPageVo();
    commentPageVo.setCommentCount(count);
    commentPageVo.setCommentVoList(commentVoList);
    BeanUtils.copyProperties(page, commentPageVo);
    return new ResultVO(ResStatus.OK, "评论查询成功", commentPageVo);
}
Also used : ResultVO(shu.java.csky.vo.ResultVO) Comment(shu.java.csky.entity.Comment) CommentPageVo(shu.java.csky.vo.page.CommentPageVo) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) CommentVo(shu.java.csky.vo.CommentVo)

Example 17 with QueryWrapper

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

the class EmailCodeServiceImpl method sendCode.

/**
 * 1. 已经注册过的不能再注册
 * 2. 验证码的时效问题
 *
 * @param email
 * @return
 */
@Override
public ResultVO sendCode(String email) {
    EmailCode emailCode = new EmailCode();
    emailCode.setCode(createCode());
    emailCode.setEmail(email);
    try {
        MailUtil.sendCode(email, emailCode.getCode(), "计算机考研网邮箱验证码");
    } catch (Exception e) {
        throw new RuntimeException("邮箱验证码发送失败!");
    }
    try {
        emailCodeMapper.insert(emailCode);
        QueryWrapper<EmailCode> wrapper = new QueryWrapper<>();
        wrapper.eq("code", emailCode.getCode());
        EmailCode emailCode1 = emailCodeMapper.selectOne(wrapper);
        EmailCodeVo emailCodeVo = new EmailCodeVo();
        BeanUtils.copyProperties(emailCode1, emailCodeVo);
        return new ResultVO(ResStatus.OK, "验证码发送成功!", emailCodeVo);
    } catch (Exception e) {
        e.printStackTrace();
        return new ResultVO(ResStatus.NO, "验证码发送失败!", null);
    }
}
Also used : ResultVO(shu.java.csky.vo.ResultVO) EmailCodeVo(shu.java.csky.vo.EmailCodeVo) EmailCode(shu.java.csky.entity.EmailCode) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)

Example 18 with QueryWrapper

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

the class SchoolServiceImpl method fuzzyQuerySchool.

@Override
public ResultVO fuzzyQuerySchool(QueryPageParam queryPageParam) {
    String text = queryPageParam.getText();
    Integer uid = queryPageParam.getUid();
    // 若text为空,直接返回
    if (text == null)
        return new ResultVO(ResStatus.OK, "text为空", null);
    QueryWrapper<School> wrapper = new QueryWrapper<>();
    wrapper.like("sname", text).or().like("introduction", text).or().like("short_introduction", text).or().like("official_Site", text).orderByAsc("sid");
    IPage<School> schoolPage = new Page<>();
    BeanUtils.copyProperties(queryPageParam, schoolPage);
    schoolMapper.selectPage(schoolPage, wrapper);
    SchoolPageVo schoolPageVo = new SchoolPageVo();
    BeanUtils.copyProperties(schoolPage, schoolPageVo);
    ArrayList<SchoolVo> schoolVos = new ArrayList<>();
    for (School record : schoolPage.getRecords()) {
        SchoolVo schoolVo = new SchoolVo();
        BeanUtils.copyProperties(record, schoolVo);
        schoolVos.add(schoolVo);
    }
    // 若查到数据,插入search表
    if (!schoolVos.isEmpty() && (uid != null))
        searchMapper.insert(new Search(0, uid, text));
    schoolPageVo.setSchoolVoList(schoolVos);
    return new ResultVO(ResStatus.OK, "学校模糊查询分页信息返回成功", schoolPageVo);
}
Also used : ResultVO(shu.java.csky.vo.ResultVO) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) SchoolPageVo(shu.java.csky.vo.page.SchoolPageVo) ArrayList(java.util.ArrayList) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage) School(shu.java.csky.entity.School) Search(shu.java.csky.entity.Search) SchoolVo(shu.java.csky.vo.SchoolVo)

Example 19 with QueryWrapper

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

the class ScoreLineServiceImpl method getScorelineBySid.

@Override
public ResultVO getScorelineBySid(Integer sid) {
    QueryWrapper<Scoreline> wrapper = new QueryWrapper<>();
    wrapper.eq("school_id", sid).orderByDesc("score_21").orderByDesc("score_20").orderByDesc("score_19");
    String sname = schoolMapper.selectById(sid).getSname();
    List<Scoreline> scorelines = scorelineMapper.selectList(wrapper);
    ArrayList<ScorelineVo> scorelineVos = new ArrayList<>();
    for (Scoreline scoreline : scorelines) {
        ScorelineVo scorelineVo = new ScorelineVo();
        BeanUtils.copyProperties(scoreline, scorelineVo);
        scorelineVo.setSname(sname);
        scorelineVos.add(scorelineVo);
    }
    return new ResultVO(ResStatus.OK, "由sid查询学校分数线成功", scorelineVos);
}
Also used : ResultVO(shu.java.csky.vo.ResultVO) Scoreline(shu.java.csky.entity.Scoreline) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) ScorelineVo(shu.java.csky.vo.ScorelineVo) ArrayList(java.util.ArrayList)

Example 20 with QueryWrapper

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

the class ScoreLineServiceImpl method getScorelinePage.

@Override
public ResultVO getScorelinePage(Page<Scoreline> scorelineIPage) {
    QueryWrapper<Scoreline> wrapper = new QueryWrapper<>();
    wrapper.orderByDesc("score_21").orderByDesc("score_20").orderByDesc("score_19");
    scorelineMapper.selectPage(scorelineIPage, wrapper);
    ScorelinePageVo scorelinePageVo = new ScorelinePageVo();
    BeanUtils.copyProperties(scorelineIPage, scorelinePageVo);
    List<Scoreline> records = scorelineIPage.getRecords();
    ArrayList<ScorelineVo> scorelineVos = new ArrayList<>();
    for (Scoreline record : records) {
        ScorelineVo scorelineVo = new ScorelineVo();
        BeanUtils.copyProperties(record, scorelineVo);
        School school = schoolMapper.selectById(record.getSchoolId());
        scorelineVo.setSname(school.getSname());
        scorelineVos.add(scorelineVo);
    }
    scorelinePageVo.setScorelineVoList(scorelineVos);
    return new ResultVO(ResStatus.OK, "分数线分页信息查询成功", scorelinePageVo);
}
Also used : ResultVO(shu.java.csky.vo.ResultVO) School(shu.java.csky.entity.School) ScorelinePageVo(shu.java.csky.vo.page.ScorelinePageVo) Scoreline(shu.java.csky.entity.Scoreline) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) ScorelineVo(shu.java.csky.vo.ScorelineVo) ArrayList(java.util.ArrayList)

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