• 谷粒学苑_第八天


    第八天

    1、添加课程基本信息完善

    (1)整合文本编辑器

    2、课程大纲管理

    (1)课程大纲列表显示

    (2)章节添加修改删除

    (3)小节添加修改删除

    3、课程信息确认

    (1)编写sql语句实现

    课程发布

    课程简介添加富文本编辑器

    略过,我选择用text就行,新版本配置富文本方法不一样

    课程大纲列表功能

    创建两个实体类,章节,小结,

    代码部分

    Vo类

    ChapterVo.java

    package com.lkw.eduservice.entity.chapter;
    
    import lombok.Data;
    
    import java.util.ArrayList;
    import java.util.List;
    
    @Data
    public class ChapterVo {
        private String id;
        private String title;
        private List<VideoVo> children = new ArrayList<>();
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    VideoVo.java

    package com.lkw.eduservice.entity.chapter;
    
    import lombok.Data;
    
    @Data
    public class VideoVo {
        private String id;
        private String title;
        private String videoSourceId;
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    Controller

    EduChapterController.java

    package com.lkw.eduservice.controller;
    
    import com.lkw.commonutils.R;
    import com.lkw.eduservice.entity.EduChapter;
    import com.lkw.eduservice.entity.chapter.ChapterVo;
    import com.lkw.eduservice.service.EduChapterService;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.web.bind.annotation.*;
    
    import java.util.List;
    
    @RestController
    @CrossOrigin
    @RequestMapping("/eduservice/chapter")
    public class EduChapterController {
    
    
        @Autowired
        private EduChapterService chapterService;
    
    
        //根据课程id查询章节小结
        @GetMapping("getChapterVideo/{courseId}")
        public R getChapterVideo(@PathVariable String courseId){
            List<ChapterVo> list=chapterService.getChapterVideoByCourseId(courseId);
            return R.ok().data("allChapterVideo",list);
    
        }
    
        //添加课程章节
        @PostMapping("addChapter")
        public R addChapter(@RequestBody EduChapter eduChapter) {
            chapterService.save(eduChapter);
            return R.ok();
        }
    
        //查询根据id课程章节
        @GetMapping("getChapterInfo/{chapterId}")
        public R getChapterInfo(@PathVariable String chapterId) {
            EduChapter chapterById = chapterService.getById(chapterId);
            return R.ok().data("chapter", chapterById);
        }
    
    
        //修改课程章节
        @PostMapping("updateChapter")
        public R updateChapter(@RequestBody EduChapter eduChapter) {
            chapterService.updateById(eduChapter);
            return R.ok();
        }
    
        //删除课程章节
        @DeleteMapping("{chapterId}")
        public R deleteChapter(@PathVariable String chapterId) {
            boolean result = chapterService.deleteChapterById(chapterId);
            if (result) {
                return R.ok();
            } else {
                return R.error();
            }
        }
    
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64

    Service

    EduChapterService

    package com.lkw.eduservice.service;
    
    import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
    import com.lkw.eduservice.entity.EduChapter;
    import com.baomidou.mybatisplus.extension.service.IService;
    import com.lkw.eduservice.entity.EduVideo;
    import com.lkw.eduservice.entity.chapter.ChapterVo;
    import com.lkw.servicebase.exceptionhandler.GuliException;
    
    import java.util.List;
    
    /**
    * @author 
    * @description 针对表【edu_chapter(课程)】的数据库操作Service
    * @createDate 2022-10-07 16:40:12
    */
    public interface EduChapterService extends IService<EduChapter> {
    
        List<ChapterVo> getChapterVideoByCourseId(String courseId);
    
        boolean deleteChapterById(String chapterId);
    
        void removeChapterByCourseId(String courseId) ;
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25

    Impl

    EduChapterServiceImpl

    package com.lkw.eduservice.service.impl;
    
    import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
    import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
    import com.lkw.eduservice.entity.EduChapter;
    import com.lkw.eduservice.entity.EduVideo;
    import com.lkw.eduservice.entity.chapter.ChapterVo;
    import com.lkw.eduservice.entity.chapter.VideoVo;
    import com.lkw.eduservice.service.EduChapterService;
    import com.lkw.eduservice.mapper.EduChapterMapper;
    import com.lkw.eduservice.service.EduVideoService;
    import com.lkw.servicebase.exceptionhandler.GuliException;
    import org.springframework.beans.BeanUtils;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;
    
    import java.util.ArrayList;
    import java.util.List;
    
    /**
    * @author 李可文
    * @description 针对表【edu_chapter(课程)】的数据库操作Service实现
    * @createDate 2022-10-07 16:40:12
    */
    @Service
    public class EduChapterServiceImpl extends ServiceImpl<EduChapterMapper, EduChapter>
        implements EduChapterService {
    
        @Autowired
        private EduVideoService eduVideoService;
    
        @Override
        public List<ChapterVo>  getChapterVideoByCourseId(String courseId) {
            //1根据课程id查询课程里面所有的章节
            QueryWrapper<EduChapter> chapterQueryWrapper = new QueryWrapper<>();
            chapterQueryWrapper.eq("course_id", courseId);
            List<EduChapter> eduChapterList = baseMapper.selectList(chapterQueryWrapper);
            //2根据课程id查询课程里面所有的小节
            QueryWrapper<EduVideo> videoQueryWrapper = new QueryWrapper<>();
            videoQueryWrapper.eq("course_id", courseId);
            List<EduVideo> eduVideoList = eduVideoService.list(videoQueryWrapper);
            //创建list集合进行最终封装
            ArrayList<ChapterVo> finalList = new ArrayList<>();
            //3遍历查询章节list集合进行封装
            for (int i = 0; i < eduChapterList.size(); i++) {
                EduChapter eduChapter = eduChapterList.get(i);
                ChapterVo chapterVo = new ChapterVo();
                BeanUtils.copyProperties(eduChapter, chapterVo);
                finalList.add(chapterVo);
    
                ArrayList<VideoVo> finalVideoVoList = new ArrayList<>();
                //4遍历查询小节list集合进行封装
                for (int j = 0; j < eduVideoList.size(); j++) {
                    EduVideo eduVideo = eduVideoList.get(j);
                    if (eduVideo.getChapterId().equals(chapterVo.getId())) {
                        VideoVo videoVo = new VideoVo();
                        BeanUtils.copyProperties(eduVideo, videoVo);
                        finalVideoVoList.add(videoVo);
                    }
                }
    
                chapterVo.setChildren(finalVideoVoList);
            }
    
    
            return finalList;
        }
    
        //删除章节的方法
        @Override
        public boolean deleteChapterById(String chapterId) {
            //根据章节id,如果有小节数据则不能删除
            QueryWrapper<EduVideo> eduVideoWrapper = new QueryWrapper<>();
            eduVideoWrapper.eq("chapter_id", chapterId);
            int count =(int) eduVideoService.count(eduVideoWrapper);
            if (count > 0) {
                //有小节
                throw new GuliException(20001, "有小节,无法删除");
            }
            int i = baseMapper.deleteById(chapterId);
    
            return i > 0;
        }
    
        @Override
        public void removeChapterByCourseId(String courseId) {
            QueryWrapper<EduChapter> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("course_id", courseId);
            baseMapper.delete(queryWrapper);
        }
    
    
    }
    
    
    
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    丝袜哥测试:

    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-7kWUGlaC-1667554945363)(md%E5%9B%BE%E7%89%87/image-20221009171113755.png)]

    前端

    src\api\chapter\chapter.js

    import request from '@/utils/request'
    
    
    export default{
    
     
        //根据课程id获取章节和小节数据列表
        getAllChapterVideo(courseId){
            return request({
                url: 'http://localhost:8001/eduservice/chapter/getChapterVideo/'+courseId,
                method: 'get'
            })
        } 
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15

    chapter.vue

    
    
    
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    前端测试

    修改课程id

    后端

    对EduCourse

    controller

    package com.lkw.eduservice.controller;
    
    import com.lkw.commonutils.R;
    import com.lkw.eduservice.entity.vo.CourseInfoVo;
    import com.lkw.eduservice.service.EduCourseService;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.web.bind.annotation.*;
    
    @RestController
    @CrossOrigin
    @RequestMapping("/eduservice/course")
    public class EduCourseController {
    
    
    
        @Autowired
        private EduCourseService courseService;
        //添加课程基本信息的方法
        @PostMapping("addCourseInfo")
        public R addCourseInfo(@RequestBody CourseInfoVo courseInfoVo){
    
            String id=courseService.saveCourseInfo(courseInfoVo);
            return R.ok().data("courseId",id);
        }
    
    
        @GetMapping("getCourseInfo/{courseId}")
        public R getCourseInfo(@PathVariable String courseId){
            CourseInfoVo courseInfoVo=courseService.getCourseInfo(courseId);
            return R.ok().data("courseInfoVo",courseInfoVo);
        }
    
    
        @PostMapping("updateCourseInfo")
        public R updateCourseInfo(@RequestBody CourseInfoVo courseInfoVo){
    
    
            courseService.updateCourseInfo(courseInfoVo);
            return R.ok();
        }
    
    
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44

    Service

    impl

    package com.lkw.eduservice.service.impl;
    
    import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
    import com.lkw.eduservice.entity.EduCourse;
    import com.lkw.eduservice.entity.EduCourseDescription;
    import com.lkw.eduservice.entity.vo.CourseInfoVo;
    import com.lkw.eduservice.service.EduCourseDescriptionService;
    import com.lkw.eduservice.service.EduCourseService;
    import com.lkw.eduservice.mapper.EduCourseMapper;
    import com.lkw.servicebase.exceptionhandler.GuliException;
    import org.springframework.beans.BeanUtils;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;
    
    /**
    * @author 李可文
    * @description 针对表【edu_course(课程)】的数据库操作Service实现
    * @createDate 2022-10-06 15:55:48
    */
    @Service
    public class EduCourseServiceImpl extends ServiceImpl<EduCourseMapper, EduCourse>
        implements EduCourseService{
    
    
    
        @Autowired
        private EduCourseDescriptionService courseDescriptionService;
    
        @Override
        public String saveCourseInfo(CourseInfoVo courseInfoVo) {
    
            //Vo转换成entity类
            EduCourse eduCourse = new EduCourse();
            BeanUtils.copyProperties(courseInfoVo,eduCourse );
    
            int insert = baseMapper.insert(eduCourse);
            if(insert<=0){
                //添加失败
                throw new GuliException(20001,"添加课程失败");
            }
            //添加成功获取id
            String cid = eduCourse.getId();
    
            //课程描述
            EduCourseDescription courseDescription = new EduCourseDescription();
            courseDescription.setDescription(courseInfoVo.getDescription());
            courseDescription.setId(cid);
            courseDescriptionService.save(courseDescription);
    
            return cid;
        }
    
        //根据课程id查询课程基本信息
        @Override
        public CourseInfoVo getCourseInfo(String courseId) {
            EduCourse eduCourse = baseMapper.selectById(courseId);
            CourseInfoVo courseInfoVo = new CourseInfoVo();
            BeanUtils.copyProperties(eduCourse,courseInfoVo);
            //查询描述表
            EduCourseDescription courseDescription = courseDescriptionService.getById(courseId);
            courseInfoVo.setDescription(courseDescription.getDescription());
    
            return courseInfoVo;
        }
    
    
        @Override
        public void updateCourseInfo(CourseInfoVo courseInfoVo) {
            //1 修改课程表
            EduCourse eduCourse = new EduCourse();
            BeanUtils.copyProperties(courseInfoVo, eduCourse);
            int update = baseMapper.updateById(eduCourse);
            if (update == 0) {
                throw new GuliException(20001, "修改课程信息失败");
            }
    
            //2 修改描述表
            EduCourseDescription description = new EduCourseDescription();
            description.setId(courseInfoVo.getId());
            description.setDescription(courseInfoVo.getDescription());
            courseDescriptionService.updateById(description);
        }
    
    }
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    丝袜哥测试

    前端
    api

    course.js

    import request from '@/utils/request'
    
    
    export default{
    
        //添加课程信息
        addCourseInfo(courseInfo){
            return request({
                url: `http://localhost:8001/eduservice/course/addCourseInfo`,
                method: 'post',
                data: courseInfo
            })
    
    
        },
    
        //查询所有讲师
        getListTeacher(){
            return request({
                url: 'http://localhost:8001/eduservice/teacher/findAll',
                method: 'get'
            })
        } ,
    
        //根据课程id查询课程基本信息
    
        getCourseInfoId(id){
            return request({
                url: 'http://localhost:8001/eduservice/course/getCourseInfo/'+id,
                method: 'get'
            })
        } ,
        //根据课程id查询课程基本信息
    
        updateCourseInfoId(courseInfo){
            return request({
                url: 'http://localhost:8001/eduservice/course/updateCourseInfo/',
                method: 'post',
                data: courseInfo
            })
        } ,
    
    
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45

    chapter.vue的这两个跳转方法添加id

          previous(){ 
              this.$router.push({path:'/course/info/'+this.courseId})
          },
            next(){
              //跳转到第三步
              this.$router.push({path:'/course/publish/'+this.courseId})
          },
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    info.vue数据回显

    created添加获取id代码,并获取查询:

        created(){
            //获取id
              if(this.$route.params&&this.$route.params.id){
              this.courseId=this.$route.params.id
              console.log(this.courseId)
              this.getInfo()
              this.getListTeacher()
              }else{
    
                this.getListTeacher()
                this.getOneSubject()
              }
        }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    getInfo方法:

     getInfo(){
                course.getCourseInfoId(this.courseId)
                .then(response=>{
                    this.courseInfo=response.data.courseInfoVo
                })
                subject.getSubjectList()
                .then(response=>{
                    this.subjectOneList=response.data.list
                    //遍历一级分类
                    for(var i=0;i
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    403错误是跨域,或者路径写错的找不到错误

    下拉回显:

    底层,使用存储的id和所有选项的id比较有相同的显示相同选项,没有相同的显示id

    添加或修改的方法

            updateCourse(){
                course.updateCourseInfoId(this.courseInfo)
                .then(response=>{
                    
                    //提示
                    this.$message({
                        type: 'success', 
                        message: '修改课程信息成功'
                    })
    
                //跳转到第二步
                this.$router.push({path:'/course/chapter/'+this.courseId})
    
                })
                
            },
    
            saveOrUpdate(){
                if(!this.courseInfo.id){
                    //添加
                    this.addCourse()
                }else{
                    this.updateCourse()
                }
    
            },
    
    
            addCourse(){
    
                course.addCourseInfo(this.courseInfo)
                .then(response=>{
                    //提示
                    this.$message({
                        type: 'success', 
                        message: '添加课程信息成功'
                    })
    
                //跳转到第二步
                this.$router.push({path:'/course/chapter/'+response.data.courseId})
    
                })
            },
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43

    课程管理

    前端
    
    
        
            
                
            
            
                
            
        
        
    
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17

    添加编辑删除章节

    后端

    前面写了的

    前端

    api:

    import request from '@/utils/request'
    
    export default{
        //根据课程id获取章节和小节数据列表
        getAllChapterVideo(courseId){
            return request({
                url: 'http://localhost:8001/eduservice/chapter/getChapterVideo/'+courseId,
                method: 'get'
            })
        } ,
        //添加章节
        addChapter(chapter){
            return request({
                url: 'http://localhost:8001/eduservice/chapter/addChapter',
                method: 'post',
                data: chaper
            })
        } ,
        //根据id查询章节
        getChapter(chapterId){
            return request({
                url: 'http://localhost:8001/eduservice/chapter/getChapterInfo/'+chapterId,
                method: 'get'
            })
        },
        //修改章节
        updateChapter(chaper){
            return request({
                url: 'http://localhost:8001/eduservice/chapter/updateChapter',
                method: 'post',
                data: chaper
            })
        },
        //删除
        deleteChapter(chapterId){ 
            return request({
                url: 'http://localhost:8001/eduservice/chapter/'+chapterId,
                method: 'delete'
            })
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41

    清除添加显示

    添加数据回显,和编辑删除按钮

    
    
    
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
    • 202
    • 203
    • 204
    • 205
    • 206
    • 207
    • 208
    • 209
    • 210
    • 211
    • 212
    • 213
    • 214
    • 215
    • 216
    • 217
    • 218
    • 219
    • 220
    • 221
    • 222
    • 223
    • 224
    • 225
    • 226
    • 227
    • 228
    • 229
    • 230
    • 231
    • 232
    • 233
    • 234
    • 235
    • 236
    • 237
    • 238
    • 239
    • 240
    • 241
    • 242
    • 243
    • 244
    • 245
    • 246
    • 247
    • 248

    效果:
    在这里插入图片描述

    小节操作

    前端暂时没有实现更新操作

    后端
    package com.lkw.eduservice.controller;
    
    import com.lkw.commonutils.R;
    import com.lkw.eduservice.entity.EduVideo;
    import com.lkw.eduservice.service.EduVideoService;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.web.bind.annotation.*;
    
    @RestController
    @CrossOrigin
    @RequestMapping("/eduservice/video")
    public class EduVideoController {
        @Autowired
        private EduVideoService videoService;
    
        //添加小节
        @PostMapping("addVideo")
        public R addVideo(@RequestBody EduVideo eduVideo){
            videoService.save(eduVideo);
            return R.ok();
        }
    
        @PostMapping("updateVideo")
        public R updateVideo(@RequestBody EduVideo eduVideo){
            videoService.updateById(eduVideo);
            return R.ok();
        }
    
    
        //删除小节
        //需要完善,删小节时,把视频删除
        @DeleteMapping("{id}")
        public R deleteVideo(@PathVariable String id){
            videoService.removeById(id);
            return R.ok();
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    前端

    chapter.vue

    
    
    
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
    • 202
    • 203
    • 204
    • 205
    • 206
    • 207
    • 208
    • 209
    • 210
    • 211
    • 212
    • 213
    • 214
    • 215
    • 216
    • 217
    • 218
    • 219
    • 220
    • 221
    • 222
    • 223
    • 224
    • 225
    • 226
    • 227
    • 228
    • 229
    • 230
    • 231
    • 232
    • 233
    • 234
    • 235
    • 236
    • 237
    • 238
    • 239
    • 240
    • 241
    • 242
    • 243
    • 244
    • 245
    • 246
    • 247
    • 248
    • 249
    • 250
    • 251
    • 252
    • 253
    • 254
    • 255
    • 256
    • 257
    • 258
    • 259
    • 260
    • 261
    • 262
    • 263
    • 264
    • 265
    • 266
    • 267
    • 268
    • 269
    • 270
    • 271
    • 272
    • 273
    • 274
    • 275
    • 276
    • 277
    • 278
    • 279
    • 280
    • 281
    • 282
    • 283
    • 284
    • 285
    • 286
    • 287
    • 288
    • 289
    • 290
    • 291
    • 292
    • 293
    • 294
    • 295
    • 296
    • 297
    • 298
    • 299
    • 300
    • 301
    • 302
    • 303
    • 304
    • 305
    • 306
    • 307
    • 308
    • 309
    • 310
    • 311
    • 312
    • 313
    • 314
    • 315
    • 316
    • 317
    • 318
    • 319
    • 320
    • 321
    • 322
    • 323
    • 324
    • 325
    • 326
    • 327
    • 328
    • 329
    • 330
    • 331
    • 332
    • 333
    • 334
    • 335
    • 336
    • 337
    • 338
    • 339
    • 340
    • 341
    • 342
    • 343
    • 344
    • 345
    • 346
    • 347
    • 348
    • 349
    • 350

    chapter.js

    import request from '@/utils/request'
    
    
    export default{
    
     
        //根据课程id获取章节和小节数据列表
        getAllChapterVideo(courseId){
            return request({
                url: 'http://localhost:8001/eduservice/chapter/getChapterVideo/'+courseId,
                method: 'get'
            })
        } ,
        //添加章节
        addChapter(chapter){
            return request({
                url: 'http://localhost:8001/eduservice/chapter/addChapter',
                method: 'post',
                data: chapter
            })
        } ,
        //根据id查询章节
        getChapter(chapterId){
            return request({
                url: 'http://localhost:8001/eduservice/chapter/getChapterInfo/'+chapterId,
                method: 'get'
            })
        },
        //修改章节
        updateChapter(chaper){
            return request({
                url: 'http://localhost:8001/eduservice/chapter/updateChapter',
                method: 'post',
                data: chaper
            })
        },
        //删除
        deleteChapter(chapterId){ 
            return request({
                url: 'http://localhost:8001/eduservice/chapter/'+chapterId,
                method: 'delete'
            })
        }
    
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46

    课程信息确认

    使用手动sql的形式

    内连接:查询有关系的连接

    左外连接,

    右外连接

    定义一个vo对象

    package com.lkw.eduservice.entity.vo;
    
    import lombok.Data;
    
    import java.io.Serializable;
    
    @Data
    public class CoursePublishVo implements Serializable {
        private String id;
        private String title;
        private String cover;
        private Integer lessonNum;
        private String subjectLevelOne;
        private String subjectLevelTwo;
        private String teacherName;
        private String price;//只用于显示
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    impl

        @Override
        public CoursePublishVo publishCourseInfo(String id) {
            //调用mapper
            return baseMapper.getPublishCourseInfo(id);
        }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    server

        CoursePublishVo publishCourseInfo(String id);
    
    • 1

    mapper.xml

      <select id="getPublishCourseInfo" resultType="com.lkw.eduservice.entity.vo.CoursePublishVo">/*方法名,返回值类型*//*resultMap也是定义*/
        SELECT ec.id,ec.title,ec.price,ec.lesson_num AS lessonNum,ec.cover,
               et.`name` AS teacherName,
               es1.title AS subjectLevelOne,
               es2.title AS subjectLevelTwo
        from edu_course ec LEFT OUTER JOIN edu_course_description ecd ON ec.id=ecd.id
                           LEFT OUTER JOIN edu_teacher et ON ec.teacher_id=et.id
                           LEFT OUTER JOIN edu_subject es1 ON ec.subject_parent_id=es1.id
                           LEFT OUTER JOIN edu_subject es2 ON ec.subject_id=es2.id
        WHERE ec.id=#{courseId}
        select>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    可能会出现老师的错误(但是我没出现这个错误)

    是因为xml是静态资源,

    maven在加载的时候把静态资源可能不会加载

    //解决方法1:将xml等资源手动复制到target

    //解决方法2:在pom.xml或者application.properties
    在这里插入图片描述

    在这里插入图片描述

    在这里插入图片描述

  • 相关阅读:
    canvas 状态管理
    FT2004(D2000)开发实战之启动流程介绍
    嵌入式养成计划-49----ARM--计算机相关理论--ARM相关内容
    论文解析——AMD EPYC和Ryzen处理器系列的开创性的chiplet技术和设计
    springboot整合redis集群
    nginx网站服务
    Python高级语法-类访问控制
    热门编程语言那么多,该选择哪个
    史上最全MATLAB误差分析工具箱,不看别后悔 【矢量化代码、效率嘎嘎快、支持计算50种指标】
    产品经理基础--04流程图与结构图
  • 原文地址:https://blog.csdn.net/m0_52070517/article/details/127693643