v2-course-member.yaml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. # 由 openapi/scripts/generate.php 生成,请勿手改;补充写到 overrides/v2-course-member.yaml
  2. get:
  3. summary: 列出课程成员
  4. tags:
  5. - course-member
  6. operationId: get_api_v2_course_member
  7. description: |-
  8. 按 view 指定的口径返回课程成员列表,支持角色/状态过滤、按昵称搜索、分页与排序。
  9. 必须登录,且当前用户必须已经是该 course 的成员(在 course_member 中有 role),否则返回 403。
  10. 返回 rows(成员列表)、role(当前用户在该 course 中的当前角色)、count(过滤后的总数)。
  11. 实现:`CourseMemberController@index`
  12. parameters:
  13. -
  14. name: id
  15. in: query
  16. schema:
  17. type: string
  18. description: 'course uid。view=timeline 时也用于权限校验'
  19. required: true
  20. -
  21. name: course
  22. in: query
  23. schema:
  24. type: string
  25. description: '权限校验与 timeline 口径使用的 course uid,缺省时回退到 id'
  26. -
  27. name: view
  28. in: query
  29. schema:
  30. type: string
  31. enum:
  32. - course
  33. - timeline
  34. description: 查询口径。course=课程内全部当前成员;timeline=某用户的成员变更时间线
  35. required: true
  36. -
  37. name: userId
  38. in: query
  39. schema:
  40. type: string
  41. description: 'view=timeline 时必填,要查看时间线的用户 uid'
  42. -
  43. name: timeline
  44. in: query
  45. schema:
  46. type: string
  47. default: current
  48. description: 'view=timeline 时的范围:current=只看 course 参数指定的课程,其余值=该用户全部课程'
  49. -
  50. name: role
  51. in: query
  52. schema:
  53. type: string
  54. description: '按角色过滤,all 表示不过滤'
  55. example: student
  56. -
  57. name: status
  58. in: query
  59. schema:
  60. type: string
  61. description: 按状态过滤,逗号分隔可多选
  62. example: 'joined,applied'
  63. -
  64. name: search
  65. in: query
  66. schema:
  67. type: string
  68. description: 按成员昵称模糊搜索
  69. -
  70. name: order
  71. in: query
  72. schema:
  73. type: string
  74. default: created_at
  75. description: 排序字段
  76. -
  77. name: dir
  78. in: query
  79. schema:
  80. type: string
  81. enum:
  82. - asc
  83. - desc
  84. default: asc
  85. description: 排序方向
  86. -
  87. name: offset
  88. in: query
  89. schema:
  90. type: integer
  91. default: 0
  92. description: 跳过的记录数
  93. -
  94. name: limit
  95. in: query
  96. schema:
  97. type: integer
  98. default: 1000
  99. description: 返回条数上限
  100. responses:
  101. 200:
  102. description: '成功。业务失败时 HTTP 仍可能为 200,以 ok 字段为准。'
  103. content:
  104. application/json:
  105. schema:
  106. type: object
  107. properties:
  108. ok:
  109. type: boolean
  110. message:
  111. type: string
  112. data:
  113. type: object
  114. properties:
  115. rows:
  116. type: array
  117. items:
  118. type: object
  119. properties: { id: { type: integer }, user_id: { type: integer }, course_id: { type: integer }, role: { type: string }, user: { type: string }, editor: { type: string }, status: { type: integer }, channel_id: { type: integer }, created_at: { type: string }, updated_at: { type: string }, channel: { type: string }, course: { type: string } }
  120. count:
  121. type: integer
  122. 401:
  123. $ref: '../../main.yaml#/components/responses/Unauthorized'
  124. 422:
  125. $ref: '../../main.yaml#/components/responses/ValidationError'
  126. post:
  127. summary: 新增课程成员记录(加入/申请/邀请)
  128. tags:
  129. - course-member
  130. operationId: post_api_v2_course_member
  131. description: |-
  132. 必须登录。status=invited 表示由当前用户邀请他人,成员归属 user_id 指定的用户;
  133. 其余情况(自己加入或申请)一律忽略 user_id,成员归属当前登录用户。
  134. 非 invited 时若该 user 已在该 course 中存在任何记录,返回 member exists(HTTP 200)。
  135. 写入前会把同一 course + user 的旧记录 is_current 置为 false,新记录成为当前记录。
  136. 状态必须与课程加入方式匹配:course.join=open 只接受 joined/invited,manual 只接受 applied/invited,
  137. 不匹配返回 invalid course(HTTP 200)。course 不存在返回 invalid course。
  138. 实现:`CourseMemberController@store`
  139. requestBody:
  140. required: true
  141. content:
  142. application/json:
  143. schema:
  144. type: object
  145. properties:
  146. user_id:
  147. type: string
  148. description: '成员用户 uid,仅在 status=invited 时生效'
  149. course_id:
  150. type: string
  151. description: 'course uid'
  152. role:
  153. type: string
  154. description: 成员角色
  155. example: student
  156. status:
  157. type: string
  158. description: 成员状态
  159. enum:
  160. - joined
  161. - applied
  162. - invited
  163. required:
  164. - user_id
  165. - course_id
  166. - role
  167. - status
  168. responses:
  169. 200:
  170. description: '成功。业务失败时 HTTP 仍可能为 200,以 ok 字段为准。'
  171. content:
  172. application/json:
  173. schema:
  174. type: object
  175. properties:
  176. ok:
  177. type: boolean
  178. message:
  179. type: string
  180. data:
  181. type: object
  182. properties:
  183. id:
  184. type: integer
  185. user_id:
  186. type: integer
  187. course_id:
  188. type: integer
  189. role:
  190. type: string
  191. user:
  192. type: string
  193. editor:
  194. type: string
  195. status:
  196. type: integer
  197. channel_id:
  198. type: integer
  199. created_at:
  200. type: string
  201. updated_at:
  202. type: string
  203. channel:
  204. type: string
  205. course:
  206. type: string
  207. 401:
  208. $ref: '../../main.yaml#/components/responses/Unauthorized'
  209. 422:
  210. $ref: '../../main.yaml#/components/responses/ValidationError'