| | |
| | | package com.xinquan.system.service.impl; |
| | | |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xinquan.common.core.utils.page.BeanUtils; |
| | | import com.xinquan.common.core.utils.page.CollUtils; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.course.api.domain.Course; |
| | | import com.xinquan.course.api.domain.CourseCategory; |
| | | import com.xinquan.course.api.domain.CourseDTO; |
| | | import com.xinquan.course.api.feign.RemoteCourseService; |
| | | import com.xinquan.system.api.domain.vo.BannerVO; |
| | | import com.xinquan.system.domain.Banner; |
| | | import com.xinquan.system.mapper.BannerMapper; |
| | | import com.xinquan.system.service.BannerService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Service |
| | | public class BannerServiceImpl extends ServiceImpl<BannerMapper, Banner> implements BannerService { |
| | | |
| | | @Resource |
| | | private RemoteCourseService remoteCourseService; |
| | | /** |
| | | * 获取轮播图列表 |
| | | * |
| | | * @return 轮播图列表 |
| | | */ |
| | | @Override |
| | | public List<BannerVO> getBannerList() { |
| | | List<Banner> list = this.lambdaQuery().orderByDesc(Banner::getSortNum).list(); |
| | | return BeanUtils.copyList(list, BannerVO.class); |
| | | } |
| | | |
| | | @Override |
| | | public PageDTO<Banner> bannerList(Integer pageCurr, Integer pageSize) { |
| | | Page<Banner> page = this.lambdaQuery() |
| | | .orderByDesc(Banner::getSortNum) |
| | | .page(new Page<>(pageCurr, pageSize)); |
| | | if (CollUtils.isEmpty(page.getRecords())) { |
| | | return PageDTO.empty(page); |
| | | } |
| | | for (Banner record : page.getRecords()) { |
| | | if (record.getCourseId()!=null){ |
| | | Course data = remoteCourseService.getCourseById(record.getCourseId()).getData(); |
| | | if (data!=null){ |
| | | record.setCourseTitle(data.getCourseTitle()); |
| | | record.setCoverUrl(data.getCoverUrl()); |
| | | record.setTutor(data.getTutor()); |
| | | record.setPrice(data.getGeneralPrice()); |
| | | if (data.getCateId()!=null){ |
| | | CourseCategory data1 = remoteCourseService.getCategoryById(data.getCateId().toString()).getData(); |
| | | record.setCate(data1.getName()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return PageDTO.of(page, Banner.class); |
| | | } |
| | | |
| | | @Override |
| | | public PageDTO<Banner> courseList(Integer pageCurr, Integer pageSize, Integer courseType, Long cateId, String courseTitle, String tutor) { |
| | | CourseDTO courseDTO = new CourseDTO(); |
| | | courseDTO.setCourseType(courseType); |
| | | courseDTO.setCateId(cateId); |
| | | courseDTO.setCourseTitle(courseTitle); |
| | | courseDTO.setTutor(tutor); |
| | | courseDTO.setPageCurr(pageCurr); |
| | | courseDTO.setPageSize(pageSize); |
| | | |
| | | |
| | | return null; |
| | | } |
| | | } |