- 出租/租赁资源
- 资源展示
- 账号系统
- 资源审核
- 反馈评价
- 客服和帮助中心
- 地图定位
- 系统通知
- AR/VR展示
- 社区交流
- 个性化推荐
- 资源评估
- 信用评分
- 日志记录
- 数据加密
- TODO
- 用户模块
- 资源模块
- 评价模块
- 日志模块
- 功能
- 用户注册
- 用户登录
- 页面跳转关系
- 功能
- 资源发布
- 资源编辑
- 功能
- 资源展示
- 资源评论
- 资源收藏
- 联系出租方
- 页面跳转关系
- 资源所属用户个人主页
- 功能
- 资源搜索
- 资源筛选
- 资源排序
- 页面跳转关系
- 搜索结果资源列表页
- 功能
- 查看收藏
- 取消收藏
- 页面跳转关系
- 功能
- 修改用户信息
- 其他设置
- 功能
- 查看浏览历史
- 管理浏览历史
- 页面跳转关系
create table user
(
id int auto_increment
primary key,
phone char(11) null,
name varchar(255) null,
avatar varchar(255) null,
role varchar(255) null,
created_at datetime default CURRENT_TIMESTAMP null,
updated_at datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP
constraint user_pk
unique (phone)
);
create table resource
(
id int auto_increment
primary key,
name varchar(255) null,
type varchar(255) null,
duration varchar(255) null,
user_id int null,
description text null,
price decimal(10, 2) null,
view int null,
created_at datetime default CURRENT_TIMESTAMP null,
updated_at datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP,
constraint resource_pk
unique (name, user_id),
constraint resource_ibfk_1
foreign key (user_id) references user (id)
);
create index user_id
on resource (user_id);
create table media
(
id int auto_increment
primary key,
resource_id int null,
url varchar(255) null,
created_at datetime default CURRENT_TIMESTAMP null,
constraint media_ibfk_1
foreign key (resource_id) references resource (id)
);
create index resource_id
on media (resource_id);
create table log
(
id int auto_increment
primary key,
user_id int null,
resource_id int null,
action varchar(255) null,
created_at datetime default CURRENT_TIMESTAMP null,
constraint log_ibfk_1
foreign key (user_id) references user (id),
constraint log_ibfk_2
foreign key (resource_id) references resource (id)
);
create index resource_id
on log (resource_id);
create index user_id
on log (user_id);
create table comment
(
id int auto_increment
primary key,
user_id int null,
resource_id int null,
parent_id int null,
content text null,
created_at datetime default CURRENT_TIMESTAMP null,
constraint comment_ibfk_1
foreign key (user_id) references user (id),
constraint comment_ibfk_2
foreign key (resource_id) references resource (id)
);
create index resource_id
on comment (resource_id);
create index user_id
on comment (user_id);
create table favorite
(
id int auto_increment
primary key,
user_id int null,
resource_id int null,
created_at datetime default CURRENT_TIMESTAMP null,
constraint favorite_ibfk_1
foreign key (user_id) references user (id),
constraint favorite_ibfk_2
foreign key (resource_id) references resource (id)
);
create table history
(
id int auto_increment
primary key,
user_id int null,
resource_id int null,
created_at datetime default CURRENT_TIMESTAMP null,
constraint history_ibfk_1
foreign key (user_id) references user (id),
constraint history_ibfk_2
foreign key (resource_id) references resource (id)
);
create table message
(
id int auto_increment
primary key,
sender_id int null,
receiver_id int null,
content text null,
created_at datetime default CURRENT_TIMESTAMP null,
constraint message_user_id_fk
foreign key (sender_id) references user (id),
constraint message_user_id_fk_2
foreign key (receiver_id) references user (id)
);
单体架构+前后端分离
- 用户界面层
- 业务逻辑层
- 数据访问层
- RESTful API
- json数据交互
- 数据加密
- 用户认证
- uni-app
- Vue.js
- Java Spring Boot
- MySQL
- Ubuntu 22.04 LTS Server
- HTTPS
- MD5
- Git
- Docker
-
注册/登录示例
- URL: /user/login
- Method: POST
- Request:
- phone: 手机号
- role: 角色
- Response:
- data:
- id: 用户ID
- phone: 手机号
- name: 用户名
- avatar: 头像(url)
- role: 角色
- data:
-
更新用户信息示例
- URL: /user/update/{id}
- Method: PUT
- Request:
- id: 用户ID
- phone: 手机号
- name: 用户名
- avatar: 头像(通过Media接口上传)
- role: 角色
- Response:
- data: 用户信息
- id: 用户ID
- phone: 手机号
- name: 用户名
- avatar: 头像(url)
- role: 角色
- data: 用户信息
-
获取用户发布的资源列表示例
- URL: /resource/list/{userid}
- Method: GET
- Request:
- userId: 用户ID
- Response:
- data: 资源列表
- item: 资源信息
- id: 资源ID
- name: 资源名称
- type: 资源类型
- user: 发布者
- cover: 封面图片url
- description: 描述
- price: 价格
- view: 浏览量
- duration: 租赁时长
- item: 资源信息
- data: 资源列表
-
发布资源示例
- URL: /resource/publish
- Method: POST
- Request:
- userId: 发布者ID
- name: 资源名称
- type: 资源类型
- description: 描述
- address: 地址
- latitude: 纬度
- longitude: 经度
- price: 价格
- view: 浏览量
- duration: 租赁时长
- decoration: 装修情况
- equipment: 周边设备
- media: 媒体资源通过Media接口上传
- Response:
- data: 资源信息
- id: 资源ID
- name: 资源名称
- type: 资源类型
- userId: 发布者ID
- cover: 封面图片url
- description: 描述
- address: 地址
- latitude: 纬度
- longitude: 经度
- price: 价格
- view: 浏览量
- decoration: 装修情况
- equipment: 周边设备
- duration: 租赁时长
- data: 资源信息
-
修改资源信息示例
- URL: /resource/update/{id}
- Method: PUT
- Request: id必须, 剩余参数可选
- id: 资源ID
- name: 资源名称
- type: 资源类型
- description: 描述
- price: 价格
- view: 浏览量
- duration: 租赁时长
- decoration: 装修情况
- equipment: 周边设备
- media: 媒体资源通过Media接口上传
- Response:
- data: 资源信息
- id: 资源ID
- name: 资源名称
- type: 资源类型
- user: 发布者
- cover: 封面图片url
- description: 描述
- price: 价格
- view: 浏览量
- duration: 租赁时长
- decoration: 装修情况
- equipment: 周边设备
- data: 资源信息
-
删除资源示例
- URL: /resource/delete/{id}
- Method: DELETE
- Request: id必须
- id: 资源ID
-
推荐资源示例
- URL: /resource/recommend
- Method: GET
- Response:
- data: 资源列表
- item: 资源信息
- id: 资源ID
- name: 资源名称
- type: 资源类型
- user: 发布者
- cover: 封面图片url
- description: 描述
- price: 价格
- view: 浏览量
- duration: 租赁时长
- item: 资源信息
- data: 资源列表
-
收藏资源示例
- URL: /resource/favorite/{userId}/{resourceId}
- Method: POST
- Request:
- userId: 用户ID
- resourceId: 资源ID
-
取消收藏资源示例
- URL: /resource/unfavorite/{userId}/{resourceId}
- Method: DELETE
- Request:
- userId: 用户ID
- resourceId: 资源ID
-
收藏列表示例
- URL: /resource/favoriteList/{userId}
- Method: GET
- Request:
- userId: 用户ID
- Response:
- data: 收藏列表
- item: 收藏资源信息
- id: 资源ID
- name: 资源名称
- type: 资源类型
- user: 发布者
- cover: 封面图片url
- description: 描述
- price: 价格
- view: 浏览量
- duration: 租赁时长
- item: 收藏资源信息
- data: 收藏列表
-
资源详情示例
- URL: /resource/detail/{userId}/{resourceId}
- Method: GET
- Request:
- resourceId: 资源ID
- userId: 用户ID
- Response:
- data: 资源信息
- id: 资源ID
- name: 资源名称
- type: 资源类型
- user: 发布者
- cover: 封面图片url
- description: 描述
- price: 价格
- view: 浏览量
- duration: 租赁时长
- mediaUrl: 媒体url列表
- item: 媒体url
- url: url
- item: 媒体url
- data: 资源信息
-
浏览历史示例
- URL: /resource/history/{userId}
- Method: GET
- Request:
- userId: 用户ID
- Response:
- data: 浏览历史列表 按时间降序
- item: 浏览资源信息
- id: 资源ID
- name: 资源名称
- type: 资源类型
- user: 发布者
- cover: 封面图片url
- description: 描述
- price: 价格
- view: 浏览量
- duration: 租赁时长
- item: 浏览资源信息
- data: 浏览历史列表 按时间降序
-
资源搜索示例
- URL: /resource/search
- Method: GET
- Request:
- keyword: 关键词
- Response:
- data: 资源列表
- item: 资源信息
- id: 资源ID
- name: 资源名称
- type: 资源类型
- user: 发布者
- cover: 封面图片url
- description: 描述
- price: 价格
- view: 浏览量
- duration: 租赁时长
- item: 资源信息
- data: 资源列表
-
搜索列表补全示例
- URL: /resource/search/autoCompleteList
- Method: GET
- Request:
- keyword: 关键词
- Response:
- data: 推荐关键词列表
- item: 关键词
- data: 推荐关键词列表
-
资源简要信息示例
- URL: /resource/get/{resourceId}
- Method: GET
- Request:
- resourceId: 资源ID
- Response:
- data: 资源信息
- id: 资源ID
- name: 资源名称
- type: 资源类型
- user: 发布者
- cover: 封面图片url
- description: 描述
- price: 价格
- view: 浏览量
- duration: 租赁时长
- equipment: 周边设备
- decoration: 装修情况
- data: 资源信息
-
获取未审核资源列表示例
- URL: /resource/toCheck
- Method: GET
- Response:
- data: 资源列表
- item: 资源信息
- id: 资源ID
- name: 资源名称
- type: 资源类型
- user: 发布者
- cover: 封面图片url
- description: 描述
- price: 价格
- view: 浏览量
- duration: 租赁时长
- created_at: 发布时间
- equipment: 周边设备
- decoration: 装修情况
- item: 资源信息
- data: 资源列表
-
审核资源示例
- URL: /resource/check/{id}/{status}
- Method: POST
- Request:
- id: 资源ID
- status: 审核状态("unchecked", "checked", "rejected")
-
上传文件示例
- URL: /media/upload/{resourceId}
- Method: POST
- Request:
- file: 文件
- resourceId: 资源ID(上传用户头像时resourceId设置为avatar)
-
访问文件示例
- URL: /media/{prefixPath:.+}/{filename:.+}
- Method: GET
- Request:
- prefixPath: 文件路径(头像为avatar, 资源图片/视频为对应资源id)
- filename: 文件名
-
删除文件示例
- URL: /media/delete/{prefixPath:.+}/{filename:.+}
- Method: DELETE
- Request:
- prefixPath: 文件路径(头像为avatar, 资源图片/视频为对应资源id)
- filename: 文件名
-
发布评论示例
- URL: /comment/publish
- Method: POST
- Request:
- userId: 用户ID
- resourceId: 资源ID
- content: 评论内容
- parentId: 父评论ID(回复评论时使用)
-
删除评论示例
- URL: /comment/delete/{id}
- Method: DELETE
- Request:
- id: 评论ID
-
获取评论列表示例
- URL: /comment/get/{resourceId}
- Method: GET
- Request:
- resourceId: 资源ID
- Response:
- data: 评论列表
- item: 评论信息
- id: 评论ID
- user: 评论者
- content: 评论内容
- created_at: 评论时间
- children: 子评论列表
- item: 子评论信息
- id: 评论ID
- user: 评论者
- content: 评论内容
- created_at: 评论时间
- item: 子评论信息
- item: 评论信息
- data: 评论列表
- 发送消息示例
- 获取消息记录示例
- URL: /message/dialogue/{receiverId}/{senderId}
- Method: GET
- Request:
- receiverId: 接收者ID
- senderId: 发送者ID
- Response:
- data: 消息列表
- item: 消息信息
- senderId: 发送者
- receiverId: 接收者
- content: 消息内容
- time: 消息时间
- item: 消息信息
- data: 消息列表
const data = {
phone: 11122223333,
}
fetch("http://kimin.cn:8080/user/login", {
method: "POST",
body: JSON.stringify({data})
})
const data = {
name: "张三",
}
fetch("http://kimin.cn:8080/user/update/1", {
method: "PUT",
body: JSON.stringify({data})
})
const data = {
name: "资源1",
type: "类型1",
description: "描述1",
address: {
latitude: 9.999,
longitude: 1.111,
},
price: "80-100",
decoration: "精装",
equipment: "学校;超市",
duration: "1w", // 一周
}
fetch("http://kimin.cn:8080/resource/publish", {
method: "POST",
body: JSON.stringify({data})
})
const data = {
id: 1,
name: "资源2",
type: "类型2",
description: "描述1",
view: 1,
price: 1000,
address: {
latitude: 9.999,
longitude: 1.111,
},
decoration: "精装",
equipment: "学校;超市",
duration: "1m", // 一月
}
fetch("http://kimin.cn:8080/resource/update/1", {
method: "PUT",
body: JSON.stringify({data})
})
fetch("http://kimin.cn:8080/resource/delete/1", {
method: "POST",
})
fetch("http://kimin.cn:8080/resource/list/1", {
method: "GET",
})
fetch("http://kimin.cn:8080/resource/recommend", {
method: "GET",
})
fetch("http://kimin.cn:8080/resource/favorite/1", {
method: "POST",
body: JSON.stringify()
})
fetch("http://kimin.cn:8080/resource/unfavorite/1", {
method: "POST",
body: JSON.stringify()
})
fetch("http://kimin.cn:8080/resource/favorite/list/1", {
method: "GET",
})
fetch("http://kimin.cn:8080/resource/detail/1/5", {
method: "GET",
})
fetch("http://kimin.cn:8080/resource/history/1", {
method: "GET",
})
fetch("http://kimin.cn:8080/resource/search?keyword=1", {
method: "GET",
})
fetch("http://kimin.cn:8080/resource/search/autoCompleteList?keyword=resource", {
method: "GET",
})
fetch("http://kimin.cn:8080/resource/get/1", {
method: "GET",
})
fetch("http://kimin.cn:8080/resource/toCheck", {
method: "GET",
})
fetch("http://kimin.cn:8080/resource/check/1/checked", {
method: "POST",
})
const data = {
file: null, //通过input["file"].files[0]获取
}
fetch("http://kimin.cn:8080/media/upload/1", {
method: "POST",
body: JSON.stringify({data})
})
<img src="http://kimin.cn:8080/media/avatar/default.png" alt="avatar">
fetch("http://kimin.cn:8080/media/delete/1/1.png", {
method: "POST",
})
const data = {
userId: 1,
resourceId: 1,
content: "评论内容",
}
fetch("http://kimin.cn:8080/comment/publish", {
method: "POST",
body: JSON.stringify({data})
})
const data = {
resourceId: 1,
content: "评论内容",
parentId: 1,
}
fetch("http://kimin.cn:8080/comment/publish", {
method: "POST",
body: JSON.stringify({data})
})
fetch("http://kimin.cn:8080/comment/delete/1", {
method: "POST",
})
fetch("http://kimin.cn:8080/comment/get/1", {
method: "GET",
})
// 补充获取id的具体逻辑
var userId = 1;
var receiverId = 2;
var ws = new WebSocket("ws://kimin.cn:8080/message?userId=" + userId);
ws.onmessage = function (event) {
// 向聊天框添加消息
var chat = document.getElementById('chat');
var message = document.createElement('div');
// event.data为消息内容
message.textContent = event.data;
chat.appendChild(message);
}
function sendMessage() {
var input = document.getElementById('message');
// 格式为receiverId:message
var msg = receiverId + ":" + input.value;
ws.send(msg);
input.value = '';
}
fetch("http://kimin.cn:8080/message/dialogue/1/2", {
method: "GET",
})