不做大哥好多年 不做大哥好多年
首页
  • MySQL
  • Redis
  • Elasticsearch
  • Kafka
  • Etcd
  • MongoDB
  • TiDB
  • RabbitMQ
  • 01.Python
  • 02.GO
  • 03.Java
  • 04.业务问题
  • 05.关键技术
  • 06.项目常识
  • 10.计算机基础
  • Docker
  • K8S
  • 容器原理
  • Istio
  • 01.GO基础
  • 02.面向对象
  • 03.并发编程
  • 04.常用库
  • 05.数据库操作
  • 06.Beego框架
  • 07.Beego商城
  • 08.GIN框架
  • 09.GIN论坛
  • 10.微服务
  • 01.Python基础
  • 02.Python模块
  • 03.Django
  • 04.Flask
  • 05.SYL
  • 06.Celery
  • 10.微服务
  • 01.Java基础
  • 02.面向对象
  • 03.Java进阶
  • 04.Web基础
  • 05.Spring框架
  • 100.微服务
  • 数据结构
  • 算法基础
  • 算法题分类
  • 前置知识
  • PyTorch
  • Langchain
  • Linux基础
  • Linux高级
  • Nginx
  • KeepAlive
  • ansible
  • zabbix
  • Shell
  • Linux内核

逍遥子

不做大哥好多年
首页
  • MySQL
  • Redis
  • Elasticsearch
  • Kafka
  • Etcd
  • MongoDB
  • TiDB
  • RabbitMQ
  • 01.Python
  • 02.GO
  • 03.Java
  • 04.业务问题
  • 05.关键技术
  • 06.项目常识
  • 10.计算机基础
  • Docker
  • K8S
  • 容器原理
  • Istio
  • 01.GO基础
  • 02.面向对象
  • 03.并发编程
  • 04.常用库
  • 05.数据库操作
  • 06.Beego框架
  • 07.Beego商城
  • 08.GIN框架
  • 09.GIN论坛
  • 10.微服务
  • 01.Python基础
  • 02.Python模块
  • 03.Django
  • 04.Flask
  • 05.SYL
  • 06.Celery
  • 10.微服务
  • 01.Java基础
  • 02.面向对象
  • 03.Java进阶
  • 04.Web基础
  • 05.Spring框架
  • 100.微服务
  • 数据结构
  • 算法基础
  • 算法题分类
  • 前置知识
  • PyTorch
  • Langchain
  • Linux基础
  • Linux高级
  • Nginx
  • KeepAlive
  • ansible
  • zabbix
  • Shell
  • Linux内核
  • python基础

  • python模块

  • django

  • flask

  • SYL

    • day01

    • day02

    • day03

    • day04

    • day05

    • day06

    • day07

      • 00.作业
      • 01.七牛云注册于基本使用
      • 02.使用七牛云进行视频点播原理
      • 03.七牛云上传后端接口
      • 04.七牛云上传js实现方法
      • 05.上传视频到七牛云django端实现
      • 06.上传视频课程到七牛云后存储到django后端接口
      • 07.视频防盗
      • 08.评论模块表结构分析
      • 09.获取对应课程评论接口
        • 10.对课程发布评论接口
      • day08

      • day09

      • day10

      • day11

      • day12

    • Celery

    • 微服务

    • python
    • SYL
    • day07
    xiaonaiqiang
    2021-03-10
    目录

    09.获取对应课程评论接口

    # 1.查询指定课程评论接口

    # 1.1 course/urls.py中还是查询课程的路由

    router.register(r'course', views.CourseViewSet)
    
    1

    # 1.2 course/serializers.py中添加评论相关查询

    from goods.serializers import GoodsSerializer
    class CourseDeepSerializer(CourseSerializer):
        comment = CommentSerializer(many=True)
        
    class CommentSerializer(serializers.ModelSerializer):
        user = serializers.CharField(source='user.username')
        to_user = serializers.SerializerMethodField(required=False)
    
        class Meta:
            model = Comment
            fields = '__all__'
    
        def get_to_user(self,row):
            if row.to_user:
                return row.to_user.username
            return ''
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16

    # 2.测试获取评论接口

    Http://192.168.56.100:8888/course/course/1/
    
    1

    • 接口结果
    {
        "id": 1,
        "goods_set": [
            {
                "id": 2,
                "create_time": "2020-10-13T03:42:53.449302Z",
                "update_time": "2020-10-13T03:42:53.449842Z",
                "goods_type": "1",
                "product_id": "1",
                "title": "Linux课程体系",
                "price": "55.00",
                "channel_type": "1",
                "period": 365,
                "is_launched": true,
                "course": 1
            }
        ],
        "comment": [
            {
                "id": 1,
                "user": "tom",
                "to_user": "zhangsan",
                "create_time": "2020-11-04T10:41:25.656763Z",
                "update_time": "2020-11-04T11:14:03.786135Z",
                "content": "tom第一次评论",
                "course": 1,
                "fid": null
            },
            {
                "id": 2,
                "user": "zhangsan",
                "to_user": "tom",
                "create_time": "2020-11-04T11:15:49.188855Z",
                "update_time": "2020-11-04T11:15:49.188898Z",
                "content": "zhangsan评论tom",
                "course": 1,
                "fid": 1
            },
            {
                "id": 3,
                "user": "tom",
                "to_user": "",
                "create_time": "2020-11-04T12:25:15.105667Z",
                "update_time": "2020-11-04T12:25:15.105946Z",
                "content": "<p>11111</p>\n",
                "course": 1,
                "fid": null
            }
        ],
        "chapters": [
            {
                "id": 1,
                "sections": [
                    {
                        "id": 1,
                        "create_time": "2020-10-11T14:57:14.151331Z",
                        "update_time": "2020-10-11T14:57:14.151364Z",
                        "title": "Linux 系统简介",
                        "serial_num": 1,
                        "learn_time": 1,
                        "video": "http://qi11dgv17.hn-bkt.clouddn.com/media/videos/20201011/07.%E6%A3%80%E6%9F%A5%E7%94%A8%E6%88%B7%E5%90%8D%E6%98%AF%E5%90%A6%E4%BD%BF%E7%94%A8%E6%8E%A5%E5%8F%A3.mp4",
                        "seq_num": 1,
                        "chapters": 1
                    },
                    {
                        "id": 2,
                        "create_time": "2020-10-15T13:26:21.528687Z",
                        "update_time": "2020-10-15T14:20:33.813725Z",
                        "title": "七牛测试上传图片",
                        "serial_num": 2,
                        "learn_time": 1,
                        "video": "http://qi11dgv17.hn-bkt.clouddn.com/media/videos/20201015/linux.jpg",
                        "seq_num": 2,
                        "chapters": 1
                    },
                    {
                        "id": 3,
                        "create_time": "2020-10-15T13:46:48.629237Z",
                        "update_time": "2020-10-15T13:46:48.629319Z",
                        "title": "七牛视频上传",
                        "serial_num": 3,
                        "learn_time": 1,
                        "video": "http://qi11dgv17.hn-bkt.clouddn.com/media/videos/20201015/07.%E6%A3%80%E6%9F%A5%E7%94%A8%E6%88%B7%E5%90%8D%E6%98%AF%E5%90%A6%E4%BD%BF%E7%94%A8%E6%8E%A5%E5%8F%A3.mp4",
                        "seq_num": 1,
                        "chapters": 1
                    }
                ],
                "create_time": "2020-10-11T14:56:34.585658Z",
                "update_time": "2020-10-11T14:56:34.585689Z",
                "title": "Linux 系统简介",
                "serial_num": 1,
                "course": 1
            }
        ],
        "create_time": "2020-10-11T14:44:31.252836Z",
        "update_time": "2020-10-15T14:19:32.879262Z",
        "title": "Linux入门课程",
        "desc": "要在实验楼愉快地学习,先要熟练地使用 Linux,本实验介绍 Linux 基本操作,shell 环境下的常用命令。",
        "img": "http://qi11dgv17.hn-bkt.clouddn.com/media/course/linux.jpg",
        "status": "1",
        "attention": 111,
        "learner": 222,
        "course_type": 3,
        "course_tag": [
            3
        ]
    }
    
    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

    # 3.前端代码

    • src\components\course_show.vue

    • src\components\common\comment.vue

    上次更新: 2024/3/13 15:35:10
    08.评论模块表结构分析
    10.对课程发布评论接口

    ← 08.评论模块表结构分析 10.对课程发布评论接口→

    最近更新
    01
    05.快递Agent智能体
    06-04
    02
    200.AI Agent核心概念
    06-04
    03
    105.Agent智能体梳理
    06-04
    更多文章>
    Theme by Vdoing | Copyright © 2019-2025 逍遥子 技术博客 京ICP备2021005373号
    • 跟随系统
    • 浅色模式
    • 深色模式
    • 阅读模式