tubinyan 5 лет назад
Родитель
Сommit
035dd934e7

+ 258 - 10
API Doc.md

@@ -1,6 +1,6 @@
 ### User
 
-1.  用户注册  POST /user/register
+1  用户注册  POST /user/register
 
 ```
     /**
@@ -51,7 +51,7 @@
      */
 ```
 
-2.  用户登录  POST /user/login
+2  用户登录  POST /user/login
 
 ```
     /**
@@ -93,7 +93,7 @@
      */
 ```
 
-3.  用户充值 POST /user/recharge
+3  用户充值 POST /user/recharge
 
 ```
     /**
@@ -136,7 +136,7 @@
      */
 ```
 
-4.  获取用户 GET /user/{uid}
+4 获取用户 GET /user/{uid}
 
 ```
     /**
@@ -171,7 +171,7 @@
 
 ### Course
 
-1. 获取一门课程 GET /course/{courseId}?uid={uid}
+1 获取一门课程 GET /course/{courseId}?uid={uid}
 
 ```
     /**
@@ -213,7 +213,7 @@
      */
 ```
 
-2. 根据关键字 分页获取课程列表 GET /course/all/{page}?uid={uid}&key={key}
+2 根据关键字 分页获取课程列表 GET /course/all/{page}?uid={uid}&key={key}
 
 ```
     /**
@@ -328,7 +328,8 @@
      */
 ```
 
-3. 根据课程分类 分页获取课程列表
+3、 根据课程分类 分页获取课程列表 GET course/type/{page}?uid={uid}&type={type}
+
 ```
     /**
      * @api {GET} /course/type/{page} getCoursesByType
@@ -427,7 +428,7 @@
      */
 ```
 
-4. 获取用户已购买的课程列表 GET course/sid/{sid}
+4 获取用户已购买的课程列表 GET course/sid/{sid}
 
 ```
 GET course/sid/2
@@ -451,7 +452,7 @@ GET course/sid/2
 ]
 ```
 
-5. 获取教师可管理的课程列表 GET course/tid/{tid}
+5 获取教师可管理的课程列表 GET course/tid/{tid}
 
 ```
 GET course/tid/1
@@ -475,7 +476,7 @@ GET course/tid/1
 ]
 ```
 
-6. 创建一门课程 POST course/create
+6 创建一门课程 POST course/create
 
 ```
     /**
@@ -542,3 +543,250 @@ GET course/tid/1
          }
     */
 ```
+
+### CourseWare
+
+1、 获取某课件 GET course_ware/{courseWareId}?uid={uid}
+
+```
+    /**
+     * @api {GET} /course_ware/{courseWareId} getCourseWare
+     * @apiVersion 1.0.0
+     * @apiGroup CourseWareController
+     * @apiName getCourseWare
+     * @apiParam (可选请求参数) {Number} uid
+     * @apiParam (请求参数) {Number} courseWareId
+     * @apiParamExample 请求参数示例
+     * course_ware/2?uid=2
+     * @apiSuccess (响应结果) {Number} id
+     * @apiSuccess (响应结果) {Number} courseId
+     * @apiSuccess (响应结果) {Number} number
+     * @apiSuccess (响应结果) {String} title
+     * @apiSuccess (响应结果) {String} fileName
+     * @apiSuccess (响应结果) {String} fileType
+     * @apiSuccess (响应结果) {String} fileSize
+     * @apiSuccess (响应结果) {Boolean} freeFlag
+     * @apiSuccess (响应结果) {Boolean} downloadFlag
+     * @apiSuccess (响应结果) {Boolean} availableFlag
+     * @apiSuccess (响应结果) {Number} uploadTime
+     * @apiSuccessExample 响应结果示例
+       {
+           "id": 2,
+           "courseId": 1,
+           "number": 1,
+           "title": "00 - Overview",
+           "fileName": null,
+           "fileType": null,
+           "fileSize": null,
+           "freeFlag": false,
+           "downloadFlag": true,
+           "availableFlag": false,
+           "uploadTime": "2020-12-18T02:00:00.000+00:00"
+       }
+     */
+```
+
+2、 获取一门课程的所有课件 GET course_ware/course/{courseId}?uid={uid}
+
+```
+GET course_ware/course/1
+响应结果示例
+[
+    {
+        "id": 2,
+        "courseId": 1,
+        "number": 1,
+        "title": "00 - Overview",
+        "fileName": "33c70532-551f-43a9-b18f-5bdf2d71b77d.png",
+        "fileType": "png",
+        "fileSize": "1.12 MB",
+        "freeFlag": false,
+        "downloadFlag": true,
+        "availableFlag": false,
+        "uploadTime": "2020-12-18T02:00:00.000+00:00"
+    },
+    ...
+]
+```
+
+3、 创建课件 POST course_ware/create
+
+```
+    /**
+     * @api {POST} /course_ware/create createCourseWare
+     * @apiVersion 1.0.0
+     * @apiGroup CourseWareController
+     * @apiName createCourseWare
+     * @apiParam (请求体) {Number} courseId
+     * @apiParam (请求体) {Number} number 课件在本课程内的序号
+     * @apiParam (请求体) {String} title
+     * @apiParam (请求体) {String} fileName
+     * @apiParam (请求体) {String} fileType
+     * @apiParam (请求体) {String} fileSize
+     * @apiParam (请求体) {Boolean} freeFlag
+     * @apiParam (请求体) {Boolean} downloadFlag
+     * @apiParam (请求体) {Number} uploadTime
+     * @apiParamExample 请求体示例
+        {
+            "courseId": 1,
+            "number": 53,
+            "title": "测试课件",
+            "fileName": "123.pdf",
+            "fileType": "pdf",
+            "fileSize": "11 MB",
+            "freeFlag": false,
+            "downloadFlag": true,
+            "availableFlag": true
+        }
+     * @apiSuccess (响应结果) {Number} code
+     * @apiSuccess (响应结果) {String} msg
+     * @apiSuccess (响应结果) {Object} data
+     * @apiSuccess (响应结果) {Number} data.id
+     * @apiSuccess (响应结果) {Number} data.courseId
+     * @apiSuccess (响应结果) {Number} data.number
+     * @apiSuccess (响应结果) {String} data.title
+     * @apiSuccess (响应结果) {String} data.fileName
+     * @apiSuccess (响应结果) {String} data.fileType
+     * @apiSuccess (响应结果) {String} data.fileSize
+     * @apiSuccess (响应结果) {Boolean} data.freeFlag
+     * @apiSuccess (响应结果) {Boolean} data.downloadFlag
+     * @apiSuccess (响应结果) {Boolean} data.availableFlag
+     * @apiSuccess (响应结果) {Number} data.uploadTime
+     * @apiSuccessExample 响应结果示例
+        {
+            "code": 1,
+            "msg": "课件创建成功",
+            "data": {
+                "id": 198,
+                "courseId": 1,
+                "number": 53,
+                "title": "测试课件",
+                "fileName": "123.pdf",
+                "fileType": "pdf",
+                "fileSize": "11 MB",
+                "freeFlag": false,
+                "downloadFlag": true,
+                "availableFlag": false,
+                "uploadTime": "2021-03-13T03:18:03.730+00:00"
+            }
+        }
+     */
+```
+
+4、更新课件 POST course_ware/update
+
+```
+    /**
+     * @api {POST} /course_ware/create createCourseWare
+     * @apiVersion 1.0.0
+     * @apiGroup CourseWareController
+     * @apiName createCourseWare
+     * @apiParam (请求体) {Number} courseId
+     * @apiParam (请求体) {Number} number 课件在本课程内的序号
+     * @apiParam (请求体) {String} title
+     * @apiParam (请求体) {String} fileName
+     * @apiParam (请求体) {String} fileType
+     * @apiParam (请求体) {String} fileSize
+     * @apiParam (请求体) {Boolean} freeFlag
+     * @apiParam (请求体) {Boolean} downloadFlag
+     * @apiParam (请求体) {Number} uploadTime
+     * @apiParamExample 请求体示例
+        {
+            "id": 198,
+            "courseId": 1,
+            "number": 53,
+            "title": "测试课件",
+            "fileName": "123.pdf",
+            "fileType": "pdf",
+            "fileSize": "11 MB",
+            "freeFlag": false,
+            "downloadFlag": true,
+            "availableFlag": true
+        }
+     * @apiSuccess (响应结果) {Number} code
+     * @apiSuccess (响应结果) {String} msg
+     * @apiSuccess (响应结果) {Object} data
+     * @apiSuccess (响应结果) {Number} data.id
+     * @apiSuccess (响应结果) {Number} data.courseId
+     * @apiSuccess (响应结果) {Number} data.number
+     * @apiSuccess (响应结果) {String} data.title
+     * @apiSuccess (响应结果) {String} data.fileName
+     * @apiSuccess (响应结果) {String} data.fileType
+     * @apiSuccess (响应结果) {String} data.fileSize
+     * @apiSuccess (响应结果) {Boolean} data.freeFlag
+     * @apiSuccess (响应结果) {Boolean} data.downloadFlag
+     * @apiSuccess (响应结果) {Boolean} data.availableFlag
+     * @apiSuccess (响应结果) {Number} data.uploadTime
+     * @apiSuccessExample 响应结果示例
+        {
+            "code": 1,
+            "msg": "课件更新成功",
+            "data": {
+                "id": 198,
+                "courseId": 1,
+                "number": 53,
+                "title": "测试课件abc",
+                "fileName": "123.pdf",
+                "fileType": "pdf",
+                "fileSize": "11 MB",
+                "freeFlag": false,
+                "downloadFlag": true,
+                "availableFlag": false,
+                "uploadTime": "2021-03-13T03:25:59.948+00:00"
+            }
+        }
+     */
+```
+
+5、 删除课件 POST course_ware/delete/{courseWareId}
+
+```
+    /**
+     * @api {POST} /course_ware/delete/{courseWareId} deleteCourseWare
+     * @apiVersion 1.0.0
+     * @apiGroup CourseWareController
+     * @apiName deleteCourseWare
+     * @apiParam (请求参数) {Number} courseWareId
+     * @apiParamExample 请求参数示例
+     * POST course_ware/delete/198
+     * @apiSuccess (响应结果) {Number} code
+     * @apiSuccess (响应结果) {String} msg
+     * @apiSuccess (响应结果) {String} data
+     * @apiSuccessExample 响应结果示例
+        {
+            "code": 1,
+            "msg": "课件删除成功",
+            "data": null
+        }
+     */
+```
+
+### File
+ 
+1、 上传文件 POST  file/upload
+ 
+    /**
+     * @api {POST} /file/upload upload
+     * @apiVersion 1.0.0
+     * @apiGroup FileController
+     * @apiName upload
+     * form-data
+     * @apiParam (请求参数) {File} file
+        key:"file"  value:"android.jpg"
+     * @apiSuccess (响应结果) {Number} code
+     * @apiSuccess (响应结果) {String} msg
+     * @apiSuccess (响应结果) {Object} data
+     * @apiSuccess (响应结果) {String} data.name
+     * @apiSuccess (响应结果) {String} data.type
+     * @apiSuccess (响应结果) {String} data.size
+     * @apiSuccessExample 响应结果示例  
+         {
+             "code": 1,
+             "msg": "文件上传成功",
+             "data": {
+                 "name": "33c70532-551f-43a9-b18f-5bdf2d71b77d.jpg",
+                 "type": "jpg",
+                 "size": "0.01 MB"
+             }
+         }
+     */

+ 1 - 0
src/main/java/cn/seecoder/courselearning/po/Course.java

@@ -120,6 +120,7 @@ public class Course {
     }
 
     public Course(@NonNull CourseVO courseVO){
+        this.id = courseVO.getId();
         this.name = courseVO.getName();
         this.type = courseVO.getType();
         this.intro = courseVO.getIntro();

+ 1 - 0
src/main/java/cn/seecoder/courselearning/po/CourseWare.java

@@ -110,6 +110,7 @@ public class CourseWare {
     }
     
     public CourseWare(@NonNull CourseWareVO courseWareVO){
+        id = courseWareVO.getId();
         courseId = courseWareVO.getCourseId();
         number = courseWareVO.getNumber();
         title = courseWareVO.getTitle();

+ 1 - 0
src/main/java/cn/seecoder/courselearning/po/RechargeOrder.java

@@ -49,6 +49,7 @@ public class RechargeOrder {
     }
 
     public RechargeOrder(RechargeOrderVO rechargeOrder) {
+        this.orderId = rechargeOrder.getOrderId();
         this.userId = rechargeOrder.getUserId();
         this.value = rechargeOrder.getValue();
         this.createTime = rechargeOrder.getCreateTime();

+ 1 - 0
src/main/java/cn/seecoder/courselearning/po/User.java

@@ -90,6 +90,7 @@ public class User {
     }
 
     public User(UserVO userVO){
+        id = userVO.getId();
         uname = userVO.getUname();
         phone = userVO.getPhone();
         password = userVO.getPassword();

+ 3 - 1
src/main/java/cn/seecoder/courselearning/serviceimpl/CourseWareServiceImpl.java

@@ -9,10 +9,10 @@ import cn.seecoder.courselearning.util.Constant;
 import cn.seecoder.courselearning.vo.CourseWareVO;
 import cn.seecoder.courselearning.vo.ResultVO;
 import org.springframework.stereotype.Service;
-import org.springframework.util.StringUtils;
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 @Service
@@ -53,6 +53,7 @@ public class CourseWareServiceImpl implements CourseWareService {
 
     @Override
     public ResultVO<CourseWareVO> createCourseWare(CourseWareVO courseWareVO) {
+        courseWareVO.setUploadTime(new Date());
         CourseWare courseWare = new CourseWare(courseWareVO);
         if(courseWareMapper.insert(courseWare) > 0)
             return new ResultVO<>(Constant.REQUEST_SUCCESS, "课件创建成功", new CourseWareVO(courseWare));
@@ -61,6 +62,7 @@ public class CourseWareServiceImpl implements CourseWareService {
 
     @Override
     public ResultVO<CourseWareVO> updateCourseWare(CourseWareVO courseWareVO) {
+        courseWareVO.setUploadTime(new Date());
         CourseWare courseWare = new CourseWare(courseWareVO);
         if(courseWareMapper.updateByPrimaryKey(courseWare) > 0)
             return new ResultVO<>(Constant.REQUEST_SUCCESS, "课件更新成功", new CourseWareVO(courseWare));