This commit is contained in:
xzb 2022-10-17 16:28:46 +08:00
parent 522d446516
commit 5310fc7819

View File

@ -19,6 +19,8 @@ import club.joylink.rtss.vo.paper.FindPaperUserForClassReqVo;
import club.joylink.rtss.vo.paper.FindPaperUserForCompositionReqVo;
import club.joylink.rtss.vo.paper.PaperUserInfoVo;
import club.joylink.rtss.vo.paper.convertor.PaperUserConvertor;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -66,7 +68,6 @@ public class PaperUserFindPageService {
*/
@Transactional(readOnly = true)
public PageVO<PaperUserInfoVo> findPaperUserByPageForClass(FindPaperUserForClassReqVo req){
PageVO<PaperUserInfoVo> page = new PageVO<>();
PaperComposition pc = paperCompositionDAO.selectByPrimaryKey(req.getPcId());
PaperExceptionAssert.PcExisted.assertNotNull(pc,"试卷定义不存在");
//
@ -83,38 +84,24 @@ public class PaperUserFindPageService {
case Complete:c.andScoreIsNotNull();break;
case All:break;
}
long sum = paperUserDAO.countByExample(example);
page.setTotal(sum);
page.setPageNum(req.getPageNum());
page.setPageSize(req.getPageSize());
page.setList(new ArrayList<>());
if (sum > 0) {
//
String orderBy = req.getOrderBy().with();
long startIndex = (req.getPageNum() - 1) * req.getPageSize();
//
if (req.getDesc()) {
example.setOrderByClause(String.format("%s desc limit %s,%s", orderBy, startIndex, req.getPageSize()));
} else {
example.setOrderByClause(String.format("%s limit %s,%s", orderBy, startIndex, req.getPageSize()));
}
List<PaperUser> pContent = this.paperUserDAO.selectByExample(example);
if (null != pContent) {
pContent.forEach(t -> {
page.getList().add(PaperUserConvertor.convert(pc,t));
});
}
//
String orderBy = req.getOrderBy().with()+(req.getDesc()?" desc":"");
PageHelper.startPage(req.getPageNum(),req.getPageSize(),orderBy);
Page<PaperUser> sqlPage = (Page<PaperUser>) this.paperUserDAO.selectByExample(example);
//
List<PaperUserInfoVo> rtContent= new ArrayList<>();
if(!CollectionUtils.isEmpty(sqlPage.getResult())){
sqlPage.getResult().forEach(t -> {
rtContent.add(PaperUserConvertor.convert(pc,t));
});
}
return page;
return PageVO.convert(sqlPage,rtContent);
}
/**
* 分页查询某个试卷蓝图的所有用户试卷基本信息
*/
@Transactional(readOnly = true)
public PageVO<PaperUserInfoVo> findPaperUserByPage(FindPaperUserForCompositionReqVo req) {
PageVO<PaperUserInfoVo> page = new PageVO<>();
//
PaperComposition pc = paperCompositionDAO.selectByPrimaryKey(req.getPcId());
PaperExceptionAssert.PcExisted.assertNotNull(pc,"试卷定义不存在");
@ -127,30 +114,18 @@ public class PaperUserFindPageService {
case Complete:c.andScoreIsNotNull();break;
case All:break;
}
long sum = paperUserDAO.countByExample(example);
page.setTotal(sum);
page.setPageNum(req.getPageNum());
page.setPageSize(req.getPageSize());
page.setList(new ArrayList<>());
if (sum > 0) {
//
String orderBy = req.getOrderBy().with();
long startIndex = (req.getPageNum() - 1) * req.getPageSize();
//
if (req.getDesc()) {
example.setOrderByClause(String.format("%s desc limit %s,%s", orderBy, startIndex, req.getPageSize()));
} else {
example.setOrderByClause(String.format("%s limit %s,%s", orderBy, startIndex, req.getPageSize()));
}
List<PaperUser> pContent = this.paperUserDAO.selectByExample(example);
if (null != pContent) {
pContent.forEach(t -> {
page.getList().add(PaperUserConvertor.convert(pc,t));
});
}
}
//
return page;
String orderBy = req.getOrderBy().with()+(req.getDesc()?" desc":"");
PageHelper.startPage(req.getPageNum(),req.getPageSize(),orderBy);
Page<PaperUser> sqlPage = (Page<PaperUser>) this.paperUserDAO.selectByExample(example);
//
List<PaperUserInfoVo> rtContent= new ArrayList<>();
if(!CollectionUtils.isEmpty(sqlPage.getResult())){
sqlPage.getResult().forEach(t -> {
rtContent.add(PaperUserConvertor.convert(pc,t));
});
}
return PageVO.convert(sqlPage,rtContent);
}
/**
* 查询某个班级的所有学生的userId