2
0

v2-terms-term.yaml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. # 由 openapi/scripts/generate.php 生成,请勿手改;补充写到 overrides/v2-terms-term.yaml
  2. get:
  3. summary: 查询单条术语
  4. tags:
  5. - terms
  6. operationId: get_api_v2_terms_term_
  7. description: |-
  8. 按 guid(不是自增 id)查找,公开接口,不需要登录。查不到返回错误 '没有查询到数据'。
  9. 实现:`DhammaTermController@show`
  10. parameters:
  11. -
  12. name: term
  13. in: path
  14. required: true
  15. schema:
  16. type: string
  17. -
  18. name: channel
  19. in: query
  20. schema:
  21. type: string
  22. description: '渲染 note 时使用的 channel 列表,多个用下划线分隔; 不传则按术语自身的 channel 或对应语言的社区 channel 渲染'
  23. -
  24. name: mode
  25. in: query
  26. schema:
  27. type: string
  28. default: read
  29. description: 渲染模式
  30. -
  31. name: format
  32. in: query
  33. schema:
  34. type: string
  35. enum:
  36. - react
  37. - html
  38. - text
  39. default: react
  40. description: 'note 的渲染输出格式'
  41. -
  42. name: community_summary
  43. in: query
  44. schema:
  45. type: boolean
  46. description: '传入该参数时,没有 note 的术语回落到社区解释作为 summary'
  47. -
  48. name: exp
  49. in: query
  50. schema:
  51. type: boolean
  52. description: 传入该参数时附带编辑者累计经验值(秒)
  53. responses:
  54. 200:
  55. description: '成功。业务失败时 HTTP 仍可能为 200,以 ok 字段为准。'
  56. content:
  57. application/json:
  58. schema:
  59. type: object
  60. properties:
  61. ok:
  62. type: boolean
  63. message:
  64. type: string
  65. data:
  66. type: object
  67. properties:
  68. id:
  69. type: integer
  70. guid:
  71. type: string
  72. word:
  73. type: string
  74. word_en:
  75. type: string
  76. meaning:
  77. type: string
  78. other_meaning:
  79. type: string
  80. tag:
  81. type: string
  82. note:
  83. type: string
  84. language:
  85. type: string
  86. channel_id:
  87. type: integer
  88. channal:
  89. type: string
  90. studio:
  91. type: string
  92. editor:
  93. type: string
  94. created_at:
  95. type: string
  96. updated_at:
  97. type: string
  98. mode:
  99. type: string
  100. format:
  101. type: string
  102. studioId:
  103. type: string
  104. channel:
  105. type: string
  106. html:
  107. type: string
  108. summary_is_community:
  109. type: string
  110. summary:
  111. type: string
  112. role:
  113. type: string
  114. exp:
  115. type: string
  116. 401:
  117. $ref: '../../main.yaml#/components/responses/Unauthorized'
  118. 422:
  119. $ref: '../../main.yaml#/components/responses/ValidationError'
  120. put:
  121. summary: 修改术语
  122. tags:
  123. - terms
  124. operationId: put_api_v2_terms_term_
  125. description: |-
  126. 需要登录(未登录 401),按主键 id 查找,不存在返回 '404'。
  127. 权限:studio 级术语(channal 为空)只有 owner 本人能改,AI 模型一律 403;
  128. channel 级术语要求对该 channel 有编辑权(owner / 协作者 / access token),否则 403。
  129. 增量更新——只有请求里出现的字段才会被写入,未提交的字段保持原值;
  130. 提交 word 时会同步重算 word_en。create_time 不变,只刷新 modify_time。
  131. 保存后清除该词的 term 缓存并重建 OpenSearch 索引(索引失败只记日志)。
  132. 实现:`DhammaTermController@update`
  133. parameters:
  134. -
  135. name: term
  136. in: path
  137. required: true
  138. schema:
  139. type: string
  140. requestBody:
  141. required: false
  142. content:
  143. application/json:
  144. schema:
  145. type: object
  146. properties:
  147. access_token:
  148. type: string
  149. description: 'channel access token,供非 owner 身份验证 channel 编辑权'
  150. word:
  151. type: string
  152. description: '术语词形,提交时同步重算 word_en'
  153. meaning:
  154. type: string
  155. description: 主要义项
  156. other_meaning:
  157. type: string
  158. description: 其他义项,逗号分隔
  159. note:
  160. type: string
  161. description: 术语解释,Markdown
  162. tag:
  163. type: string
  164. description: 标签
  165. language:
  166. type: string
  167. description: 语言
  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. guid:
  186. type: string
  187. word:
  188. type: string
  189. word_en:
  190. type: string
  191. meaning:
  192. type: string
  193. other_meaning:
  194. type: string
  195. tag:
  196. type: string
  197. note:
  198. type: string
  199. language:
  200. type: string
  201. channel_id:
  202. type: integer
  203. channal:
  204. type: string
  205. studio:
  206. type: string
  207. editor:
  208. type: string
  209. created_at:
  210. type: string
  211. updated_at:
  212. type: string
  213. mode:
  214. type: string
  215. format:
  216. type: string
  217. studioId:
  218. type: string
  219. channel:
  220. type: string
  221. html:
  222. type: string
  223. summary_is_community:
  224. type: string
  225. summary:
  226. type: string
  227. role:
  228. type: string
  229. exp:
  230. type: string
  231. 401:
  232. $ref: '../../main.yaml#/components/responses/Unauthorized'
  233. 422:
  234. $ref: '../../main.yaml#/components/responses/ValidationError'
  235. patch:
  236. summary: 修改术语
  237. tags:
  238. - terms
  239. operationId: patch_api_v2_terms_term_
  240. description: |-
  241. 需要登录(未登录 401),按主键 id 查找,不存在返回 '404'。
  242. 权限:studio 级术语(channal 为空)只有 owner 本人能改,AI 模型一律 403;
  243. channel 级术语要求对该 channel 有编辑权(owner / 协作者 / access token),否则 403。
  244. 增量更新——只有请求里出现的字段才会被写入,未提交的字段保持原值;
  245. 提交 word 时会同步重算 word_en。create_time 不变,只刷新 modify_time。
  246. 保存后清除该词的 term 缓存并重建 OpenSearch 索引(索引失败只记日志)。
  247. 实现:`DhammaTermController@update`
  248. parameters:
  249. -
  250. name: term
  251. in: path
  252. required: true
  253. schema:
  254. type: string
  255. requestBody:
  256. required: false
  257. content:
  258. application/json:
  259. schema:
  260. type: object
  261. properties:
  262. access_token:
  263. type: string
  264. description: 'channel access token,供非 owner 身份验证 channel 编辑权'
  265. word:
  266. type: string
  267. description: '术语词形,提交时同步重算 word_en'
  268. meaning:
  269. type: string
  270. description: 主要义项
  271. other_meaning:
  272. type: string
  273. description: 其他义项,逗号分隔
  274. note:
  275. type: string
  276. description: 术语解释,Markdown
  277. tag:
  278. type: string
  279. description: 标签
  280. language:
  281. type: string
  282. description: 语言
  283. responses:
  284. 200:
  285. description: '成功。业务失败时 HTTP 仍可能为 200,以 ok 字段为准。'
  286. content:
  287. application/json:
  288. schema:
  289. type: object
  290. properties:
  291. ok:
  292. type: boolean
  293. message:
  294. type: string
  295. data:
  296. type: object
  297. properties:
  298. id:
  299. type: integer
  300. guid:
  301. type: string
  302. word:
  303. type: string
  304. word_en:
  305. type: string
  306. meaning:
  307. type: string
  308. other_meaning:
  309. type: string
  310. tag:
  311. type: string
  312. note:
  313. type: string
  314. language:
  315. type: string
  316. channel_id:
  317. type: integer
  318. channal:
  319. type: string
  320. studio:
  321. type: string
  322. editor:
  323. type: string
  324. created_at:
  325. type: string
  326. updated_at:
  327. type: string
  328. mode:
  329. type: string
  330. format:
  331. type: string
  332. studioId:
  333. type: string
  334. channel:
  335. type: string
  336. html:
  337. type: string
  338. summary_is_community:
  339. type: string
  340. summary:
  341. type: string
  342. role:
  343. type: string
  344. exp:
  345. type: string
  346. 401:
  347. $ref: '../../main.yaml#/components/responses/Unauthorized'
  348. 422:
  349. $ref: '../../main.yaml#/components/responses/ValidationError'
  350. delete:
  351. summary: 批量删除术语
  352. tags:
  353. - terms
  354. operationId: delete_api_v2_terms_term_
  355. description: |-
  356. 需要登录。一次可以删除多条,返回实际删除的条数;无权限的条目被跳过而不报错。
  357. 传了 uuid 参数时,id 按数组处理:owner 本人可删,非 owner 且术语属于某个 channel 时
  358. 需要该 channel 的协作权限达到 20(编辑)才可删,studio 级术语非 owner 一律跳过。
  359. 未传 uuid 时,id 按 JSON 字符串数组处理,且只能删除 owner 是当前用户的术语。
  360. 每删一条都会清除该词对应的 term 缓存。
  361. 实现:`DhammaTermController@destroy`
  362. parameters:
  363. -
  364. name: term
  365. in: path
  366. required: true
  367. schema:
  368. type: string
  369. -
  370. name: uuid
  371. in: query
  372. schema:
  373. type: string
  374. description: '存在该参数即表示 id 以数组形式提交,并启用 channel 协作者删除权限判定'
  375. -
  376. name: id
  377. in: query
  378. schema:
  379. type: array
  380. description: '要删除的术语 id 列表。带 uuid 时为数组,否则为 JSON 数组字符串'
  381. required: true
  382. responses:
  383. 200:
  384. description: '成功。业务失败时 HTTP 仍可能为 200,以 ok 字段为准。'
  385. content:
  386. application/json:
  387. schema:
  388. type: object
  389. properties:
  390. ok:
  391. type: boolean
  392. message:
  393. type: string
  394. data:
  395. type: object
  396. 401:
  397. $ref: '../../main.yaml#/components/responses/Unauthorized'
  398. 422:
  399. $ref: '../../main.yaml#/components/responses/ValidationError'