docs: 更新项目文档,完善需求和技术细节
This commit is contained in:
437
java-backend/target/classes/api-docs.yaml
Normal file
437
java-backend/target/classes/api-docs.yaml
Normal file
@@ -0,0 +1,437 @@
|
||||
openapi: 3.0.0
|
||||
info:
|
||||
title: 爱鉴花小程序API文档
|
||||
description: 爱鉴花小程序后端API接口文档
|
||||
version: 1.0.0
|
||||
|
||||
servers:
|
||||
- url: http://localhost:8080/api/v1
|
||||
description: 本地开发服务器
|
||||
|
||||
paths:
|
||||
/auth/register:
|
||||
post:
|
||||
summary: 用户注册
|
||||
description: 用户注册接口,支持用户名、手机号、邮箱注册
|
||||
operationId: register
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/RegisterRequest'
|
||||
responses:
|
||||
'200':
|
||||
description: 注册成功
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponseUser'
|
||||
'400':
|
||||
description: 请求参数错误
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponseError'
|
||||
'409':
|
||||
description: 用户已存在
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponseError'
|
||||
|
||||
/auth/login:
|
||||
post:
|
||||
summary: 用户登录
|
||||
description: 用户登录接口,支持用户名、手机号、邮箱登录
|
||||
operationId: login
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/LoginRequest'
|
||||
responses:
|
||||
'200':
|
||||
description: 登录成功
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponseUser'
|
||||
'400':
|
||||
description: 请求参数错误
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponseError'
|
||||
'401':
|
||||
description: 用户名或密码错误
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponseError'
|
||||
|
||||
/auth/me:
|
||||
get:
|
||||
summary: 获取当前用户信息
|
||||
description: 获取当前登录用户信息
|
||||
operationId: getCurrentUser
|
||||
security:
|
||||
- bearerAuth: []
|
||||
responses:
|
||||
'200':
|
||||
description: 获取成功
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponseUser'
|
||||
'401':
|
||||
description: 未授权
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponseError'
|
||||
'404':
|
||||
description: 用户不存在
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponseError'
|
||||
|
||||
/upload:
|
||||
post:
|
||||
summary: 上传文件
|
||||
description: 上传文件接口,支持图片、文档等文件类型
|
||||
operationId: uploadFile
|
||||
security:
|
||||
- bearerAuth: []
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
multipart/form-data:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
file:
|
||||
type: string
|
||||
format: binary
|
||||
responses:
|
||||
'200':
|
||||
description: 上传成功
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponseUpload'
|
||||
'400':
|
||||
description: 请求参数错误
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponseError'
|
||||
'401':
|
||||
description: 未授权
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponseError'
|
||||
'500':
|
||||
description: 服务器内部错误
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponseError'
|
||||
|
||||
/upload/list:
|
||||
get:
|
||||
summary: 获取上传文件列表
|
||||
description: 获取当前用户上传的文件列表
|
||||
operationId: getUploads
|
||||
security:
|
||||
- bearerAuth: []
|
||||
responses:
|
||||
'200':
|
||||
description: 获取成功
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Upload'
|
||||
'401':
|
||||
description: 未授权
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponseError'
|
||||
|
||||
/upload/{id}:
|
||||
delete:
|
||||
summary: 删除上传文件
|
||||
description: 删除指定ID的上传文件
|
||||
operationId: deleteUpload
|
||||
security:
|
||||
- bearerAuth: []
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
format: int64
|
||||
responses:
|
||||
'200':
|
||||
description: 删除成功
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponseString'
|
||||
'401':
|
||||
description: 未授权
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponseError'
|
||||
'404':
|
||||
description: 文件不存在
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponseError'
|
||||
|
||||
/health:
|
||||
get:
|
||||
summary: 服务健康检查
|
||||
description: 检查服务运行状态
|
||||
operationId: healthCheck
|
||||
responses:
|
||||
'200':
|
||||
description: 服务正常
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponseHealth'
|
||||
|
||||
components:
|
||||
securitySchemes:
|
||||
bearerAuth:
|
||||
type: http
|
||||
scheme: bearer
|
||||
bearerFormat: JWT
|
||||
|
||||
schemas:
|
||||
RegisterRequest:
|
||||
type: object
|
||||
required:
|
||||
- username
|
||||
- password
|
||||
- phone
|
||||
properties:
|
||||
username:
|
||||
type: string
|
||||
description: 用户名
|
||||
password:
|
||||
type: string
|
||||
minLength: 6
|
||||
description: 密码
|
||||
phone:
|
||||
type: string
|
||||
description: 手机号
|
||||
email:
|
||||
type: string
|
||||
format: email
|
||||
description: 邮箱
|
||||
userType:
|
||||
type: string
|
||||
default: farmer
|
||||
description: 用户类型
|
||||
|
||||
LoginRequest:
|
||||
type: object
|
||||
required:
|
||||
- login
|
||||
- password
|
||||
properties:
|
||||
login:
|
||||
type: string
|
||||
description: 登录凭证(用户名/手机号/邮箱)
|
||||
password:
|
||||
type: string
|
||||
description: 密码
|
||||
|
||||
ApiResponseMap:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
description: 响应码
|
||||
message:
|
||||
type: string
|
||||
description: 响应消息
|
||||
data:
|
||||
type: object
|
||||
description: 响应数据
|
||||
|
||||
ApiResponseUser:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
description: 响应码
|
||||
message:
|
||||
type: string
|
||||
description: 响应消息
|
||||
data:
|
||||
$ref: '#/components/schemas/UserResponse'
|
||||
|
||||
ApiResponseUpload:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
description: 响应码
|
||||
message:
|
||||
type: string
|
||||
description: 响应消息
|
||||
data:
|
||||
$ref: '#/components/schemas/UploadResponse'
|
||||
|
||||
ApiResponseError:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
description: 错误码
|
||||
message:
|
||||
type: string
|
||||
description: 错误消息
|
||||
data:
|
||||
type: object
|
||||
nullable: true
|
||||
description: 错误数据
|
||||
|
||||
UserResponse:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
description: 用户ID
|
||||
username:
|
||||
type: string
|
||||
description: 用户名
|
||||
phone:
|
||||
type: string
|
||||
description: 手机号
|
||||
email:
|
||||
type: string
|
||||
format: email
|
||||
description: 邮箱
|
||||
userType:
|
||||
type: string
|
||||
description: 用户类型
|
||||
avatarUrl:
|
||||
type: string
|
||||
description: 头像URL
|
||||
createdAt:
|
||||
type: string
|
||||
format: date-time
|
||||
description: 创建时间
|
||||
lastLogin:
|
||||
type: string
|
||||
format: date-time
|
||||
description: 最后登录时间
|
||||
|
||||
UploadResponse:
|
||||
type: object
|
||||
properties:
|
||||
url:
|
||||
type: string
|
||||
description: 文件访问URL
|
||||
filename:
|
||||
type: string
|
||||
description: 存储文件名
|
||||
originalName:
|
||||
type: string
|
||||
description: 原始文件名
|
||||
size:
|
||||
type: integer
|
||||
description: 文件大小
|
||||
mimeType:
|
||||
type: string
|
||||
description: MIME类型
|
||||
uploadType:
|
||||
type: string
|
||||
description: 上传类型
|
||||
|
||||
PageResponseUpload:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
description: 响应码
|
||||
message:
|
||||
type: string
|
||||
description: 响应消息
|
||||
data:
|
||||
type: object
|
||||
properties:
|
||||
items:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Upload'
|
||||
pagination:
|
||||
$ref: '#/components/schemas/Pagination'
|
||||
|
||||
Upload:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
description: 文件ID
|
||||
userId:
|
||||
type: integer
|
||||
description: 用户ID
|
||||
originalName:
|
||||
type: string
|
||||
description: 原始文件名
|
||||
storedName:
|
||||
type: string
|
||||
description: 存储文件名
|
||||
filePath:
|
||||
type: string
|
||||
description: 文件路径
|
||||
fileSize:
|
||||
type: integer
|
||||
description: 文件大小
|
||||
mimeType:
|
||||
type: string
|
||||
description: MIME类型
|
||||
fileType:
|
||||
type: string
|
||||
description: 文件类型
|
||||
uploadType:
|
||||
type: string
|
||||
description: 上传类型
|
||||
createdAt:
|
||||
type: string
|
||||
format: date-time
|
||||
description: 创建时间
|
||||
updatedAt:
|
||||
type: string
|
||||
format: date-time
|
||||
description: 更新时间
|
||||
|
||||
Pagination:
|
||||
type: object
|
||||
properties:
|
||||
page:
|
||||
type: integer
|
||||
description: 当前页码
|
||||
limit:
|
||||
type: integer
|
||||
description: 每页数量
|
||||
total:
|
||||
type: integer
|
||||
description: 总记录数
|
||||
pages:
|
||||
type: integer
|
||||
description: 总页数
|
||||
47
java-backend/target/classes/application.yml
Normal file
47
java-backend/target/classes/application.yml
Normal file
@@ -0,0 +1,47 @@
|
||||
server:
|
||||
port: 3200
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: aijianhua-backend
|
||||
datasource:
|
||||
url: jdbc:mysql://129.211.213.226:9527/xlxumudata?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
|
||||
username: root
|
||||
password: aiotAiot123!
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
hikari:
|
||||
maximum-pool-size: 20
|
||||
minimum-idle: 5
|
||||
connection-timeout: 30000
|
||||
idle-timeout: 10000
|
||||
max-lifetime: 1800000
|
||||
connection-test-query: SELECT 1
|
||||
jpa:
|
||||
hibernate:
|
||||
ddl-auto: update
|
||||
show-sql: false
|
||||
properties:
|
||||
hibernate:
|
||||
dialect: org.hibernate.dialect.MySQL8Dialect
|
||||
format_sql: true
|
||||
open-in-view: false
|
||||
flyway:
|
||||
enabled: false
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 10MB
|
||||
max-request-size: 10MB
|
||||
|
||||
# JWT配置
|
||||
jwt:
|
||||
secret: xluMubackendSecretKey2024!
|
||||
expiration: 604800000 # 7天
|
||||
|
||||
# 日志配置
|
||||
logging:
|
||||
level:
|
||||
com.aijianhua: INFO
|
||||
org.springframework.web: INFO
|
||||
org.hibernate.SQL: INFO
|
||||
pattern:
|
||||
console: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,29 @@
|
||||
-- 创建用户表
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||
username VARCHAR(50) NOT NULL UNIQUE,
|
||||
password VARCHAR(255) NOT NULL,
|
||||
phone VARCHAR(20) UNIQUE,
|
||||
email VARCHAR(100) UNIQUE,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
is_active BOOLEAN DEFAULT TRUE
|
||||
);
|
||||
|
||||
-- 创建文件上传表
|
||||
CREATE TABLE IF NOT EXISTS uploads (
|
||||
id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||
user_id BIGINT NOT NULL,
|
||||
original_name VARCHAR(255) NOT NULL,
|
||||
file_path VARCHAR(500) NOT NULL,
|
||||
file_type VARCHAR(50) NOT NULL,
|
||||
file_size BIGINT NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
-- 创建索引
|
||||
CREATE INDEX idx_users_username ON users(username);
|
||||
CREATE INDEX idx_users_phone ON users(phone);
|
||||
CREATE INDEX idx_users_email ON users(email);
|
||||
CREATE INDEX idx_uploads_user_id ON uploads(user_id);
|
||||
Reference in New Issue
Block a user