contact-api-apifox.json 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. {
  2. "openapi": "3.0.0",
  3. "info": {
  4. "title": "飞鸟农场联系我们API",
  5. "description": "飞鸟农场网站联系我们模块的API接口文档",
  6. "version": "1.0.0",
  7. "contact": {
  8. "name": "飞鸟农场开发团队",
  9. "email": "dev@feiniao.com"
  10. }
  11. },
  12. "servers": [
  13. {
  14. "url": "http://localhost:3000",
  15. "description": "开发环境"
  16. },
  17. {
  18. "url": "https://api.feiniao.com",
  19. "description": "生产环境"
  20. }
  21. ],
  22. "tags": [
  23. {
  24. "name": "Contact",
  25. "description": "联系我们相关接口"
  26. }
  27. ],
  28. "paths": {
  29. "/contact": {
  30. "post": {
  31. "tags": ["Contact"],
  32. "summary": "提交联系我们表单",
  33. "description": "用户提交联系我们表单,系统会保存到数据库并发送邮件通知",
  34. "operationId": "createContact",
  35. "requestBody": {
  36. "required": true,
  37. "content": {
  38. "application/json": {
  39. "schema": {
  40. "$ref": "#/components/schemas/CreateContactRequest"
  41. },
  42. "examples": {
  43. "basic": {
  44. "summary": "基本留言",
  45. "value": {
  46. "name": "张三",
  47. "email": "zhangsan@example.com",
  48. "subject": "产品咨询",
  49. "message": "我想了解一下你们的产品价格和功能特点。"
  50. }
  51. },
  52. "complete": {
  53. "summary": "完整信息",
  54. "value": {
  55. "name": "李四",
  56. "email": "lisi@company.com",
  57. "phone": "13800138000",
  58. "company": "某某科技有限公司",
  59. "subject": "合作洽谈",
  60. "message": "我们公司希望与贵公司建立长期合作关系,请提供详细的产品资料和合作方案。"
  61. }
  62. }
  63. }
  64. }
  65. }
  66. },
  67. "responses": {
  68. "201": {
  69. "description": "留言提交成功",
  70. "content": {
  71. "application/json": {
  72. "schema": {
  73. "$ref": "#/components/schemas/SuccessResponse"
  74. },
  75. "examples": {
  76. "success": {
  77. "summary": "成功响应",
  78. "value": {
  79. "success": true,
  80. "message": "留言提交成功,我们会尽快回复您",
  81. "data": {
  82. "id": 1,
  83. "message": "感谢您的留言,我们已收到并会在24小时内回复"
  84. }
  85. }
  86. }
  87. }
  88. }
  89. }
  90. },
  91. "400": {
  92. "description": "参数验证失败",
  93. "content": {
  94. "application/json": {
  95. "schema": {
  96. "$ref": "#/components/schemas/ErrorResponse"
  97. },
  98. "examples": {
  99. "validation_error": {
  100. "summary": "参数验证失败",
  101. "value": {
  102. "success": false,
  103. "message": "参数验证失败",
  104. "error": [
  105. "联系人姓名不能为空",
  106. "邮箱格式不正确"
  107. ]
  108. }
  109. }
  110. }
  111. }
  112. }
  113. },
  114. "500": {
  115. "description": "服务器内部错误",
  116. "content": {
  117. "application/json": {
  118. "schema": {
  119. "$ref": "#/components/schemas/ErrorResponse"
  120. }
  121. }
  122. }
  123. }
  124. }
  125. },
  126. "get": {
  127. "tags": ["Contact"],
  128. "summary": "获取联系我们列表",
  129. "description": "管理员获取联系我们留言列表,支持分页和状态筛选",
  130. "operationId": "getContacts",
  131. "parameters": [
  132. {
  133. "name": "page",
  134. "in": "query",
  135. "description": "页码",
  136. "required": false,
  137. "schema": {
  138. "type": "integer",
  139. "minimum": 1,
  140. "default": 1
  141. }
  142. },
  143. {
  144. "name": "limit",
  145. "in": "query",
  146. "description": "每页数量",
  147. "required": false,
  148. "schema": {
  149. "type": "integer",
  150. "minimum": 1,
  151. "maximum": 100,
  152. "default": 10
  153. }
  154. },
  155. {
  156. "name": "status",
  157. "in": "query",
  158. "description": "处理状态筛选",
  159. "required": false,
  160. "schema": {
  161. "type": "integer",
  162. "enum": [0, 1],
  163. "description": "0-未处理,1-已处理"
  164. }
  165. }
  166. ],
  167. "responses": {
  168. "200": {
  169. "description": "获取成功",
  170. "content": {
  171. "application/json": {
  172. "schema": {
  173. "type": "object",
  174. "properties": {
  175. "success": {
  176. "type": "boolean",
  177. "example": true
  178. },
  179. "message": {
  180. "type": "string",
  181. "example": "获取成功"
  182. },
  183. "data": {
  184. "type": "object",
  185. "properties": {
  186. "contacts": {
  187. "type": "array",
  188. "items": {
  189. "$ref": "#/components/schemas/Contact"
  190. }
  191. },
  192. "pagination": {
  193. "$ref": "#/components/schemas/Pagination"
  194. }
  195. }
  196. }
  197. }
  198. }
  199. }
  200. }
  201. },
  202. "500": {
  203. "description": "服务器内部错误",
  204. "content": {
  205. "application/json": {
  206. "schema": {
  207. "$ref": "#/components/schemas/ErrorResponse"
  208. }
  209. }
  210. }
  211. }
  212. }
  213. }
  214. },
  215. "/contact/{id}": {
  216. "get": {
  217. "tags": ["Contact"],
  218. "summary": "获取联系详情",
  219. "description": "根据ID获取具体的联系记录详情",
  220. "operationId": "getContactDetail",
  221. "parameters": [
  222. {
  223. "name": "id",
  224. "in": "path",
  225. "required": true,
  226. "description": "联系记录ID",
  227. "schema": {
  228. "type": "integer"
  229. }
  230. }
  231. ],
  232. "responses": {
  233. "200": {
  234. "description": "获取成功",
  235. "content": {
  236. "application/json": {
  237. "schema": {
  238. "type": "object",
  239. "properties": {
  240. "success": {
  241. "type": "boolean",
  242. "example": true
  243. },
  244. "message": {
  245. "type": "string",
  246. "example": "获取成功"
  247. },
  248. "data": {
  249. "$ref": "#/components/schemas/Contact"
  250. }
  251. }
  252. }
  253. }
  254. }
  255. },
  256. "404": {
  257. "description": "联系记录不存在",
  258. "content": {
  259. "application/json": {
  260. "schema": {
  261. "$ref": "#/components/schemas/ErrorResponse"
  262. },
  263. "examples": {
  264. "not_found": {
  265. "summary": "记录不存在",
  266. "value": {
  267. "success": false,
  268. "message": "联系记录不存在",
  269. "error": null
  270. }
  271. }
  272. }
  273. }
  274. }
  275. },
  276. "500": {
  277. "description": "服务器内部错误",
  278. "content": {
  279. "application/json": {
  280. "schema": {
  281. "$ref": "#/components/schemas/ErrorResponse"
  282. }
  283. }
  284. }
  285. }
  286. }
  287. },
  288. "delete": {
  289. "tags": ["Contact"],
  290. "summary": "删除联系记录",
  291. "description": "根据ID删除联系记录",
  292. "operationId": "deleteContact",
  293. "parameters": [
  294. {
  295. "name": "id",
  296. "in": "path",
  297. "required": true,
  298. "description": "联系记录ID",
  299. "schema": {
  300. "type": "integer"
  301. }
  302. }
  303. ],
  304. "responses": {
  305. "200": {
  306. "description": "删除成功",
  307. "content": {
  308. "application/json": {
  309. "schema": {
  310. "type": "object",
  311. "properties": {
  312. "success": {
  313. "type": "boolean",
  314. "example": true
  315. },
  316. "message": {
  317. "type": "string",
  318. "example": "删除成功"
  319. },
  320. "data": {
  321. "type": "null",
  322. "example": null
  323. }
  324. }
  325. }
  326. }
  327. }
  328. },
  329. "404": {
  330. "description": "联系记录不存在",
  331. "content": {
  332. "application/json": {
  333. "schema": {
  334. "$ref": "#/components/schemas/ErrorResponse"
  335. }
  336. }
  337. }
  338. },
  339. "500": {
  340. "description": "服务器内部错误",
  341. "content": {
  342. "application/json": {
  343. "schema": {
  344. "$ref": "#/components/schemas/ErrorResponse"
  345. }
  346. }
  347. }
  348. }
  349. }
  350. }
  351. },
  352. "/contact/{id}/status": {
  353. "put": {
  354. "tags": ["Contact"],
  355. "summary": "更新处理状态",
  356. "description": "更新联系记录的处理状态",
  357. "operationId": "updateContactStatus",
  358. "parameters": [
  359. {
  360. "name": "id",
  361. "in": "path",
  362. "required": true,
  363. "description": "联系记录ID",
  364. "schema": {
  365. "type": "integer"
  366. }
  367. }
  368. ],
  369. "requestBody": {
  370. "required": true,
  371. "content": {
  372. "application/json": {
  373. "schema": {
  374. "type": "object",
  375. "required": ["status"],
  376. "properties": {
  377. "status": {
  378. "type": "integer",
  379. "enum": [0, 1],
  380. "description": "处理状态:0-未处理,1-已处理"
  381. }
  382. }
  383. },
  384. "examples": {
  385. "mark_processed": {
  386. "summary": "标记为已处理",
  387. "value": {
  388. "status": 1
  389. }
  390. },
  391. "mark_unprocessed": {
  392. "summary": "标记为未处理",
  393. "value": {
  394. "status": 0
  395. }
  396. }
  397. }
  398. }
  399. }
  400. },
  401. "responses": {
  402. "200": {
  403. "description": "状态更新成功",
  404. "content": {
  405. "application/json": {
  406. "schema": {
  407. "type": "object",
  408. "properties": {
  409. "success": {
  410. "type": "boolean",
  411. "example": true
  412. },
  413. "message": {
  414. "type": "string",
  415. "example": "状态更新成功"
  416. },
  417. "data": {
  418. "$ref": "#/components/schemas/Contact"
  419. }
  420. }
  421. }
  422. }
  423. }
  424. },
  425. "400": {
  426. "description": "状态值无效",
  427. "content": {
  428. "application/json": {
  429. "schema": {
  430. "$ref": "#/components/schemas/ErrorResponse"
  431. },
  432. "examples": {
  433. "invalid_status": {
  434. "summary": "状态值无效",
  435. "value": {
  436. "success": false,
  437. "message": "状态值只能是0或1",
  438. "error": null
  439. }
  440. }
  441. }
  442. }
  443. }
  444. },
  445. "404": {
  446. "description": "联系记录不存在",
  447. "content": {
  448. "application/json": {
  449. "schema": {
  450. "$ref": "#/components/schemas/ErrorResponse"
  451. }
  452. }
  453. }
  454. },
  455. "500": {
  456. "description": "服务器内部错误",
  457. "content": {
  458. "application/json": {
  459. "schema": {
  460. "$ref": "#/components/schemas/ErrorResponse"
  461. }
  462. }
  463. }
  464. }
  465. }
  466. }
  467. }
  468. },
  469. "components": {
  470. "schemas": {
  471. "CreateContactRequest": {
  472. "type": "object",
  473. "required": ["name", "email", "subject", "message"],
  474. "properties": {
  475. "name": {
  476. "type": "string",
  477. "maxLength": 100,
  478. "description": "联系人姓名",
  479. "example": "张三"
  480. },
  481. "email": {
  482. "type": "string",
  483. "format": "email",
  484. "maxLength": 255,
  485. "description": "联系人邮箱",
  486. "example": "zhangsan@example.com"
  487. },
  488. "phone": {
  489. "type": "string",
  490. "maxLength": 20,
  491. "description": "联系电话",
  492. "example": "13800138000"
  493. },
  494. "company": {
  495. "type": "string",
  496. "maxLength": 200,
  497. "description": "公司名称",
  498. "example": "某某科技有限公司"
  499. },
  500. "subject": {
  501. "type": "string",
  502. "maxLength": 200,
  503. "description": "留言主题",
  504. "example": "产品咨询"
  505. },
  506. "message": {
  507. "type": "string",
  508. "description": "留言内容",
  509. "example": "我想了解一下你们的产品价格和功能特点。"
  510. }
  511. }
  512. },
  513. "Contact": {
  514. "type": "object",
  515. "properties": {
  516. "id": {
  517. "type": "integer",
  518. "description": "联系记录ID",
  519. "example": 1
  520. },
  521. "name": {
  522. "type": "string",
  523. "description": "联系人姓名",
  524. "example": "张三"
  525. },
  526. "email": {
  527. "type": "string",
  528. "format": "email",
  529. "description": "联系人邮箱",
  530. "example": "zhangsan@example.com"
  531. },
  532. "phone": {
  533. "type": "string",
  534. "nullable": true,
  535. "description": "联系电话",
  536. "example": "13800138000"
  537. },
  538. "company": {
  539. "type": "string",
  540. "nullable": true,
  541. "description": "公司名称",
  542. "example": "某某科技有限公司"
  543. },
  544. "subject": {
  545. "type": "string",
  546. "description": "留言主题",
  547. "example": "产品咨询"
  548. },
  549. "message": {
  550. "type": "string",
  551. "description": "留言内容",
  552. "example": "我想了解一下你们的产品价格和功能特点。"
  553. },
  554. "status": {
  555. "type": "integer",
  556. "enum": [0, 1],
  557. "description": "处理状态:0-未处理,1-已处理",
  558. "example": 0
  559. },
  560. "isEmailSent": {
  561. "type": "boolean",
  562. "description": "是否已发送邮件通知",
  563. "example": true
  564. },
  565. "createdAt": {
  566. "type": "string",
  567. "format": "date-time",
  568. "description": "创建时间",
  569. "example": "2024-01-15T10:30:00.000Z"
  570. },
  571. "updatedAt": {
  572. "type": "string",
  573. "format": "date-time",
  574. "description": "更新时间",
  575. "example": "2024-01-15T10:30:00.000Z"
  576. }
  577. }
  578. },
  579. "Pagination": {
  580. "type": "object",
  581. "properties": {
  582. "total": {
  583. "type": "integer",
  584. "description": "总记录数",
  585. "example": 100
  586. },
  587. "page": {
  588. "type": "integer",
  589. "description": "当前页码",
  590. "example": 1
  591. },
  592. "limit": {
  593. "type": "integer",
  594. "description": "每页数量",
  595. "example": 10
  596. },
  597. "totalPages": {
  598. "type": "integer",
  599. "description": "总页数",
  600. "example": 10
  601. }
  602. }
  603. },
  604. "SuccessResponse": {
  605. "type": "object",
  606. "properties": {
  607. "success": {
  608. "type": "boolean",
  609. "description": "请求状态",
  610. "example": true
  611. },
  612. "message": {
  613. "type": "string",
  614. "description": "响应消息",
  615. "example": "操作成功"
  616. },
  617. "data": {
  618. "type": "object",
  619. "description": "响应数据"
  620. }
  621. }
  622. },
  623. "ErrorResponse": {
  624. "type": "object",
  625. "properties": {
  626. "success": {
  627. "type": "boolean",
  628. "description": "请求状态",
  629. "example": false
  630. },
  631. "message": {
  632. "type": "string",
  633. "description": "错误消息",
  634. "example": "操作失败"
  635. },
  636. "error": {
  637. "type": "object",
  638. "description": "错误详情",
  639. "nullable": true
  640. }
  641. }
  642. }
  643. }
  644. }
  645. }