v2-article.yaml 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. # 由 openapi/scripts/generate.php 生成,请勿手改;补充写到 overrides/v2-article.yaml
  2. get:
  3. summary: '列出 article(文章)'
  4. tags:
  5. - article
  6. operationId: get_api_v2_article
  7. description: |-
  8. 按 view 指定的口径返回文章列表,支持关键字搜索、分页、排序。
  9. 默认只返回列表字段(uid、title、subtitle、summary、owner、lang、status、editor_id、时间),
  10. content=true 时才附带正文与正文类型。
  11. view=studio 需要登录,且当前登录用户必须就是 name 指定的 studio 的拥有者,否则返回 401/403。
  12. 实现:`ArticleController@index`
  13. parameters:
  14. -
  15. name: content
  16. in: query
  17. schema:
  18. type: string
  19. description: '是否返回文章正文。传 true 时结果附带 content 与 content_type'
  20. example: 'true'
  21. -
  22. name: view
  23. in: query
  24. schema:
  25. type: string
  26. enum:
  27. - template
  28. - studio
  29. - public
  30. description: '查询口径。template=按 studio_name 取该 studio 的全部文章(模版库);studio=取某 studio 内的文章,需要登录;public=只取已公开(status=30)的文章'
  31. required: true
  32. -
  33. name: studio_name
  34. in: query
  35. schema:
  36. type: string
  37. description: 'view=template 时使用,指定 studio 的名称'
  38. -
  39. name: name
  40. in: query
  41. schema:
  42. type: string
  43. description: 'view=studio 时使用,指定 studio 的名称,必须与当前登录用户一致'
  44. -
  45. name: view2
  46. in: query
  47. schema:
  48. type: string
  49. default: my
  50. description: 'view=studio 时的二级口径:my=我创建的(owner 为该 studio),其余值=协作的(别人共享给我的,res_type=3)'
  51. -
  52. name: anthology
  53. in: query
  54. schema:
  55. type: string
  56. enum:
  57. - all
  58. - none
  59. description: 'view=studio 时按文集过滤。all=不过滤;none=不属于我任何文集的文章;其余值按文集 uid 过滤'
  60. -
  61. name: search
  62. in: query
  63. schema:
  64. type: string
  65. description: '按标题模糊搜索(title like %search%)'
  66. -
  67. name: subtitle
  68. in: query
  69. schema:
  70. type: string
  71. description: '按副标题过滤(subtitle like,需自行带通配符)'
  72. -
  73. name: order
  74. in: query
  75. schema:
  76. type: string
  77. default: updated_at
  78. description: 排序字段
  79. -
  80. name: dir
  81. in: query
  82. schema:
  83. type: string
  84. enum:
  85. - asc
  86. - desc
  87. default: desc
  88. description: 排序方向
  89. -
  90. name: offset
  91. in: query
  92. schema:
  93. type: integer
  94. default: 0
  95. description: 分页起始位置
  96. -
  97. name: limit
  98. in: query
  99. schema:
  100. type: integer
  101. default: 1000
  102. description: 每页条数
  103. responses:
  104. 200:
  105. description: '成功。业务失败时 HTTP 仍可能为 200,以 ok 字段为准。'
  106. content:
  107. application/json:
  108. schema:
  109. type: object
  110. properties:
  111. ok:
  112. type: boolean
  113. message:
  114. type: string
  115. data:
  116. type: object
  117. properties:
  118. rows:
  119. type: array
  120. items:
  121. type: object
  122. properties: { uid: { type: string }, title: { type: string }, subtitle: { type: string }, summary: { type: string }, studio: { type: string }, editor: { type: string }, status: { type: integer }, lang: { type: string }, parent_uid: { type: string }, created_at: { type: string }, updated_at: { type: string }, format: { type: string }, key: { type: string }, level: { type: integer }, mode: { type: string }, footnote: { type: string }, origin: { type: string }, paragraph: { type: string }, role: { type: string }, anthology_count: { type: integer }, anthology_first: { type: string }, path: { type: string }, toc: { type: string }, title_text: { type: string }, content: { type: string }, content_type: { type: string }, html: { type: string }, _summary: { type: string } }
  123. count:
  124. type: integer
  125. 401:
  126. $ref: '../../main.yaml#/components/responses/Unauthorized'
  127. 422:
  128. $ref: '../../main.yaml#/components/responses/ValidationError'
  129. post:
  130. summary: '新建 article(文章)'
  131. tags:
  132. - article
  133. operationId: post_api_v2_article
  134. description: |-
  135. 需要登录。权限:当前用户必须是 studio 的拥有者;若不是,则必须对 anthologyId 指定的文集
  136. 拥有大于只读的权限(power>10),否则返回 403。
  137. 副作用:整个新建过程在事务中执行——写入 articles 表,若给了 anthologyId 则同时把文章挂进文集;
  138. 若再给了 parentNode,会按目录树重建该文集的 article_collections 记录(删除后整表重插)并刷新文集缓存。
  139. 标题超过 128 字会被截断。
  140. 实现:`ArticleController@store`
  141. requestBody:
  142. required: true
  143. content:
  144. application/json:
  145. schema:
  146. type: object
  147. properties:
  148. studio:
  149. type: string
  150. description: 'studio 名称,文章归属的 studio'
  151. anthologyId:
  152. type: string
  153. description: '文集 uid,传入则把新文章加入该文集'
  154. title:
  155. type: string
  156. description: '文章标题,最多 128 字,超出截断'
  157. lang:
  158. type: string
  159. description: 文章语言代码
  160. status:
  161. type: integer
  162. description: '公开状态,30 表示公开。不传则用数据库默认值'
  163. parentId:
  164. type: string
  165. description: '父文章 uid,写入 articles.parent'
  166. parentNode:
  167. type: string
  168. description: '文集目录中的挂接点文章 uid,新文章作为它的子节点插入; 不传则作为一级节点(level=1)追加到文集末尾'
  169. required:
  170. - studio
  171. - title
  172. - lang
  173. responses:
  174. 200:
  175. description: '成功。业务失败时 HTTP 仍可能为 200,以 ok 字段为准。'
  176. content:
  177. application/json:
  178. schema:
  179. type: object
  180. properties:
  181. ok:
  182. type: boolean
  183. message:
  184. type: string
  185. data:
  186. type: object
  187. properties:
  188. uid:
  189. type: string
  190. title:
  191. type: string
  192. subtitle:
  193. type: string
  194. summary:
  195. type: string
  196. studio:
  197. type: string
  198. editor:
  199. type: string
  200. status:
  201. type: integer
  202. lang:
  203. type: string
  204. parent_uid:
  205. type: string
  206. created_at:
  207. type: string
  208. updated_at:
  209. type: string
  210. format:
  211. type: string
  212. key:
  213. type: string
  214. level:
  215. type: integer
  216. mode:
  217. type: string
  218. footnote:
  219. type: string
  220. origin:
  221. type: string
  222. paragraph:
  223. type: string
  224. role:
  225. type: string
  226. anthology_count:
  227. type: integer
  228. anthology_first:
  229. type: string
  230. path:
  231. type: string
  232. toc:
  233. type: string
  234. title_text:
  235. type: string
  236. content:
  237. type: string
  238. content_type:
  239. type: string
  240. html:
  241. type: string
  242. _summary:
  243. type: string
  244. 401:
  245. $ref: '../../main.yaml#/components/responses/Unauthorized'
  246. 422:
  247. $ref: '../../main.yaml#/components/responses/ValidationError'