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);
}
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);
}
}
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);
}
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);
}
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);
}
Aggregations