zoukankan      html  css  js  c++  java
  • mp service层 增删改查

    后端:
    //添加章节
    @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 eduChapter = chapterService.getById(chapterId);
    return R.ok().data("chapter",eduChapter);

    }

    //修改章节
    @PostMapping("updateChapter")
    public R updateChapter(@RequestBody EduChapter eduChapter) {
    chapterService.updateById(eduChapter);
    return R.ok();
    }

    //删除的方法
    @DeleteMapping("{chapterId}")
    public R deleteChapter(@PathVariable String chapterId) {
    chapterService.removeById(chapterId);
    return R.ok();
    }

    前端使用:
    //添加章节
        addChapter(chapter) {
            return request({
                url: '/eduservice/chapter/addChapter',
                method: 'post',
                data:chapter
            })
        },
        //根据id查询章节
        getChapter(courseId) {
            return request({
                url: '/eduservice/chapter/getChapterInfo/'+courseId,
                method: 'get'
            })
        },
        //修改章节
        updateChapter(chapter) {
            return request({
                url: '/eduservice/chapter/updateChapter',
                method: 'post',
                data: 'chapter'
            })
        },
        //删除章节
        deleteChapter(chapterId) {
            return request({
                url: '/eduservice/chapter/'+chapterId,
                method: 'delete'
            })
        } 
  • 相关阅读:
    删除查询出以外的数据
    查询头3条
    查询共多少条记录
    Linq查询非泛型集合要指定Student类型(比如List)
    Linq to 泛型集合查询集合包括大写M和年龄小于等于18
    LINQ查询字符串判断是否大写
    LINQ查询数组里面是否包含某值
    Lambda表达式
    构建之法(四)
    构建之法(三)
  • 原文地址:https://www.cnblogs.com/zjazn/p/14451851.html
Copyright © 2011-2022 走看看