瀏覽代碼

初始化接口文件

WuXinyu 6 年之前
父節點
當前提交
b057a59770

+ 17 - 0
index.raml

@@ -0,0 +1,17 @@
+#%RAML 1.0
+title       : SEEC-I-API
+version     : 1.0.0
+baseUri     : http://seeci.cn/api
+mediaType   : application/json
+types       : !include types/index.raml
+traits      : !include traits/index.raml
+
+/record     : !include ./routes/record.raml
+/user       : !include ./routes/user.raml
+/auth       : !include ./routes/auth.raml
+/commit     : !include ./routes/commit.raml
+/course     : !include ./routes/course.raml
+/exam       : !include ./routes/exam.raml
+/problem    : !include ./routes/problem.raml
+/result     : !include ./routes/result.raml
+/statistic  : !include ./routes/statistic.raml

+ 30 - 0
routes/auth.raml

@@ -0,0 +1,30 @@
+#%RAML 1.0
+
+/current:
+  get             : 
+    displayName   : 获得当前登录用户的信息
+    is            : [Response: { res: User }]
+
+/login:
+  post            : 
+    displayName   : 登录
+    body          : LoginDTO
+    is            : [Response: { res: User }]
+
+/verification:
+  post            : 
+    displayName   : 手机验证码
+    body          : VerificationDTO
+    is            : [EmptyResponse]
+
+/register:
+  post            : 
+    displayName   : 注册
+    body          : RegisterDTO
+    is            : [Response: { res: User }]
+
+/password/change:
+  post            : 
+    displayName   : 修改密码
+    body          : ChangePasswordForm
+    is            : [EmptyResponse]

+ 10 - 0
routes/commit.raml

@@ -0,0 +1,10 @@
+#%RAML 1.0
+
+/{commitId}: 
+  uriParameters   : 
+    commitId      : 
+      type        : number
+      description : 提交id
+  get             : 
+    displayName   : 查看提交信息
+    is            : [Response: { res: Commit }]

+ 32 - 0
routes/course.raml

@@ -0,0 +1,32 @@
+#%RAML 1.0
+
+post                : 
+  displayName       : 教师新建课程
+  body              : CourseDTO
+  is                : [Response: { res: Course }]
+
+get                 : 
+  displayName       : 教师获取自己创建的所有课程
+  is                : [PagedResponse: { res: 'Course[]' }]
+
+/{courseId}: 
+  uriParameters     : 
+    courseId        : 
+      type          : number
+      description   : 课程id
+  put               : 
+    displayName     : 更新课程信息
+    body            : CourseDTO
+    is              : [Response: { res: Course }]
+
+/student:
+  post              : 
+    displayName     : 学生选课
+    body            : CourseCodeDTO
+    is              : [Response: { res: Course }]
+
+/code:
+  post              : 
+    displayName     : 判断选课码是否重复
+    body            : CourseCodeDTO
+    is              : [Response: { res: boolean }]

+ 67 - 0
routes/exam.raml

@@ -0,0 +1,67 @@
+#%RAML 1.0
+
+post                    : 
+  displayName           : 创建考试
+  body                  : ExamDTO
+  is                    : [Response: { res: Exam }]
+
+get                     : 
+  displayName           : 获得用户列表
+  queryParameters       : 
+    status?             : 
+      type              : ExamStatus
+      description       : 搜索信息
+  is                    : [PagedResponse: { res: 'Exam[]' }]
+
+/{examId}:
+  uriParameters         : 
+    examId              : 
+      type              : number
+      description       : 考试id
+  get                   : 
+    displayName         : 查看考试信息
+    is                  : [Response: { res: Exam }]
+  
+  put                   : 
+    displayName         : 更新考试信息
+    body                : ExamDTO
+    is                  : [Response: { res: Exam }]
+
+  delete                : 
+    displayName         : 删除考试
+    is                  : [EmptyResponse]
+
+  post                  : 
+    displayName         : 参加考试
+    is                  : [EmptyResponse]
+
+  /onlineCode:
+    get                 : 
+      displayName       : 获得在线代码(1)
+      is                : [Response: { res: Code }]
+
+    post                : 
+      displayName       : 更新在线代码(1)
+      body              : 
+        properties      : 
+          //            : string
+      is                : [EmptyResponse]
+
+    /{questionId}:
+      uriParameters     : 
+        questionId      : 
+          type          : number
+          description   : 问题id
+      get               : 
+        displayName     : 获得在线代码(2)
+        is              : [Response: { res: Code }]
+
+      post              : 
+        displayName     : 更新在线代码(2)
+        body            : CodeDTO
+        is              : [EmptyResponse]
+
+  /result:
+    get                 : 
+      displayName       : 获得考试结果
+      is                : [Response: { res: Result }]

+ 44 - 0
routes/problem.raml

@@ -0,0 +1,44 @@
+#%RAML 1.0
+
+post                    : 
+  displayName           : 创建题目
+  body                  : 
+    multipart/form-data:
+      properties        : 
+        meta            : ProblemDTO
+        data            : 
+          type          : file
+          description   : 题目压缩包
+  is                    : [Response: { res: Problem }]
+
+get                     : 
+  displayName           : 查看题目列表
+  queryParameters       : 
+    type?               : 
+      type              : ProblemType
+      description       : 问题状态
+  is                    : [PagedResponse: { res: 'Problem[]' }]
+
+/{problemId}:
+  uriParameters         : 
+    problemId           : 
+      type              : number
+      description       : 问题id
+  get                   : 
+    displayName         : 查看题目信息
+    is                  : [Response: { res: Problem }]
+    
+  put                   : 
+    displayName         : 更新题目信息
+    body                : 
+      multipart/form-data:
+      properties        : 
+        path            : string
+        file            : 
+          type          : file
+          description   : 题目压缩包
+    is                  : [Response: { res: Problem }]
+  
+  delete                : 
+    displayName         : 删除题目
+    is                  : [EmptyResponse]

+ 10 - 0
routes/record.raml

@@ -0,0 +1,10 @@
+#%RAML 1.0
+
+/{recordId}: 
+  uriParameters   : 
+    recordId      : 
+      type        : number
+      description : 记录id
+  get             : 
+    displayName   : 获得记录
+    is            : [Response: { res: Record }]

+ 14 - 0
routes/result.raml

@@ -0,0 +1,14 @@
+#%RAML 1.0
+
+get                 : 
+  displayName       : 查看当前用户的结果列表
+  is                : [Response: { res: 'Result[]' }]
+
+/{resultId}: 
+  uriParameters     : 
+    resultId        : 
+      type          : number
+      description   : 结果id
+  get               : 
+    displayName     : 通过结果id查看结果信息
+    is              : [Response: { res: Result }]

+ 5 - 0
routes/statistic.raml

@@ -0,0 +1,5 @@
+#%RAML 1.0
+
+get             : 
+  displayName   : 获得记录
+  is            : [Response: { res: Statistic }]

+ 37 - 0
routes/user.raml

@@ -0,0 +1,37 @@
+#%RAML 1.0
+
+post                : 
+  displayName       : 创建用户
+  body              : UserDTO
+  is                : [Response: { res: User }]
+
+get                 : 
+  displayName       : 获得用户列表
+  queryParameters   : 
+    search?         : 
+      type          : string
+      description   : 搜索信息
+  is                : [PagedResponse: { res: 'User[]' }]
+
+/{userId}:
+  uriParameters     : 
+    userId          : 
+      type          : number
+      description   : 用户id
+  get               : 
+    displayName     : 查看用户
+    is              : [Response: { res: User }]
+  
+  delete            : 
+    displayName     : 删除用户
+    is              : [EmptyResponse]
+
+  /password/change:
+    post            : 
+      displayName   : 重置密码
+      is            : [EmptyResponse]
+  
+  /result:
+    get             : 
+      displayName   : 查看用户的考试结果列表
+      is            : [Response: { res: Problem }]

+ 8 - 0
traits/EmptyResponse.raml

@@ -0,0 +1,8 @@
+#%RAML 1.0 Trait
+responses           : 
+  200               : 
+    body            : 
+      properties    : 
+        err         : 
+          type      : number
+          default   : 0

+ 7 - 0
traits/ErrorResponse.raml

@@ -0,0 +1,7 @@
+#%RAML 1.0 Trait
+responses           : 
+  200               : 
+    body            : 
+      properties    : 
+        err         : <<err>>
+        msg         : <<msg>>

+ 22 - 0
traits/PagedResponse.raml

@@ -0,0 +1,22 @@
+#%RAML 1.0 Trait
+queryParameters         : 
+  page?                 : 
+    type                : number
+    description         : 页数
+  limit?                : 
+    type                : number
+    description         : 每页数量
+responses               : 
+  200                   : 
+    body                : 
+      properties        : 
+        err             : 
+          type          : number
+          default       : 0
+        res             : <<res>>
+        page            : 
+          properties    : 
+              page      : number
+              limit     : number
+              size      : number
+              total     : number

+ 9 - 0
traits/Response.raml

@@ -0,0 +1,9 @@
+#%RAML 1.0 Trait
+responses           : 
+  200               : 
+    body            : 
+      properties    : 
+        err         : 
+          type      : number
+          default   : 0
+        res         : <<res>>

+ 5 - 0
traits/index.raml

@@ -0,0 +1,5 @@
+#%RAML 1.0
+Response        : !include Response.raml
+PagedResponse   : !include PagedResponse.raml
+EmptyResponse   : !include EmptyResponse.raml
+ErrorResponse   : !include ErrorResponse.raml

+ 5 - 0
types/basic/LocalDateTime.raml

@@ -0,0 +1,5 @@
+#%RAML 1.0 DataType
+# LocalDateTime
+type    : number
+minimum : 0
+maximum : 2147483648

+ 20 - 0
types/code/Code.raml

@@ -0,0 +1,20 @@
+#%RAML 1.0 DataType
+type                    : object
+properties              : 
+  examId                : number
+  fetchAt               : LocalDateTime
+  startAt               : LocalDateTime
+  endAt                 : LocalDateTime
+  codeList              : 
+    type                : array
+    items               : 
+      properties        : 
+        questionId      : number
+        language        : string
+        projectName     : string
+        editable        : 
+          properties    : 
+            //          : string
+        uneditable      : 
+          properties    : 
+            //          : string

+ 6 - 0
types/code/CodeDTO.raml

@@ -0,0 +1,6 @@
+#%RAML 1.0 DataType
+type              : object
+properties        : 
+  code            : 
+    properties    : 
+      //          : string

+ 32 - 0
types/commit/Commit.raml

@@ -0,0 +1,32 @@
+#%RAML 1.0 DataType
+type: object
+description: Commit
+properties:
+  id: number
+  hash: string
+  finished: boolean
+  score: number
+  createdAt: LocalDateTime
+  result:
+    properties:
+      id: number
+      score: number
+      exam:
+        properties:
+          id: number
+          name: string
+      owner:
+        properties:
+          id: number
+          username?: string
+  records:
+    type: array
+    items: 
+      properties:
+        id: number
+        status: BuildStatus
+        score: number
+        problem: 
+          properties:
+            id: number
+            name: string

+ 6 - 0
types/course/Course.raml

@@ -0,0 +1,6 @@
+#%RAML 1.0 DataType
+type          : object
+properties    : 
+  id          : number
+  name        : string
+  code        : string

+ 4 - 0
types/course/CourseCodeDTO.raml

@@ -0,0 +1,4 @@
+#%RAML 1.0 DataType
+type          : object
+properties    : 
+  code        : string

+ 5 - 0
types/course/CourseDTO.raml

@@ -0,0 +1,5 @@
+#%RAML 1.0 DataType
+type          : object
+properties    : 
+  name        : string
+  code        : string

+ 10 - 0
types/enums/BuildStatus.raml

@@ -0,0 +1,10 @@
+#%RAML 1.0 DataType
+# BuildStatus
+type    : string
+enum    : 
+  - SUCCESS  #构建成功,表示没有错误
+  - UNSTABLE #构建不稳定,表示有测试错误等非致命错误
+  - FAILURE  #构建失败,表示有语法错误等致命错误
+  - TIMEOUT  #构建超时,表示运行测试时超时
+  - WAITING  #等待构建,表示构建尚未开始
+  - RUNNING  #正在构建,表示构建正在进行

+ 9 - 0
types/enums/ExamStatus.raml

@@ -0,0 +1,9 @@
+#%RAML 1.0 DataType
+type    : string
+enum    : 
+  - PREPARING   #正在准备试题,通常是正在PUSH试题
+  - UNAVAILABLE #考试不可用,通常是PUSH试题失败
+  - READY       #考试已准备好,在考试尚未开始时使用,不持久化到数据库中
+  - AVAILABLE   #考试可用,表示考试正在进行,持久化时考试从准备好到考试被关闭均为此状态
+  - FINISHED    #考试已完成,在考试结束后使用,不持久化到数据库中
+  - CLOSED      #考试已关闭,表示考试生命周期结束,所有试卷均被存档

+ 10 - 0
types/enums/ProblemType.raml

@@ -0,0 +1,10 @@
+#%RAML 1.0 DataType
+# ProblemType
+type    : string
+enum    : 
+  - JAVA            # 普通Java题目,统计测试用例通过情况
+  - JAVA_DATABASE   # 带数据库的Java题目,统计测试用例通过情况
+  - PYTHON          # 普通Python题目,统计测试用例通过情况
+  - JAVA_COVERAGE   # Java测试覆盖率题目,统计测试覆盖率
+  - PYTHON_COVERAGE # Python测试覆盖率题目,统计测试覆盖率
+  - JAVA_MUTATION   # Java变异覆盖题目,统计变异覆盖率

+ 6 - 0
types/enums/UserRole.raml

@@ -0,0 +1,6 @@
+#%RAML 1.0 DataType
+# UserRole
+type    : string
+enum    : 
+  - STUDENT
+  - TEACHER

+ 16 - 0
types/exam/Exam.raml

@@ -0,0 +1,16 @@
+#%RAML 1.0 DataType
+type              : object
+properties        : 
+  id              : number
+  name            : string
+  createdAt       : LocalDateTime
+  startAt         : LocalDateTime
+  endAt           : LocalDateTime
+  status          : ExamStatus
+  joined          : boolean
+  courseId        : number
+  courseName      : string
+  creator         : 
+    properties    : 
+      id          : number
+      username    : string

+ 8 - 0
types/exam/ExamDTO.raml

@@ -0,0 +1,8 @@
+#%RAML 1.0 DataType
+type          : object
+properties    : 
+  name        : string
+  startAt     : LocalDateTime
+  endAt       : LocalDateTime
+  problem     : number[]
+  courseId    : number

+ 47 - 0
types/index.raml

@@ -0,0 +1,47 @@
+#%RAML 1.0
+
+# Basic Types
+LocalDateTime         : !include ./basic/LocalDateTime.raml
+
+# enums
+BuildStatus           : !include ./enums/BuildStatus.raml
+UserRole              : !include ./enums/UserRole.raml
+ProblemType           : !include ./enums/ProblemType.raml
+ExamStatus            : !include ./enums/ExamStatus.raml
+
+# User
+User                  : !include ./user/User.raml
+UserDTO               : !include ./user/UserDTO.raml
+ChangePasswordForm    : !include ./user/ChangePasswordForm.raml
+LoginDTO              : !include ./user/LoginDTO.raml
+RegisterDTO           : !include ./user/RegisterDTO.raml
+VerificationDTO       : !include ./user/VerificationDTO.raml
+
+# Exam
+Exam                  : !include ./exam/Exam.raml
+ExamDTO               : !include ./exam/ExamDTO.raml
+
+# Result
+Result                : !include ./result/Result.raml
+
+# Problem
+Problem               : !include ./problem/Problem.raml
+Problem               : !include ./problem/ProblemDTO.raml
+
+# Code
+Code                  : !include ./code/Code.raml
+CodeDTO               : !include ./code/CodeDTO.raml
+
+# Commit
+Commit                : !include ./commit/Commit.raml
+
+# Course
+Course                : !include ./course/Course.raml
+CourseDTO             : !include ./course/CourseDTO.raml
+CourseCodeDTO         : !include ./course/CourseCodeDTO.raml
+
+# Record
+Record                : !include ./record/Record.raml
+
+# Statistic
+Statistic             : !include ./statistic/Statistic.raml

+ 18 - 0
types/problem/Problem.raml

@@ -0,0 +1,18 @@
+#%RAML 1.0 DataType
+# Problem
+type                : object
+properties          : 
+  id                : number
+  name              : string
+  type              : ProblemType
+  description       : string
+  publicFiles       : string[]
+  protectedFiles    : string[]
+  privateFiles      : string[]
+  createdAt         : LocalDateTime
+  modifiedAt        : LocalDateTime
+  deprecated        : boolean
+  creator           : 
+    properties      : 
+      id            : number
+      username      : string

+ 7 - 0
types/problem/ProblemDTO.raml

@@ -0,0 +1,7 @@
+#%RAML 1.0 DataType
+# Problem
+type          : object
+properties    : 
+  name        : string
+  type        : ProblemType
+  description : string

+ 20 - 0
types/record/Record.raml

@@ -0,0 +1,20 @@
+#%RAML 1.0 DataType
+# Record
+type              : object
+properties        : 
+  id              : number
+  number          : number
+  status          : BuildStatus
+  consoleOutput   : string
+  score           : number
+  commit          : 
+    properties    : 
+      id          : number
+      createdAt   : LocalDateTime
+  failures        : 
+    type          : array
+    items         : 
+      properties  : 
+        name      : string
+        details   : string
+        trace     : string

+ 24 - 0
types/result/Result.raml

@@ -0,0 +1,24 @@
+#%RAML 1.0 DataType
+type              : object
+properties        : 
+  id              : number
+  score           : number
+  lastCommitAt    : LocalDateTime
+  deleted         : boolean
+  exam            : 
+    properties    : 
+      id          : number
+      name        : string
+      course      : string
+  owner           : 
+    properties    : 
+      id          : number
+      username    : string
+  commits         : 
+    type          : array
+    items         : 
+      properties  : 
+        id        : number
+        finished  : boolean
+        score     : number
+        createdAt : LocalDateTime

+ 10 - 0
types/statistic/Statistic.raml

@@ -0,0 +1,10 @@
+#%RAML 1.0 DataType
+type                  : object
+properties            : 
+  studentCount        : number
+  teacherCount        : number
+  examinationCount    : number
+  resultCount         : number
+  recordCount         : number
+  javaProblemCount    : number
+  pythonProblemCount  : number

+ 7 - 0
types/user/ChangePasswordForm.raml

@@ -0,0 +1,7 @@
+#%RAML 1.0 DataType
+# ChangePasswordForm
+type          : object
+properties    : 
+  origin      : string
+  password    : string
+  confirm     : string

+ 6 - 0
types/user/LoginDTO.raml

@@ -0,0 +1,6 @@
+#%RAML 1.0 DataType
+# LoginDTO
+type          : object
+properties    : 
+  username    : string
+  password    : string

+ 10 - 0
types/user/RegisterDTO.raml

@@ -0,0 +1,10 @@
+#%RAML 1.0 DataType
+# RegisterDTO
+type          : object
+properties    : 
+  username    : string
+  password    : string
+  confirm     : string
+  phone       : string
+  token       : string
+  email       : string

+ 11 - 0
types/user/User.raml

@@ -0,0 +1,11 @@
+#%RAML 1.0 DataType
+# User
+type          : object
+properties    : 
+  id          : number
+  score       : number
+  username    : string
+  email       : string
+  phone       : string
+  role        : UserRole
+  createAt    : LocalDateTime

+ 8 - 0
types/user/UserDTO.raml

@@ -0,0 +1,8 @@
+#%RAML 1.0 DataType
+# UserDTO
+type          : object
+properties    : 
+  username    : string
+  email       : string
+  role        : UserRole
+  phone       : string

+ 5 - 0
types/user/VerificationDTO.raml

@@ -0,0 +1,5 @@
+#%RAML 1.0 DataType
+# VerificationDTO
+type          : object
+properties    : 
+  phoneNumber : string