Selaa lähdekoodia

feat: 初始化SEEC-II文档

wanghongkai 6 vuotta sitten
commit
6d3147dd53
59 muutettua tiedostoa jossa 1227 lisäystä ja 0 poistoa
  1. 4 0
      .gitignore
  2. 31 0
      README.md
  3. 10 0
      index.raml
  4. 16 0
      package.json
  5. 32 0
      raml2swagger.js
  6. 14 0
      routes/assignment/assignment.raml
  7. 139 0
      routes/assignment/codework/codehw.raml
  8. 65 0
      routes/assignment/codework/codework.raml
  9. 38 0
      routes/course/course.raml
  10. 33 0
      routes/group/group.raml
  11. 7 0
      routes/index.raml
  12. 50 0
      routes/question/question.raml
  13. 55 0
      routes/user/user.raml
  14. 7 0
      traits/empty_response.raml
  15. 12 0
      traits/error.raml
  16. 5 0
      traits/index.raml
  17. 35 0
      traits/pagable.raml
  18. 8 0
      traits/response.raml
  19. 29 0
      types/assignment/codework/BuildRecordDTO.raml
  20. 37 0
      types/assignment/codework/CodeProjectGeneral.raml
  21. 20 0
      types/assignment/codework/CodeWork.raml
  22. 18 0
      types/assignment/codework/CodeWorkDTO.raml
  23. 10 0
      types/assignment/codework/CodeWorkDeploy.raml
  24. 31 0
      types/assignment/codework/CodeWorkDeployRecord.raml
  25. 31 0
      types/assignment/codework/CodeWorkProcedure.raml
  26. 34 0
      types/assignment/codework/CodeWorkProject.raml
  27. 19 0
      types/assignment/codework/CodeWorkResult.raml
  28. 18 0
      types/assignment/codework/DeployDTO.raml
  29. 10 0
      types/assignment/codework/DeployImage.raml
  30. 22 0
      types/assignment/codework/DeployResponse.raml
  31. 7 0
      types/assignment/codework/FunctionTestRecord.raml
  32. 13 0
      types/assignment/codework/FunctionalTestDTO.raml
  33. 19 0
      types/assignment/codework/NestedOneUnitTest.raml
  34. 16 0
      types/assignment/codework/NestedScore.raml
  35. 8 0
      types/assignment/codework/NestedStatus.raml
  36. 14 0
      types/assignment/codework/NestedTestStatus.raml
  37. 20 0
      types/assignment/codework/TestRecord.raml
  38. 19 0
      types/assignment/codework/UnitTestRecord.raml
  39. 16 0
      types/course/Course.raml
  40. 10 0
      types/course/CourseDTO.raml
  41. 5 0
      types/enums/AssignmentStatus.raml
  42. 5 0
      types/enums/AssignmentType.raml
  43. 5 0
      types/enums/BuildStatus.raml
  44. 5 0
      types/enums/DeployEnvironment.raml
  45. 5 0
      types/enums/DeployStatus.raml
  46. 5 0
      types/enums/Difficulty.raml
  47. 5 0
      types/enums/QuestionType.raml
  48. 5 0
      types/enums/UserIdentity.raml
  49. 16 0
      types/group/Group.raml
  50. 10 0
      types/group/GroupDTO.raml
  51. 13 0
      types/group/NestedGroup.raml
  52. 13 0
      types/group/NestedGroupWithSingleUsername.raml
  53. 56 0
      types/index.raml
  54. 13 0
      types/question/NestedQuestion.raml
  55. 22 0
      types/question/Question.raml
  56. 16 0
      types/question/QuestionDTO.raml
  57. 23 0
      types/user/User.raml
  58. 16 0
      types/user/UserDTO.raml
  59. 7 0
      yapi-import.json

+ 4 - 0
.gitignore

@@ -0,0 +1,4 @@
+node_modules/
+package-lock.json
+swagger.json
+*.html

+ 31 - 0
README.md

@@ -0,0 +1,31 @@
+# API-DOC/SEEC-II
+该项目为SEEC-II的api文档仓库
+
+## 维护须知
+项目使用yapi + raml作为维护该文档库的流程即
+
+- 1.开发人员更新文档,push到仓库
+- 2.触发仓库的webhook,调用ci钩子
+- 3.ci自动构建,通过oas-raml-converter工具将raml转化为swagger.json
+- 4.ci通过yapi import,自动导入接口到yapi
+
+其中yapi的接口管理平台地址:yapi.seecoder.cn  
+目前yapi的功能只做项目的管理、接口的展示与mock,如需要其他功能可基于其开源版本二次开发。  
+
+## 一些好处
+- 通过结合ci的自动化流程,保证团队其他成员都能方便查看项目的接口,同时用raml的语言方便重用接口的数据结构。
+- 开发者更新文档后,不需要通知其他团队成员git pull,yapi平台上的接口保证与仓库是一致的,其他开发者不需要繁琐地输入命令。
+- 分组与项目的管理,开发者不需要来来回回在各个项目的仓库切换。
+- 实时Mock,开发者无需自己维护Mock服务,yapi保证mock的服务是最新的。
+
+## raml语法
+参见[github](https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md)
+
+## raml2swagger处理
+raml1.0暂时没有tags的服务,因此通过路径来维护接口的分组,参见`raml2swagger.js`
+
+
+## 如何为其他api文档仓库接入ci?
+- 该仓库定义了一些比较好的split 来帮助开发者维护raml文件,同时用了一些常用的traits机制方便重用某些结构,你可以参照该仓库的结构定义自己的raml结构。
+- 依赖上需要oas-raml-converter,并在raml2swagger中处理api的路径与接口分组的关系。
+- 到yapi上创建项目,获取它的token,并在新仓库中定义yapi-import.json,详情参见[yapi swagger数据导入](https://hellosean1025.github.io/yapi/documents/data.html)。

+ 10 - 0
index.raml

@@ -0,0 +1,10 @@
+#%RAML 1.0
+title: SEEC-II-API
+version: 0.4.5
+baseUri: http://dev.seecii.cn
+mediaType: application/json
+types:
+  !include types/index.raml
+traits:
+  !include traits/index.raml
+/api: !include routes/index.raml

+ 16 - 0
package.json

@@ -0,0 +1,16 @@
+{
+  "name": "api-doc-seec-ii",
+  "version": "0.4.5",
+  "description": "",
+  "main": "index.js",
+  "dependencies": {
+    "oas-raml-converter": "^1.1.43",
+    "yapi-cli": "^1.5.0"
+  },
+  "devDependencies": {},
+  "scripts": {
+    "test": "echo \"Error: no test specified\" && exit 1"
+  },
+  "author": "WangHongKai",
+  "license": "ISC"
+}

+ 32 - 0
raml2swagger.js

@@ -0,0 +1,32 @@
+var converter = require('oas-raml-converter');
+var fs = require('fs');
+var raml10ToOas20 = new converter.Converter(converter.Formats.RAML, converter.Formats.OAS20);
+const tagsMap = {
+  '/api/assignment/code': '代码作业',
+  '/api/assignment/course/{courseId}/code': '代码作业',
+  '/api/codehw': '代码作业',
+  '/api/user': '用户',
+  '/api/course': '课程',
+  '/api/question': '问题',
+  '/api/group': '小组',
+}
+
+raml10ToOas20.convertFile('./index.raml')
+  .then(function(json) {
+    // 接口名称
+    json = json.replace(/operationId/g, 'summary');
+    json = JSON.parse(json)
+    // tags支持
+    tags = Object.values(tagsMap).map(v => ({name: v, description: v}));
+    json['tags'] = tags;
+    Object.keys(json.paths).forEach(uri => {
+      uriTags = Object.keys(tagsMap).filter(k => uri.startsWith(k)).map(k => tagsMap[k]);
+      Object.keys(json.paths[uri]).forEach(method => {
+        json.paths[uri][method]['tags'] = uriTags;
+      });
+    });
+    fs.writeFileSync('./swagger.json', JSON.stringify(json, null, '  '));
+  })
+  .catch(function(err) {
+    console.error(err);
+  });

+ 14 - 0
routes/assignment/assignment.raml

@@ -0,0 +1,14 @@
+#%RAML 1.0
+/course/{courseId}:
+  uriParameters: 
+    courseId: 
+      type: integer
+      description: 课程id
+  /code:
+    post:
+      displayName: 老师创建代码作业
+      body: 
+        application/json:
+          type: CodeWorkDTO
+      is: [response: { typeName: CodeWork }]
+/code: !include codework/codework.raml

+ 139 - 0
routes/assignment/codework/codehw.raml

@@ -0,0 +1,139 @@
+#%RAML 1.0
+
+# Project
+/projects:
+  post:
+    displayName: 获取代码作业的项目列表
+    body: 
+      application/json:
+        properties: 
+          homeworkId:
+            type: integer
+            description: 代码作业id
+    is: [response: { typeName: 'CodeWorkProject[]' }]
+/project:
+  /{id}:
+    uriParameters: 
+      id: 
+        type: integer
+        description: 项目id
+    get:
+      displayName: 获取代码作业的项目
+      is: [response: { typeName: CodeWorkProject }]
+    /build/record:
+      get:
+        queryParameters: 
+          limit:
+            type: integer
+            default: 5
+            description: 数目限制
+        displayName: 获取项目的最近limit条构建记录
+        is: [response: { typeName: 'BuildRecordDTO[]' }]
+    /build/image:
+      get:
+        displayName: 获取项目的构建镜像记录,用于部署镜像选择
+        is: [response: { typeName: DeployImage }]
+    /deploy/record:
+      get:
+        displayName: 获取项目当前的部署记录
+        description: 获取项目的部署记录,只包含当前的测试环境和生产环境部署记录
+        is: [response: { typeName: CodeWorkDeploy }]
+  /deploy/record/{id}:
+    uriParameters: 
+      id: 
+        type: integer
+        description: 代码作业小组resultId
+    get:
+      displayName: 获取代码作业小组的部署记录
+      queryParameters: 
+        limit:
+          type: integer
+          default: 5
+          description: 条数
+        success:
+          type: integer
+          default: 1
+          description: 是否只返回成功的部署记录,1为是,否则返回所有记录
+      is: [response: { typeName: 'DeployResponse[]' }]
+
+# Build
+/build:
+  /{id}:
+    uriParameters: 
+      id: 
+        type: integer
+        description: 构建记录id
+    get:
+      displayName: 获取构建记录
+      is: [response: { typeName: BuildRecordDTO }]
+  /record/{recordId}:
+    uriParameters: 
+      recordId: 
+        type: integer
+        description: 构建记录id,选择已存在的一个构建记录(根据id找到branch和hash,来主动重新构建该次记录)
+    post:
+      displayName: 主动构建镜像
+      is: [response: { typeName: BuildRecordDTO }]
+
+# Deploy
+/deploy:
+  post:
+    displayName: 学生主动进行部署
+    body:
+      application/json:
+        type: DeployDTO
+    is: [response: { typeName: DeployResponse }]
+  /{deployId}:
+    uriParameters: 
+      deployId: 
+        type: integer
+        description: 部署记录id
+    get:
+      displayName: 获取部署记录
+      is: [response: { typeName: DeployResponse }]
+  /log/{deployId}:
+    uriParameters: 
+      deployId: 
+        type: integer
+        description: 部署记录id
+    get:
+      displayName: 获取部署应用的日志
+      is: [response: { typeName: string }]
+
+# UnitTest
+/unit/{id}:
+  uriParameters: 
+    id: 
+      type: integer
+      description: 单元测试记录id
+  get:
+    displayName: 获取单元测试记录
+    is: [response: { typeName: UnitTestRecord }]
+
+# FunctionTest
+/functional:
+  post:
+    displayName: 主动触发界面测试
+    body:
+      application/json:
+        type: FunctionalTestDTO
+    responses:
+      200:
+        body:
+          type: object
+          properties:
+            code: integer
+            data:
+              properties:
+                success:
+                  type: boolean
+                  description: 是否触发成功
+  /{id}:
+    uriParameters: 
+      id: 
+        type: integer
+        description: 界面测试记录id
+    get:
+      displayName: 获取单元测试记录
+      is: [response: { typeName: FunctionTestRecord }]
+  

+ 65 - 0
routes/assignment/codework/codework.raml

@@ -0,0 +1,65 @@
+#%RAML 1.0
+/{codeId}:
+  uriParameters: 
+    codeId: 
+      type: integer
+      description: 代码作业id
+  put:
+    displayName: 老师更新代码作业
+    body: 
+      application/json:
+        type: CodeWorkDTO
+    is: [response: { typeName: CodeWork }]
+  delete:
+    displayName: 老师删除代码作业
+    is: [empty_response]
+/teacher:
+  /course/{courseId}/code:
+    uriParameters: 
+      courseId: 
+        type: integer
+        description: 课程id
+    get:
+      displayName: 老师获取代码作业列表
+      is: [response: { typeName: 'CodeWork[]' }]
+  /code/{codeId}:
+    uriParameters: 
+      codeId: 
+        type: integer
+        description: 代码作业id
+    get:
+      displayName: 老师获取单个代码作业信息
+      is: [response: { typeName: CodeWork }]
+    /submitted/procedure:
+      get:
+        displayName: 老师获取代码作业的提交过程记录
+        is: [response: { typeName: 'CodeWorkProcedure[]' }]
+    /unsubmitted/groups:
+      get:
+        displayName: 老师获取代码作业的未提交的小组列表
+        is: [response: { typeName: 'Group[]' }]
+    /result:
+      get:
+        displayName: 老师获取代码作业所有组的测试情况
+        is: [response: { typeName: 'CodeWorkResult[]' }]
+/student:
+  /course/{courseId}/code: 
+    uriParameters: 
+      courseId: 
+        type: integer
+        description: 课程id
+    get:
+      displayName: 学生获取代码作业列表
+      is: [response: { typeName: 'CodeWork[]' }]
+  /code/{codeId}:
+    uriParameters: 
+      codeId: 
+        type: integer
+        description: 代码作业id
+    get:
+      displayName: 学生获取单个代码作业信息
+      is: [response: { typeName: CodeWork }]
+    /result:
+      displayName: 学生获取自己小组的测试情况
+      is: [response: { typeName: CodeWorkResult }]
+    

+ 38 - 0
routes/course/course.raml

@@ -0,0 +1,38 @@
+#%RAML 1.0
+put:
+  displayName: 教师更新课程信息
+  is: [response: { typeName: Course }]
+  body:
+    application/json:
+      type: CourseDTOWithId
+/student:
+  get:
+    displayName: 学生获取所选课程列表信息
+    is: [response: { typeName: 'Course[]' }]
+/teacher:
+  get:
+    displayName: 教师获取所创建列表信息
+    is: [response: { typeName: 'Course[]' }]
+  post:
+    displayName: 教师创建课程
+    body: 
+      application/json:
+        type: CourseDTO
+    is: [response: { typeName: Course }]
+/register:
+  post:
+    displayName: 学生选课
+    body: 
+      application/json:
+        type: object
+        properties: 
+          code: string
+    is: [response: { typeName: Course }]
+/course/{courseId}:
+  uriParameters: 
+    courseId: 
+      description: 课程id
+      type: integer
+  get:
+    displayName: 学生获取所选课程的信息
+    is: [response: { typeName: Course }]

+ 33 - 0
routes/group/group.raml

@@ -0,0 +1,33 @@
+get:
+  displayName: 学生查看自己的小组
+  queryParameters:
+    courseId:
+      description: 课程id
+      type: integer
+  is: [response: { typeName: 'Group[]' }]
+post:
+  displayName: 学生创建小组
+  body:
+    application/json:
+      type: GroupDTO
+  is: [response: { typeName: Group }]
+put:
+  displayName: 学生通过选组码加入小组
+  body:
+    application/json:
+      type: object
+      properties:
+        code:
+          type: string
+          description: 选组码
+  is: [response: { typeName: Group }]
+/{groupId}:
+  uriParameters: 
+    groupId: 
+      description: 小组id
+      type: integer
+  get:
+    displayName: 老师获取小组信息
+    is: [response: { typeName: Group }]
+
+

+ 7 - 0
routes/index.raml

@@ -0,0 +1,7 @@
+#%RAML 1.0
+/course: !include course/course.raml
+/group: !include group/group.raml
+/question: !include question/question.raml
+/user: !include user/user.raml
+/assignment: !include assignment/assignment.raml
+/codehw: !include assignment/codework/codehw.raml

+ 50 - 0
routes/question/question.raml

@@ -0,0 +1,50 @@
+#%RAML 1.0
+post:
+  displayName: 老师上传题目
+  body:
+    multipart/form-data:
+      properties:
+        question: QuestionDTO
+        file:
+          type: file
+          description: 题目压缩包
+  is: [response: { typeName: Question }]
+/teacher:
+  /questionType:
+    get:
+      displayName: 老师获取所有题目类型
+      is: [response: { typeName: 'QuestionType[]' }]
+  /questions/type:
+    get:
+      displayName: 老师获取某题目类型的所有题目
+      description: type为空则获取所有
+      is: [pagable: { typeName: Question }]
+      queryParameters: 
+        type: QuestionType
+  /questions/assignmentType:
+    get:
+      displayName: 老师获取某作业类型的所有题目
+      description: type为空则获取所有
+      is: [pagable: { typeName: Question }]
+      queryParameters: 
+        type: AssignmentType
+  /keyword:
+    get:
+      displayName: 老师搜索题目
+      queryParameters:
+        keyword:
+          type: string
+          description: 搜索关键字
+        type?:
+          type: QuestionType
+          description: 题目类型
+      is: [response: { typeName: 'Question[]' }]
+/question/{questionId}:
+  uriParameters: 
+    questionId: 
+      type: integer
+      description: 题目id
+  get:
+    displayName: 老师获取单个题目信息
+    is: [response: { typeName: Question }]
+

+ 55 - 0
routes/user/user.raml

@@ -0,0 +1,55 @@
+#%RAML 1.0
+/{userId}:
+  uriParameters: 
+    userId: 
+      type: integer
+      description: 用户id
+  get:
+    displayName: 获取用户信息
+    is: [response: { typeName: User }]
+  post:
+    displayName: 更新用户信息
+    body:
+      application/json:
+        properties:   
+          bio?: string
+          nickname?: string
+    is: [response: { typeName: User }]
+  /password:
+    post:
+      displayName: 修改密码
+      body:
+        application/json:
+          properties:   
+            oldPassword: string
+            newPassword: string
+      is: [response: { typeName: User }]
+/user:
+  post:
+    displayName: 管理员创建账号
+    body:
+      application/json:
+        type: UserDTO
+    is: [response: {typeName: User }]
+  get:
+    displayName: 管理员搜索用户列表
+    is: [pagable: { typeName: User }]
+    queryParameters: 
+      search:
+        type: string
+        description: 搜索字符串
+  /{userId}:
+    uriParameters: 
+      userId: 
+        type: integer
+        description: 用户id
+    get:
+      displayName: 管理员获取单个用户
+      is: [response: { typeName: User }]
+    delete:
+      displayName: 管理员删除单个用户
+      is: [empty_response]
+  /current:
+    displayName: 获取当前用户的信息
+    is: [response: { typeName: User }]
+      

+ 7 - 0
traits/empty_response.raml

@@ -0,0 +1,7 @@
+#%RAML 1.0 Trait
+responses:
+  200:
+    body:
+      type: object
+      properties:
+        code: integer

+ 12 - 0
traits/error.raml

@@ -0,0 +1,12 @@
+#%RAML 1.0 Trait
+responses: 
+  <<code>>:
+    body:
+      type: object
+      properties:
+        code:
+          type: integer
+          default: <<code>>
+        message:
+          type: string
+          default: <<message>>

+ 5 - 0
traits/index.raml

@@ -0,0 +1,5 @@
+#%RAML 1.0
+response: !include response.raml
+error: !include error.raml
+pagable: !include pagable.raml
+empty_response: !include empty_response.raml

+ 35 - 0
traits/pagable.raml

@@ -0,0 +1,35 @@
+#%RAML 1.0 Trait
+queryParameters: 
+  page:
+    type: integer
+    description: 页数
+  limit:
+    type: integer
+    description: 每页数量
+responses: 
+  200:
+    body:
+      type: object
+      properties:
+        code: integer
+        data:
+          properties: 
+            content: <<typeName>>[]
+            pagable:
+              properties:
+                pageNumber: integer
+                pageSize: integer
+                offset: integer
+                paged: boolean
+                unpaged: boolean
+            last: boolean
+            totalPages: integer
+            totalElements: integer
+            first: boolean
+            sort:
+              properties:
+                sorted: boolean
+                unsorted: boolean
+            numberOfElements: number
+            size: integer
+            number: integer

+ 8 - 0
traits/response.raml

@@ -0,0 +1,8 @@
+#%RAML 1.0 Trait
+responses:
+  200:
+    body:
+      type: object
+      properties:
+        code: integer
+        data: <<typeName>>

+ 29 - 0
types/assignment/codework/BuildRecordDTO.raml

@@ -0,0 +1,29 @@
+#%RAML 1.0 DataType
+# BuildRecordDTO
+type: object
+properties:
+  id:
+    type: integer
+    description: 构建记录id
+  buildTime:
+    type: datetime
+    description: 构建的时间
+  buildState:
+    type: integer
+    description: 构建状态 1-成功-1-失败0-未提交2-正在构建3-准备构建中
+    enum: [-1, 0, 1, 2, 3]
+  buildMessage:
+    type: string
+    description: 构建的输出
+  branchId:
+    type: string
+    description: 构建的分支
+  mirrorId:
+    type: string
+    description: 老版本构建对应的镜像id,分环境后只会在对应分支的构建会创建镜像,非可构建镜像分支(master,release)此项无意义
+  commitMessage:
+    type: string
+    description: 构建的提交的message
+  author:
+    type: string
+    description: 构建的触发人

+ 37 - 0
types/assignment/codework/CodeProjectGeneral.raml

@@ -0,0 +1,37 @@
+#%RAML 1.0 DataType
+# CodeProjectGeneralVO
+type: object
+properties: 
+  buildSuccessCount:
+    type: integer
+    description: 构建成功的记录数
+  buildFailureCount:
+    type: integer
+    description: 构建失败的记录数
+  otherUnitTestSuccess:
+    type: integer
+    description: 非生产环境的单元测试成功记录数
+  otherUnitTestFailure:
+    type: integer
+    description: 非生产环境的单元测试失败记录数
+  prodUnitTestSuccess:
+    type: integer
+    description: 生产环境的单元测试成功记录数
+  prodUnitTestFailure:
+    type: integer
+    description: 生产环境的单元测试失败记录数
+  functionalTestSuccess:
+    type: integer
+    description: 界面测试成功记录数
+  functionalTestFailure:
+    type: integer
+    description: 界面测试成功记录数
+  invalidBranches:
+    type: string[]
+    description: 到当前为止,项目中分支命名不合理的列表
+  invalidCommitMessages:
+    type: string[]
+    description: 到当前为止,项目中提交记录信息不合理的记录
+  score:
+    type: integer
+    description: 项目得分

+ 20 - 0
types/assignment/codework/CodeWork.raml

@@ -0,0 +1,20 @@
+#%RAML 1.0 DataType
+# CodeWork
+type: object
+properties:
+  id:
+    type: integer
+    description: 代码作业id
+  name:
+    type: string
+    description: 作业名称
+  description:
+    type: string
+    description: 作业描述
+  status:
+    type: AssignmentStatus
+    description: 作业状态
+  createAt: datetime
+  startAt: datetime
+  endAt: datetime
+  problem: NestedQuestion

+ 18 - 0
types/assignment/codework/CodeWorkDTO.raml

@@ -0,0 +1,18 @@
+#%RAML 1.0 DataType
+# CodeWorkDTO
+type: object
+properties:
+  type:
+    type: AssignmentType
+    description: 代码类型
+  name:
+    type: string
+    description: 作业名称
+  description:
+    type: string
+    description: 作业描述
+  startAt: datetime
+  endAt: datetime
+  problem:
+    type: integer
+    description: 题目id

+ 10 - 0
types/assignment/codework/CodeWorkDeploy.raml

@@ -0,0 +1,10 @@
+#%RAML 1.0 DataType
+# CodeWorkDeploy
+type: object
+properties:
+  latestProdDeploy:
+    type: CodeWorkDeployRecord | nil
+    description: 最近一次的生产记录的部署记录
+  latestTestDeploy:
+    type: CodeWorkDeployRecord | nil
+    description: 最近一次的测试记录的部署记录

+ 31 - 0
types/assignment/codework/CodeWorkDeployRecord.raml

@@ -0,0 +1,31 @@
+#%RAML 1.0 DataType
+# CodeWorkDeployRecord
+type: object
+properties:
+  id:
+    type: integer
+    description: 部署记录id
+  time:
+    type: datetime
+    description: 部署的时间
+  status:
+    type: DeployStatus
+    description: 部署状态
+  url:
+    type: string
+    description: 该次部署的url地址
+  branch:
+    type: string
+    description: 该次部署对应构建记录的构建的分支
+  commitHash:
+    type: string
+    description: 该次部署对应构建记录的构建的提交hash
+  author:
+    type: string
+    description: 该次部署对应构建记录的提交人
+  testStatus:
+    type: BuildStatus
+    description: 该次部署对应构建记录的状态
+  consoleOutput:
+    type: string
+    description: 控制台输出

+ 31 - 0
types/assignment/codework/CodeWorkProcedure.raml

@@ -0,0 +1,31 @@
+#%RAML 1.0 DataType
+# CodeWorkProcedure
+type: object
+properties:
+  id:
+    type: integer
+    description: 该小组对应代码作业的result的id
+  code:
+    type: string
+    description: 代码作业id
+  group:
+    type: NestedGroup
+    description: 小组信息
+  buildStatus:
+    type: NestedStatus
+    description: 最新一次构建状态信息
+  prodDeployStatus:
+    type: NestedStatus
+    description: 最新一次生产环境部署状态信息
+  testDeployStatus:
+    type: NestedStatus
+    description: 最新一次测试环境部署状态信息
+  unitTestStatus:
+    type: NestedTestStatus
+    description: 最新一次单元测试状态信息
+  prodFunctionTestStatus:
+    type: NestedTestStatus
+    description: 最新一次生产环境界面测试状态信息
+  testFunctionTestStatus:
+    type: NestedTestStatus
+    description: 最新一次测试环境界面测试状态信息

+ 34 - 0
types/assignment/codework/CodeWorkProject.raml

@@ -0,0 +1,34 @@
+#%RAML 1.0 DataType
+# CodeWorkProject
+type: object
+properties:
+  id:
+    type: integer
+    description: 该小组对应代码作业的result的id
+  codeId:
+    type: string
+    description: 代码作业id
+  url:
+    type: string
+    description: 老版本的部署产生的url信息,目前废弃,分环境的url在deploy
+  name:
+    type: string
+    description: 项目的部署的命名空间
+  buildList:
+    type: BuildRecordDTO[] | nil
+    description: 构建记录列表
+  deploy:
+    type: CodeWorkDeploy | nil
+    description: 项目的部署信息
+  unitTestList:
+    type: UnitTestRecord[] | nil
+    description: 单元测试记录列表
+  prodFunctionTestList:
+    type: FunctionTestRecord[] | nil
+    description: 生产环境界面测试记录列表
+  testFunctionTestList:
+    type: FunctionTestRecord[] | nil
+    description: 测试环境界面测试记录列表
+  general:
+    type: CodeProjectGeneral | nil
+    description: 代码作业项目总览

+ 19 - 0
types/assignment/codework/CodeWorkResult.raml

@@ -0,0 +1,19 @@
+#%RAML 1.0 DataType
+# CodeWorkResult
+type: object
+properties:
+  id:
+    type: integer
+    description: 代码作业小组的result的id
+  codeWork:
+    type: integer
+    description: 代码作业id
+  group:
+    type: NestedGroupWithSingleUsername
+    description: 小组信息
+  unitTestScore:
+    type: NestedScore | nil
+    description: 分数最高的单元测试记录的测试详情
+  functionTestScore:
+    type: NestedScore | nil
+    description: 分数最高的界面测试记录的测试详情

+ 18 - 0
types/assignment/codework/DeployDTO.raml

@@ -0,0 +1,18 @@
+#%RAML 1.0 DataType
+# DeployDTO
+type: object
+properties: 
+  projectId:
+    type: integer
+    description: 项目id
+  mirrorId:
+    type: string
+    description: 部署的镜像路径
+  replicas:
+    type: integer
+    description: 副本数,目前只允许一个
+    minimum: 1
+    maximum: 1
+  deployEnvironment:
+    type: DeployEnvironment
+    description: 部署环境

+ 10 - 0
types/assignment/codework/DeployImage.raml

@@ -0,0 +1,10 @@
+#%RAML 1.0 DataType
+# DeployImage
+type: object
+properties:
+  prodBuildRecord:
+    type: BuildRecordDTO | nil
+    description: 最近一次的生产环境构建记录,内含mirrorId
+  testBuildRecord:
+    type: BuildRecordDTO | nil
+    description: 最近一次的测试环境构建记录,内含mirrorId

+ 22 - 0
types/assignment/codework/DeployResponse.raml

@@ -0,0 +1,22 @@
+#%RAML 1.0 DataType
+# DeployResponse
+type: object
+properties:
+  id:
+    type: integer
+    description: 部署记录id
+  status:
+    type: DeployStatus
+    description: 部署状态
+  createdAt:
+    type: datetime
+    description: 开始部署时间
+  endAt:
+    type: datetime
+    description: 结束部署时间
+  mirrorId:
+    type: string
+    description: 部署对应镜像uri
+  url:
+    type: string
+    description: 部署暴露的域名

+ 7 - 0
types/assignment/codework/FunctionTestRecord.raml

@@ -0,0 +1,7 @@
+#%RAML 1.0 DataType
+# FunctionTestRecord
+type: TestRecord
+properties:
+  deployId:
+    type: integer
+    description: 界面测试对应的部署记录id

+ 13 - 0
types/assignment/codework/FunctionalTestDTO.raml

@@ -0,0 +1,13 @@
+#%RAML 1.0 DataType
+# FunctionalTestDTO
+type: object
+properties:
+  homeworkId:
+    type: integer
+    description: 代码作业id
+  projectId:
+    type: integer
+    description: 项目id
+  deployId:
+    type: integer
+    description: 部署记录id

+ 19 - 0
types/assignment/codework/NestedOneUnitTest.raml

@@ -0,0 +1,19 @@
+#%RAML 1.0 DataType
+# NestedOneUnitTestVO
+type: object
+properties:
+  id:
+    type: integer
+    description: 用例id,注意生产环境和测试环境的用例数目不一样,顺序无法保证,该属性并非unique的
+  name:
+    type: strng
+    description: 测试用例名称
+  isPass:
+    type: boolean
+    description: 是否通过
+  message:
+    type: string
+    description: 如果失败,测试失败的简易message信息
+  trace:
+    type: string
+    description: 如果失败,测试失败的trace信息

+ 16 - 0
types/assignment/codework/NestedScore.raml

@@ -0,0 +1,16 @@
+#%RAML 1.0 DataType
+# NestedScore
+type: object
+properties:
+  id:
+    type: integer
+    description: 用例id,注意生产环境和测试环境的用例数目不一样,顺序无法保证,该属性并非unique的
+  name:
+    type: strng
+    description: 测试用例名称
+  passed:
+    type: boolean
+    description: 是否通过
+  score:
+    type: integer
+    description: 该测试用例得分

+ 8 - 0
types/assignment/codework/NestedStatus.raml

@@ -0,0 +1,8 @@
+#%RAML 1.0 DataType
+# NestedStatus
+type: object
+properties:
+  key:
+    type: integer
+    description: 构建或部署状态,0-未提交,1-成功,-1-失败
+    enum: [0, 1, -1]

+ 14 - 0
types/assignment/codework/NestedTestStatus.raml

@@ -0,0 +1,14 @@
+#%RAML 1.0 DataType
+# NestedTestStatus
+type: object
+properties:
+  key:
+    type: integer
+    description: 构建或部署状态,0-未提交,1-成功,-1-失败
+    enum: [0, 1, -1]
+  testCount:
+    type: integer
+    description: 测试用例数目
+  passCount:
+    type: integer
+    description: 通过用例数目

+ 20 - 0
types/assignment/codework/TestRecord.raml

@@ -0,0 +1,20 @@
+#%RAML 1.0 DataType
+# TestRecord
+type: TestRecord
+properties:
+  id:
+    type: integer
+    description: 测试记录id
+  testTime:
+    type: datetime
+    description: 测试时间
+  status:
+    type: integer
+    description: 测试状态 1 表示运行结束,0 表示正在运行
+    enum: [0, 1]
+  isPassAll:
+    type: boolean
+    description: 是否全部通过
+  detail:
+    type: NestedOneUnitTestVO[]
+    description: 测试的用例信息

+ 19 - 0
types/assignment/codework/UnitTestRecord.raml

@@ -0,0 +1,19 @@
+#%RAML 1.0 DataType
+# UnitTestRecord
+type: TestRecord
+properties:
+  buildId:
+    type: integer
+    description: 测试对应的构建记录id
+  hash:
+    type: string
+    description: 测试对应的commit hash
+  branchId:
+    type: string
+    description: 测试的分支
+  commitMessage:
+    type: string
+    description: 测试对应构建的提交的message
+  author:
+    type: string
+    description: 单元测试的触发人

+ 16 - 0
types/course/Course.raml

@@ -0,0 +1,16 @@
+#%RAML 1.0 DataType
+# Course
+type: object
+properties:
+  id:
+    type: integer
+    description: 课程id
+  name:
+    type: string
+    description: 课程名称
+  code:
+    type: string
+    description: 选课码
+  teacher:
+    type: User
+    description: 老师信息

+ 10 - 0
types/course/CourseDTO.raml

@@ -0,0 +1,10 @@
+#%RAML 1.0 DataType
+# CourseDTO
+type: object
+properties:
+  name:
+    type: string
+    description: 课程名称
+  code:
+    type: string
+    description: 选课码

+ 5 - 0
types/enums/AssignmentStatus.raml

@@ -0,0 +1,5 @@
+#%RAML 1.0 DataType
+# AssignmentStatus
+type: string
+description: 作业状态
+enum: [PREPARING, UNAVAILABLE, READY, AVAILABLE, FINISHED]

+ 5 - 0
types/enums/AssignmentType.raml

@@ -0,0 +1,5 @@
+#%RAML 1.0 DataType
+# AssignmentType
+type: string
+description: 作业类型
+enum: [DOCUMENT, CODE, CODE_TEST, ML, UNKNOWN]

+ 5 - 0
types/enums/BuildStatus.raml

@@ -0,0 +1,5 @@
+#%RAML 1.0 DataType
+# BuildStatus
+type: string
+description: 构建的状态
+enum: [SUCCESS, UNSTABLE, FAILURE, TIMEOUT, WAITING, RUNNING]

+ 5 - 0
types/enums/DeployEnvironment.raml

@@ -0,0 +1,5 @@
+#%RAML 1.0 DataType
+# DeployEnvironment
+type: string
+description: 部署的环境
+enum: [production, test]

+ 5 - 0
types/enums/DeployStatus.raml

@@ -0,0 +1,5 @@
+#%RAML 1.0 DataType
+# DeployStatus
+type: string
+description: 部署的状态
+enum: [RUNNING, SUCCESS, IMAGE_ACQUISITION_FAIL, RESOURCE_LACK, FAILURE, WAITING]

+ 5 - 0
types/enums/Difficulty.raml

@@ -0,0 +1,5 @@
+#%RAML 1.0 DataType
+# Difficulty
+type: string
+description: 题目难度
+enum: [EASY, MIDDLE, HARD]

+ 5 - 0
types/enums/QuestionType.raml

@@ -0,0 +1,5 @@
+#%RAML 1.0 DataType
+# QuestionType
+type: string
+description: 题目类型
+enum: [JAVA, MARKDOWN, UNKNOWN]

+ 5 - 0
types/enums/UserIdentity.raml

@@ -0,0 +1,5 @@
+#%RAML 1.0 DataType
+# UserIdentity
+type: string
+description: 用户角色
+enum: [STUDENT, TEACHER]

+ 16 - 0
types/group/Group.raml

@@ -0,0 +1,16 @@
+#%RAML 1.0 DataType
+# Group
+type: object
+properties: 
+  id:
+    type: integer
+    description: 小组id
+  name:
+    type: string
+    description: 小组名称
+  code:
+    type: string
+    description: 选组码
+  members:
+    type: User[]
+    description: 组员信息

+ 10 - 0
types/group/GroupDTO.raml

@@ -0,0 +1,10 @@
+#%RAML 1.0 DataType
+# GroupDTO
+type: object
+properties: 
+  name:
+    type: string
+    description: 小组名称
+  courseId:
+    type: integer
+    description: 课程id

+ 13 - 0
types/group/NestedGroup.raml

@@ -0,0 +1,13 @@
+#%RAML 1.0 DataType
+# NestedGroup
+type: object
+properties: 
+  id:
+    type: integer
+    description: 小组id
+  name:
+    type: string
+    description: 小组名称
+  members:
+    type: User[]
+    description: 组员信息

+ 13 - 0
types/group/NestedGroupWithSingleUsername.raml

@@ -0,0 +1,13 @@
+#%RAML 1.0 DataType
+# NestedGroup
+type: object
+properties: 
+  id:
+    type: integer
+    description: 小组id
+  name:
+    type: string
+    description: 小组名称
+  members:
+    type: string[]
+    description: 组员用户名信息

+ 56 - 0
types/index.raml

@@ -0,0 +1,56 @@
+#%RAML 1.0
+
+# Course
+Course: !include ./course/Course.raml
+CourseDTO: !include ./course/CourseDTO.raml
+CourseDTOWithId:
+  type: CourseDTO
+  properties:
+    id: integer
+
+# User
+User: !include ./user/User.raml
+UserDTO: !include ./user/UserDTO.raml
+
+# Group
+Group: !include ./group/Group.raml
+GroupDTO: !include ./group/GroupDTO.raml
+NestedGroup: !include ./group/NestedGroup.raml
+NestedGroupWithSingleUsername: !include ./group/NestedGroupWithSingleUsername.raml
+
+# Question
+QuestionDTO: !include ./question/QuestionDTO.raml
+Question: !include ./question/Question.raml
+NestedQuestion: !include ./question/NestedQuestion.raml
+
+# CodeWork
+CodeWork: !include ./assignment/codework/CodeWork.raml
+CodeWorkDTO: !include ./assignment/codework/CodeWorkDTO.raml
+CodeWorkProcedure: !include ./assignment/codework/CodeWorkProcedure.raml
+NestedStatus: !include ./assignment/codework/NestedStatus.raml
+NestedTestStatus: !include ./assignment/codework/NestedTestStatus.raml
+NestedScore: !include ./assignment/codework/NestedScore.raml
+NestedOneUnitTest: !include ./assignment/codework/NestedOneUnitTest.raml
+CodeWorkResult: !include ./assignment/codework/CodeWorkResult.raml
+CodeWorkProject: !include ./assignment/codework/CodeWorkProject.raml
+CodeWorkProjectGeneral: !include ./assignment/codework/CodeWorkProjectGeneral.raml
+CodeWorkDeploy: !include ./assignment/codework/CodeWorkDeploy.raml
+CodeWorkDeployRecord: !include ./assignment/codework/CodeWorkDeployRecord.raml
+BuildRecordDTO: !include ./assignment/codework/BuildRecordDTO.raml
+TestRecord: !include ./assignment/codework/TestRecord.raml
+UnitTestRecord: !include ./assignment/codework/UnitTestRecord.raml
+FunctionTestRecord: !include ./assignment/codework/FunctionTestRecord.raml
+DeployImage: !include ./assignment/codework/DeployImage.raml
+FunctionalTestDTO: !include ./assignment/codework/FunctionalTestDTO.raml
+DeployDTO: !include ./assignment/codework/DeployDTO.raml
+DeployResponse: !include ./assignment/codework/DeployResponse.raml
+
+# Enums
+UserIdentity: !include ./enums/UserIdentity.raml
+QuestionType: !include ./enums/QuestionType.raml
+Difficulty: !include ./enums/Difficulty.raml
+AssignmentType: !include ./enums/AssignmentType.raml
+AssignmentStatus: !include ./enums/AssignmentStatus.raml
+DeployEnvironment: !include ./enums/DeployEnvironment.raml
+DeployStatus: !include ./enums/DeployStatus.raml
+BuildStatus: !include ./enums/BuildStatus.raml

+ 13 - 0
types/question/NestedQuestion.raml

@@ -0,0 +1,13 @@
+#%RAML 1.0 DataType
+# NestedQuestion
+type: object
+properties:
+  id:
+    type: integer
+    description: 题目id
+  name:
+    type: string
+    description: 题目名称
+  description:
+    type: string
+    description: 题目描述

+ 22 - 0
types/question/Question.raml

@@ -0,0 +1,22 @@
+#%RAML 1.0 DataType
+# Question
+type: object
+properties:
+  id:
+    type: integer
+    description: 题目id
+  name:
+    type: string
+    description: 题目名称
+  description:
+    type: string
+    description: 题目描述
+  assignmentType: AssignmentType
+  questionType: QuestionType
+  difficulty: Difficulty
+  expectTime:
+    type: integer
+    description: 预计完成时间
+  creator:
+    type: integer
+    description: 题目创建者id

+ 16 - 0
types/question/QuestionDTO.raml

@@ -0,0 +1,16 @@
+#%RAML 1.0 DataType
+# QuestionDTO
+type: object
+properties: 
+  name:
+    type: string
+    description: 题目名称
+  description:
+    type: string
+    description: 题目描述
+  assignmentType: AssignmentType
+  questionType: QuestionType
+  difficulty: Difficulty
+  expectTime:
+    type: integer
+    description: 预计完成时间

+ 23 - 0
types/user/User.raml

@@ -0,0 +1,23 @@
+#%RAML 1.0 DataType
+# User
+type: object
+properties:
+  id:
+    type: integer
+    description: 用户id
+  username:
+    type: string
+    description: 用户名
+  role:
+    type: UserIdentity
+    description: 用户角色
+  email:
+    pattern: ^.+@.+\..+$
+    description: 邮箱
+  nickname:
+    type: string
+    description: 昵称
+  bio:
+    type: string
+    description: 用户自我描述
+  createdAt: datetime

+ 16 - 0
types/user/UserDTO.raml

@@ -0,0 +1,16 @@
+#%RAML 1.0 DataType
+# UserDTO
+type: object
+properties:
+  username:
+    pattern: [0-9a-zA-Z]{4,16}
+    description: 用户名
+  role:
+    type: UserIdentity
+    description: 用户角色
+  email:
+    pattern: ^.+@.+\..+$
+    description: 邮箱
+  nickname:
+    type: string
+    description: 昵称

+ 7 - 0
yapi-import.json

@@ -0,0 +1,7 @@
+{
+  "type": "swagger",
+  "token": "b277fcd739e37351f55bb21541e7f6ae5be77d90fb7cdb196445108628a6ff19",
+  "file": "swagger.json",
+  "merge": "good",
+  "server": "http://yapi.seecoder.cn"
+}