mybatis-plus

@Service
@RequiredArgsConstructor
@Slf4j
public class CourseService extends ServiceImpl<CourseMapper, Course>
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

 

 

@Repository
public interface CourseMapper extends BaseMapper<Course> 
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

 

        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.0.7.1</version>
        </dependency>

        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-generator</artifactId>
            <version>3.0.7.1</version>
        </dependency>



        <!--分页插件 pagehelper -->
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <!-- 特别注意版本问题 -->
            <version>1.2.3</version>
        </dependency>

sptingboot 2.1.6

 

 

        List<CourseTeacher> oldCourseTeacherList = this.list(new QWrapper<CourseTeacher>().eq(CourseTeacher.FIELD_COURSE_ID,courseId).eq(CourseTeacher.FIELD_VALID, 'Y').orderByDesc(CourseTeacher.FIELD_CREATED_TIME));
    
        //删除
        if (!CollectionUtils.isEmpty(deList) && !this.remove(new QWrapper<CourseTeacher>().eq(CourseTeacher.FIELD_COURSE_ID,courseId).in(CourseTeacher.FIELD_TEACHER_ID,deList))){
            ResponseUtil.throwBusinessException("删除附件课程关联关系失败!");
        }
            QWrapper qWrapper = new QWrapper();
            qWrapper.eq("course_id", id);
            qWrapper.in("belong_type", belongType, belongCode);
            belongChannelsMapper.delete(qWrapper);

 

                List<String> courseIdList = belongInstitutionsList.stream().map((a) -> a.getCmoocAllId()).collect(Collectors.toList());

                list = this.list(new QWrapper<CourseSeries>()
                        .select(selectColumns)
                        .eq(StringUtils.isNotBlank(appId), CourseSeries.FIELD_APP_ID, appId)
                        .eq(!StringUtil.isEmpty(onlineStatus), CourseSeries.FIELD_ONLINE_STATUS, onlineStatus)
                        .in(!CollectionUtils.isEmpty(courseIdList), CourseSeries.FIELD_ID, courseIdList)
                        .like(StringUtils.isNotBlank(seriesTitle), CourseSeries.FIELD_SERIES_TITLE, seriesTitle)
                        .orderByDesc(CourseSeries.FIELD_CREATED_TIME));
        List<Course> courseList = courseService.lambdaQuery()
                .select(Course::getId, Course::getCourseStatus, Course::getStreamStatus)
                .eq(Course::getCourseResourceType, CourseResourceTypeEnum.live.status())
                .eq(Course::getCourseStatus, CourseStatusEnum.onShelf.status())
                .and(courseLambdaQueryWrapper -> courseLambdaQueryWrapper
                        .eq(Course::getStreamStatus, StreamStatusEnum.notStated.getStatus())
                        .or()
                        .eq(Course::getStreamStatus, StreamStatusEnum.living.getStatus())
                        .or()
                        .eq(Course::getStreamStatus, StreamStatusEnum.finish.getStatus()))
                .list();
        List<CourseChapter> courseChapters = courseChapterService.list(new LambdaQueryWrapper<CourseChapter>().eq(CourseChapter::getSeriesId, id));

        if (!CollectionUtils.isEmpty(courseChapters)) {
            List<String> chapterIds = new ArrayList<>();
            courseChapters.forEach(item -> {
                if (StringUtils.isNotBlank(item.getSeriesId())) {
                    chapterIds.add(item.getSeriesId());
                }
            });
        CategoryRelation categoryRelation = this.lambdaQuery().eq(CategoryRelation::getBusinessId,courseId).one();
        List<Course> courseList = courseService.lambdaQuery()
                .select(Course::getId, Course::getCourseStatus, Course::getStreamStatus)
                .eq(Course::getCourseResourceType, CourseResourceTypeEnum.live.status())
                .eq(Course::getCourseStatus, CourseStatusEnum.onShelf.status())
                .and(courseLambdaQueryWrapper -> courseLambdaQueryWrapper
                        .eq(Course::getStreamStatus, StreamStatusEnum.notStated.getStatus())
                        .or()
                        .eq(Course::getStreamStatus, StreamStatusEnum.living.getStatus())
                        .or()
                        .eq(Course::getStreamStatus, StreamStatusEnum.finish.getStatus()))
                .list();
      courseSeriesDto.setPlayCount(courseService.lambdaQuery().eq(Course::getSeriesId, seriesId).list().stream().map(Course::getPlayCount).count());



        int totalNum = list.stream().mapToInt(a -> a).sum();



        List result = CollectionUtils.isEmpty(list) ? new ArrayList<>() : (List)list.stream().map(CopyUtils::copyBeanToMap).collect(Collectors.toList());

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值