当前位置: 首页 > wzjs >正文

自动建站源码注册公司代理有哪些

自动建站源码,注册公司代理有哪些,图片制作视频怎么制作,国外专门做视频翻译网站需求 分页查询我的课表 返回: 总条数、总页数、当前页的课表信息的集合 返回的VO(已经封装成统一的LearningLessonsVO) 定义Controller RestController RequestMapping("/lessons") RequiredArgsConstructor public class Lear…

需求

分页查询我的课表

返回:

总条数、总页数、当前页的课表信息的集合

返回的VO(已经封装成统一的LearningLessonsVO)

定义Controller

@RestController
@RequestMapping("/lessons")
@RequiredArgsConstructor
public class LearningLessonController {private final ILearningLessonService lessonService;@GetMapping("/page")public PageDTO<LearningLessonVO> queryMyLesson(PageQuery query) {return lessonService.querMyLesson(query);}
}

2.service实现类

代码逻辑:

(1).因为要查询当前用户下的所有课程分页查询信息,所以首先要拿到用户userId

Long userId = UserContext.getUser();

(2)分页查询并作非空判断,将userId当作条件传给eq,传一个page对象给page方法.

//2.分页查询Page<LearningLesson> page = lambdaQuery().eq(LearningLesson::getUserId, userId).page(query.toMpPage("latest_learn_time", false));List<LearningLesson> records = page.getRecords();if (CollUtils.isEmpty(records)) {return PageDTO.empty(page);}

(3)

先根据从数据库里面查询出来的records拿到每个课程的id。

再根据id调用课程的接口查询每个id对应的课程信息。

判空处理

用stream流的方式将每个课程的id和对应的课程数据放在map中。

//3.查询课程信息//3.1获取课程idSet<Long> Ids = records.stream().map(LearningLesson::getCourseId).collect(Collectors.toSet());//3.2查询课程信息List<CourseSimpleInfoDTO> infoList = courseClient.getSimpleInfoList(Ids);if (CollUtils.isEmpty(infoList)) {throw new BadRequestException("课程信息不存在");}//3.3把课程集合处理成map,key是courseId,value是course本身Map<Long, CourseSimpleInfoDTO> cMap = infoList.stream().collect(Collectors.toMap(CourseSimpleInfoDTO::getId, c -> c));

 (4)

创建一个VO空数组

将po拷贝到VO中

将课程信息set到VO中

最后返回分页查询信息。

//4.封装vo返回List<LearningLessonVO> list = new ArrayList<>(records.size());//循环遍历,吧LearningLesson转变成VOfor (LearningLesson r : records) {//4.1拷贝基础属性到LearningLessonVOLearningLessonVO learningLessonVO = BeanUtils.copyProperties(r, LearningLessonVO.class);//4.2获取课程信息,填充到voCourseSimpleInfoDTO courseSimpleInfoDTO = cMap.get(r.getCourseId());learningLessonVO.setCourseName(courseSimpleInfoDTO.getName());learningLessonVO.setCourseCoverUrl(courseSimpleInfoDTO.getCoverUrl());learningLessonVO.setSections(courseSimpleInfoDTO.getSectionNum());list.add(learningLessonVO);}return PageDTO.of(page, list);

 

 @Overridepublic PageDTO<LearningLessonVO> querMyLesson(PageQuery query) {//1.获取当前登录用户Long userId = UserContext.getUser();//2.分页查询Page<LearningLesson> page = lambdaQuery().eq(LearningLesson::getUserId, userId).page(query.toMpPage("latest_learn_time", false));List<LearningLesson> records = page.getRecords();if (CollUtils.isEmpty(records)) {return PageDTO.empty(page);}//3.查询课程信息//3.1获取课程idSet<Long> Ids = records.stream().map(LearningLesson::getCourseId).collect(Collectors.toSet());//3.2查询课程信息List<CourseSimpleInfoDTO> infoList = courseClient.getSimpleInfoList(Ids);if (CollUtils.isEmpty(infoList)) {throw new BadRequestException("课程信息不存在");}//3.3把课程集合处理成map,key是courseId,value是course本身Map<Long, CourseSimpleInfoDTO> cMap = infoList.stream().collect(Collectors.toMap(CourseSimpleInfoDTO::getId, c -> c));//4.封装vo返回List<LearningLessonVO> list = new ArrayList<>(records.size());//循环遍历,吧LearningLesson转变成VOfor (LearningLesson r : records) {//4.1拷贝基础属性到LearningLessonVOLearningLessonVO learningLessonVO = BeanUtils.copyProperties(r, LearningLessonVO.class);//4.2获取课程信息,填充到voCourseSimpleInfoDTO courseSimpleInfoDTO = cMap.get(r.getCourseId());learningLessonVO.setCourseName(courseSimpleInfoDTO.getName());learningLessonVO.setCourseCoverUrl(courseSimpleInfoDTO.getCoverUrl());learningLessonVO.setSections(courseSimpleInfoDTO.getSectionNum());list.add(learningLessonVO);}return PageDTO.of(page, list);}

 

http://www.dtcms.com/wzjs/837260.html

相关文章:

  • 北京网站模仿洛阳市建设厅网站
  • 网站哪里买外链海外学校网站建设
  • 丹徒做网站上海工商网上公示
  • 贵阳专业做网站公司有哪些网站开发实训指导书
  • 做商城网站技术要点饮料包装设计
  • 资源站建站技术如何去掉wordpress版权信息
  • 怎么提交自己的网站建设局工程网站
  • 苏州做网站最好公司正规网站制作公司是哪家
  • 学校网站建设年度总结如何做网站推广的策略
  • 江西安福县建设局网站wordpress 权限
  • 普宁网站建设公司北京好一点的微网站开发公司
  • 电商的推广方式有哪些seo最好的网站
  • 发簪做的比较好的网站rewite wordpress
  • 选择锦州网站建设有的网站域名解析错误
  • 做网站用的腾讯云服务器wordpress国外空间
  • 网站是怎么做360网站关键词排名优化
  • 秀设计网站建设个招聘网站
  • 广州建站服务商南京制作网页公司
  • 漆包线 东莞网站建设网站建设作者墙这个模板
  • 一般网站建设费用山西焦煤集团公司网站
  • thinkphp做网站好吗极速网站建设定制价格
  • 怎么查询网站开发时间计算机软件开发培训机构
  • 马鞍山做网站的公司wordpress 老萨
  • 服务器出租网站网站建设师薪资
  • 免费公司主页网站网站系统jsp模板
  • 白山市住房和建设局网站wordpress小说文章发布软件
  • 网站死链查询诗歌网站开发意义
  • 网站有死链怎么办wordpress获取动态页面
  • 芜湖市网站建设绵阳科技城建设
  • 特价网站源码黑龙江建设网网上办事大厅