123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645 |
- {
- "openapi": "3.0.0",
- "info": {
- "title": "飞鸟农场联系我们API",
- "description": "飞鸟农场网站联系我们模块的API接口文档",
- "version": "1.0.0",
- "contact": {
- "name": "飞鸟农场开发团队",
- "email": "dev@feiniao.com"
- }
- },
- "servers": [
- {
- "url": "http://localhost:3000",
- "description": "开发环境"
- },
- {
- "url": "https://api.feiniao.com",
- "description": "生产环境"
- }
- ],
- "tags": [
- {
- "name": "Contact",
- "description": "联系我们相关接口"
- }
- ],
- "paths": {
- "/contact": {
- "post": {
- "tags": ["Contact"],
- "summary": "提交联系我们表单",
- "description": "用户提交联系我们表单,系统会保存到数据库并发送邮件通知",
- "operationId": "createContact",
- "requestBody": {
- "required": true,
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/CreateContactRequest"
- },
- "examples": {
- "basic": {
- "summary": "基本留言",
- "value": {
- "name": "张三",
- "email": "zhangsan@example.com",
- "subject": "产品咨询",
- "message": "我想了解一下你们的产品价格和功能特点。"
- }
- },
- "complete": {
- "summary": "完整信息",
- "value": {
- "name": "李四",
- "email": "lisi@company.com",
- "phone": "13800138000",
- "company": "某某科技有限公司",
- "subject": "合作洽谈",
- "message": "我们公司希望与贵公司建立长期合作关系,请提供详细的产品资料和合作方案。"
- }
- }
- }
- }
- }
- },
- "responses": {
- "201": {
- "description": "留言提交成功",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/SuccessResponse"
- },
- "examples": {
- "success": {
- "summary": "成功响应",
- "value": {
- "success": true,
- "message": "留言提交成功,我们会尽快回复您",
- "data": {
- "id": 1,
- "message": "感谢您的留言,我们已收到并会在24小时内回复"
- }
- }
- }
- }
- }
- }
- },
- "400": {
- "description": "参数验证失败",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ErrorResponse"
- },
- "examples": {
- "validation_error": {
- "summary": "参数验证失败",
- "value": {
- "success": false,
- "message": "参数验证失败",
- "error": [
- "联系人姓名不能为空",
- "邮箱格式不正确"
- ]
- }
- }
- }
- }
- }
- },
- "500": {
- "description": "服务器内部错误",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ErrorResponse"
- }
- }
- }
- }
- }
- },
- "get": {
- "tags": ["Contact"],
- "summary": "获取联系我们列表",
- "description": "管理员获取联系我们留言列表,支持分页和状态筛选",
- "operationId": "getContacts",
- "parameters": [
- {
- "name": "page",
- "in": "query",
- "description": "页码",
- "required": false,
- "schema": {
- "type": "integer",
- "minimum": 1,
- "default": 1
- }
- },
- {
- "name": "limit",
- "in": "query",
- "description": "每页数量",
- "required": false,
- "schema": {
- "type": "integer",
- "minimum": 1,
- "maximum": 100,
- "default": 10
- }
- },
- {
- "name": "status",
- "in": "query",
- "description": "处理状态筛选",
- "required": false,
- "schema": {
- "type": "integer",
- "enum": [0, 1],
- "description": "0-未处理,1-已处理"
- }
- }
- ],
- "responses": {
- "200": {
- "description": "获取成功",
- "content": {
- "application/json": {
- "schema": {
- "type": "object",
- "properties": {
- "success": {
- "type": "boolean",
- "example": true
- },
- "message": {
- "type": "string",
- "example": "获取成功"
- },
- "data": {
- "type": "object",
- "properties": {
- "contacts": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Contact"
- }
- },
- "pagination": {
- "$ref": "#/components/schemas/Pagination"
- }
- }
- }
- }
- }
- }
- }
- },
- "500": {
- "description": "服务器内部错误",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ErrorResponse"
- }
- }
- }
- }
- }
- }
- },
- "/contact/{id}": {
- "get": {
- "tags": ["Contact"],
- "summary": "获取联系详情",
- "description": "根据ID获取具体的联系记录详情",
- "operationId": "getContactDetail",
- "parameters": [
- {
- "name": "id",
- "in": "path",
- "required": true,
- "description": "联系记录ID",
- "schema": {
- "type": "integer"
- }
- }
- ],
- "responses": {
- "200": {
- "description": "获取成功",
- "content": {
- "application/json": {
- "schema": {
- "type": "object",
- "properties": {
- "success": {
- "type": "boolean",
- "example": true
- },
- "message": {
- "type": "string",
- "example": "获取成功"
- },
- "data": {
- "$ref": "#/components/schemas/Contact"
- }
- }
- }
- }
- }
- },
- "404": {
- "description": "联系记录不存在",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ErrorResponse"
- },
- "examples": {
- "not_found": {
- "summary": "记录不存在",
- "value": {
- "success": false,
- "message": "联系记录不存在",
- "error": null
- }
- }
- }
- }
- }
- },
- "500": {
- "description": "服务器内部错误",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ErrorResponse"
- }
- }
- }
- }
- }
- },
- "delete": {
- "tags": ["Contact"],
- "summary": "删除联系记录",
- "description": "根据ID删除联系记录",
- "operationId": "deleteContact",
- "parameters": [
- {
- "name": "id",
- "in": "path",
- "required": true,
- "description": "联系记录ID",
- "schema": {
- "type": "integer"
- }
- }
- ],
- "responses": {
- "200": {
- "description": "删除成功",
- "content": {
- "application/json": {
- "schema": {
- "type": "object",
- "properties": {
- "success": {
- "type": "boolean",
- "example": true
- },
- "message": {
- "type": "string",
- "example": "删除成功"
- },
- "data": {
- "type": "null",
- "example": null
- }
- }
- }
- }
- }
- },
- "404": {
- "description": "联系记录不存在",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ErrorResponse"
- }
- }
- }
- },
- "500": {
- "description": "服务器内部错误",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ErrorResponse"
- }
- }
- }
- }
- }
- }
- },
- "/contact/{id}/status": {
- "put": {
- "tags": ["Contact"],
- "summary": "更新处理状态",
- "description": "更新联系记录的处理状态",
- "operationId": "updateContactStatus",
- "parameters": [
- {
- "name": "id",
- "in": "path",
- "required": true,
- "description": "联系记录ID",
- "schema": {
- "type": "integer"
- }
- }
- ],
- "requestBody": {
- "required": true,
- "content": {
- "application/json": {
- "schema": {
- "type": "object",
- "required": ["status"],
- "properties": {
- "status": {
- "type": "integer",
- "enum": [0, 1],
- "description": "处理状态:0-未处理,1-已处理"
- }
- }
- },
- "examples": {
- "mark_processed": {
- "summary": "标记为已处理",
- "value": {
- "status": 1
- }
- },
- "mark_unprocessed": {
- "summary": "标记为未处理",
- "value": {
- "status": 0
- }
- }
- }
- }
- }
- },
- "responses": {
- "200": {
- "description": "状态更新成功",
- "content": {
- "application/json": {
- "schema": {
- "type": "object",
- "properties": {
- "success": {
- "type": "boolean",
- "example": true
- },
- "message": {
- "type": "string",
- "example": "状态更新成功"
- },
- "data": {
- "$ref": "#/components/schemas/Contact"
- }
- }
- }
- }
- }
- },
- "400": {
- "description": "状态值无效",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ErrorResponse"
- },
- "examples": {
- "invalid_status": {
- "summary": "状态值无效",
- "value": {
- "success": false,
- "message": "状态值只能是0或1",
- "error": null
- }
- }
- }
- }
- }
- },
- "404": {
- "description": "联系记录不存在",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ErrorResponse"
- }
- }
- }
- },
- "500": {
- "description": "服务器内部错误",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ErrorResponse"
- }
- }
- }
- }
- }
- }
- }
- },
- "components": {
- "schemas": {
- "CreateContactRequest": {
- "type": "object",
- "required": ["name", "email", "subject", "message"],
- "properties": {
- "name": {
- "type": "string",
- "maxLength": 100,
- "description": "联系人姓名",
- "example": "张三"
- },
- "email": {
- "type": "string",
- "format": "email",
- "maxLength": 255,
- "description": "联系人邮箱",
- "example": "zhangsan@example.com"
- },
- "phone": {
- "type": "string",
- "maxLength": 20,
- "description": "联系电话",
- "example": "13800138000"
- },
- "company": {
- "type": "string",
- "maxLength": 200,
- "description": "公司名称",
- "example": "某某科技有限公司"
- },
- "subject": {
- "type": "string",
- "maxLength": 200,
- "description": "留言主题",
- "example": "产品咨询"
- },
- "message": {
- "type": "string",
- "description": "留言内容",
- "example": "我想了解一下你们的产品价格和功能特点。"
- }
- }
- },
- "Contact": {
- "type": "object",
- "properties": {
- "id": {
- "type": "integer",
- "description": "联系记录ID",
- "example": 1
- },
- "name": {
- "type": "string",
- "description": "联系人姓名",
- "example": "张三"
- },
- "email": {
- "type": "string",
- "format": "email",
- "description": "联系人邮箱",
- "example": "zhangsan@example.com"
- },
- "phone": {
- "type": "string",
- "nullable": true,
- "description": "联系电话",
- "example": "13800138000"
- },
- "company": {
- "type": "string",
- "nullable": true,
- "description": "公司名称",
- "example": "某某科技有限公司"
- },
- "subject": {
- "type": "string",
- "description": "留言主题",
- "example": "产品咨询"
- },
- "message": {
- "type": "string",
- "description": "留言内容",
- "example": "我想了解一下你们的产品价格和功能特点。"
- },
- "status": {
- "type": "integer",
- "enum": [0, 1],
- "description": "处理状态:0-未处理,1-已处理",
- "example": 0
- },
- "isEmailSent": {
- "type": "boolean",
- "description": "是否已发送邮件通知",
- "example": true
- },
- "createdAt": {
- "type": "string",
- "format": "date-time",
- "description": "创建时间",
- "example": "2024-01-15T10:30:00.000Z"
- },
- "updatedAt": {
- "type": "string",
- "format": "date-time",
- "description": "更新时间",
- "example": "2024-01-15T10:30:00.000Z"
- }
- }
- },
- "Pagination": {
- "type": "object",
- "properties": {
- "total": {
- "type": "integer",
- "description": "总记录数",
- "example": 100
- },
- "page": {
- "type": "integer",
- "description": "当前页码",
- "example": 1
- },
- "limit": {
- "type": "integer",
- "description": "每页数量",
- "example": 10
- },
- "totalPages": {
- "type": "integer",
- "description": "总页数",
- "example": 10
- }
- }
- },
- "SuccessResponse": {
- "type": "object",
- "properties": {
- "success": {
- "type": "boolean",
- "description": "请求状态",
- "example": true
- },
- "message": {
- "type": "string",
- "description": "响应消息",
- "example": "操作成功"
- },
- "data": {
- "type": "object",
- "description": "响应数据"
- }
- }
- },
- "ErrorResponse": {
- "type": "object",
- "properties": {
- "success": {
- "type": "boolean",
- "description": "请求状态",
- "example": false
- },
- "message": {
- "type": "string",
- "description": "错误消息",
- "example": "操作失败"
- },
- "error": {
- "type": "object",
- "description": "错误详情",
- "nullable": true
- }
- }
- }
- }
- }
- }
|