v2-userdict.yaml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. # 由 openapi/scripts/generate.php 生成,请勿手改;补充写到 overrides/v2-userdict.yaml
  2. delete:
  3. summary: 批量删除用户词典记录(旧接口)
  4. tags:
  5. - userdict
  6. operationId: delete_api_v2_userdict
  7. description: |-
  8. 不走 AuthService,凭据取自 cookie 中的 user_id,只删除该用户创建的记录。
  9. 每删一条都会同步刷新 _SYS_USER_WBW_ 汇总与该单词的 Redis 缓存 dict/user。
  10. 返回 deleted(实际删除条数)。
  11. 实现:`UserDictController@delete`
  12. parameters:
  13. -
  14. name: id
  15. in: query
  16. schema:
  17. type: string
  18. description: '要删除的词条 id 数组的 JSON 字符串'
  19. required: true
  20. example:
  21. - '123'
  22. - '456'
  23. responses:
  24. 200:
  25. description: '成功。业务失败时 HTTP 仍可能为 200,以 ok 字段为准。'
  26. content:
  27. application/json:
  28. schema:
  29. type: object
  30. properties:
  31. ok:
  32. type: boolean
  33. message:
  34. type: string
  35. data:
  36. type: object
  37. 401:
  38. $ref: '../../main.yaml#/components/responses/Unauthorized'
  39. 422:
  40. $ref: '../../main.yaml#/components/responses/ValidationError'
  41. get:
  42. summary: 列出用户词典条目
  43. tags:
  44. - userdict
  45. operationId: get_api_v2_userdict
  46. description: |-
  47. 按 view 指定的口径返回 user_dict 记录,支持按单词、词根、词典过滤,以及分页与排序。
  48. 需要登录的口径:all、studio;studio 口径还要求 name 指定的 studio 属于当前用户,否则返回 auth.failed。
  49. community 口径只返回 status>5 且来源为 _USER_WBW_/_USER_DICT_ 的社区公开数据。
  50. 返回 rows 与 count(过滤后总数)。
  51. 实现:`UserDictController@index`
  52. parameters:
  53. -
  54. name: view
  55. in: query
  56. schema:
  57. type: string
  58. enum:
  59. - all
  60. - studio
  61. - user
  62. - word
  63. - community
  64. - compound
  65. - dict
  66. description: '查询口径。all=全部;studio=某 studio 创建者的用户词条;user=cookie 中用户的词条(排除系统汇总);word=按单词查全部;community=社区公开词条;compound=复合词机器人词典;dict=指定词典'
  67. required: true
  68. -
  69. name: name
  70. in: query
  71. schema:
  72. type: string
  73. description: 'studio 口径为 studio 名;dict 口径为系统词典短名'
  74. example: robot_compound
  75. -
  76. name: word
  77. in: query
  78. schema:
  79. type: string
  80. description: '要查询的单词,word/community/compound 口径必填;其他口径传入时也会追加过滤'
  81. -
  82. name: id
  83. in: query
  84. schema:
  85. type: string
  86. description: 'dict 口径下直接指定的词典 uid(与 name 二选一)'
  87. -
  88. name: search
  89. in: query
  90. schema:
  91. type: string
  92. description: 按单词前缀模糊搜索
  93. -
  94. name: parent
  95. in: query
  96. schema:
  97. type: string
  98. description: 按词根(parent)过滤
  99. -
  100. name: dict
  101. in: query
  102. schema:
  103. type: string
  104. description: '按词典短名(dict_info.shortname)过滤,解析为 uuid 后才生效'
  105. -
  106. name: order
  107. in: query
  108. schema:
  109. type: string
  110. default: updated_at
  111. description: 排序字段
  112. -
  113. name: dir
  114. in: query
  115. schema:
  116. type: string
  117. enum:
  118. - asc
  119. - desc
  120. default: desc
  121. description: 排序方向
  122. -
  123. name: offset
  124. in: query
  125. schema:
  126. type: integer
  127. default: 0
  128. description: 跳过的记录数
  129. -
  130. name: limit
  131. in: query
  132. schema:
  133. type: integer
  134. default: 200
  135. description: 返回条数上限
  136. responses:
  137. 200:
  138. description: '成功。业务失败时 HTTP 仍可能为 200,以 ok 字段为准。'
  139. content:
  140. application/json:
  141. schema:
  142. type: object
  143. properties:
  144. ok:
  145. type: boolean
  146. message:
  147. type: string
  148. data:
  149. type: object
  150. properties:
  151. rows:
  152. type: array
  153. items:
  154. type: object
  155. properties: { id: { type: integer }, word: { type: string }, type: { type: integer }, grammar: { type: string }, mean: { type: string }, parent: { type: string }, note: { type: string }, factors: { type: string }, source: { type: string }, status: { type: integer }, confidence: { type: string }, updated_at: { type: string }, creator_id: { type: integer }, format: { type: string }, lang: { type: string }, editor: { type: string }, exp: { type: string }, dict: { type: string } }
  156. count:
  157. type: integer
  158. 401:
  159. $ref: '../../main.yaml#/components/responses/Unauthorized'
  160. 422:
  161. $ref: '../../main.yaml#/components/responses/ValidationError'
  162. post:
  163. summary: 批量新增/更新用户词典条目
  164. tags:
  165. - userdict
  166. operationId: post_api_v2_userdict
  167. description: |-
  168. 需要登录。data 是 JSON 字符串,解码后逐条处理:以 creator_id + word 以及请求中给出的
  169. type/grammar/parent/mean/factors 组合判重,不存在则插入(自动生成雪花 id、按 view 写入 source、
  170. 记录 create_time 与 creator_id),已存在则只更新 note 与 confidence。
  171. 新增且 status>5 时会同步刷新系统汇总词典 _SYS_USER_WBW_;每次新增都会刷新该单词的 Redis 缓存 dict/user。
  172. 返回 [新增条数, 汇总表更新结果]。
  173. 实现:`UserDictController@store`
  174. requestBody:
  175. required: true
  176. content:
  177. application/json:
  178. schema:
  179. type: object
  180. properties:
  181. data:
  182. type: string
  183. description: '词条数组的 JSON 字符串,每项含 word(必填)及可选 type、grammar、parent、mean、factors、factormean、note、confidence、status、language'
  184. view:
  185. type: string
  186. description: '数据来源口径,决定写入的 source:dict=_USER_DICT_,wbw=_USER_WBW_'
  187. enum:
  188. - dict
  189. - wbw
  190. required:
  191. - view
  192. - data
  193. responses:
  194. 200:
  195. description: '成功。业务失败时 HTTP 仍可能为 200,以 ok 字段为准。'
  196. content:
  197. application/json:
  198. schema:
  199. type: object
  200. properties:
  201. ok:
  202. type: boolean
  203. message:
  204. type: string
  205. data:
  206. type: object
  207. 401:
  208. $ref: '../../main.yaml#/components/responses/Unauthorized'
  209. 422:
  210. $ref: '../../main.yaml#/components/responses/ValidationError'