You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
3 weeks ago | |
|---|---|---|
| .. | ||
| src | 3 weeks ago | |
| target | 3 weeks ago | |
| API使用指南.md | 3 weeks ago | |
| README.md | 2 months ago | |
| TestServer.class | 3 weeks ago | |
| TestServer.java | 3 weeks ago | |
| add_condition_column.py | 3 weeks ago | |
| application_startup_guide.md | 2 months ago | |
| build.bat | 3 weeks ago | |
| compile_error.log | 2 months ago | |
| database_setup_guide.md | 2 months ago | |
| pom.xml | 3 weeks ago | |
| query | 3 weeks ago | |
| queryex | 3 weeks ago | |
| run_app.bat | 2 months ago | |
| start.bat | 3 weeks ago | |
| test_server.py | 3 weeks ago | |
README.md
二手市场后端项目
项目结构
backend/
├── src/
│ ├── main/
│ │ ├── java/com/example/secondhandmarket/
│ │ │ ├── SecondHandMarketApplication.java # 应用入口类
│ │ │ ├── model/entity/
│ │ │ │ ├── User.java # 用户实体类
│ │ │ │ ├── Item.java # 商品实体类
│ │ │ │ └── ChatMessage.java # 聊天消息实体类
│ │ │ ├── repository/
│ │ │ │ ├── UserRepository.java # 用户数据访问接口
│ │ │ │ ├── ItemRepository.java # 商品数据访问接口
│ │ │ │ └── ChatMessageRepository.java # 聊天消息数据访问接口
│ │ │ ├── service/
│ │ │ │ ├── UserService.java # 用户服务接口
│ │ │ │ ├── ItemService.java # 商品服务接口
│ │ │ │ ├── ChatMessageService.java # 聊天消息服务接口
│ │ │ │ └── impl/
│ │ │ │ ├── UserServiceImpl.java # 用户服务实现
│ │ │ │ ├── ItemServiceImpl.java # 商品服务实现
│ │ │ │ └── ChatMessageServiceImpl.java # 聊天消息服务实现
│ │ │ ├── controller/
│ │ │ │ ├── UserController.java # 用户控制器
│ │ │ │ ├── ItemController.java # 商品控制器
│ │ │ │ └── ChatMessageController.java # 聊天消息控制器
│ │ │ └── config/
│ │ │ ├── WebSecurityConfig.java # 安全配置
│ │ │ ├── GlobalExceptionHandler.java # 全局异常处理
│ │ │ └── CorsConfig.java # 跨域配置
│ │ └── resources/
│ │ └── application.properties # 应用配置文件
│ └── test/ # 测试目录
├── pom.xml # Maven配置文件
└── README.md # 项目说明文档
技术栈
- Spring Boot 2.7.15
- Spring Data JPA
- Spring Security
- MySQL数据库
- Java 8+
功能模块
-
用户模块
- 用户注册、登录
- 用户信息查询和更新
- 手机号验证
-
商品模块
- 商品发布、编辑、删除
- 商品分类浏览
- 关键词搜索
- 价格范围筛选
- 浏览次数统计和点赞功能
-
聊天模块
- 买卖双方实时聊天
- 未读消息管理
- 会话列表获取
如何运行
前提条件
- JDK 8+
- Maven 3.6+
- MySQL 5.7+
配置步骤
-
修改
application.properties文件中的数据库配置:spring.datasource.url=jdbc:mysql://localhost:3306/secondhandmarket?useSSL=false&serverTimezone=UTC spring.datasource.username=root spring.datasource.password=your_password -
创建数据库:
CREATE DATABASE secondhandmarket CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; -
构建项目:
mvn clean install -
运行应用:
mvn spring-boot:run或者直接运行生成的jar包:
java -jar target/secondhandmarket-0.0.1-SNAPSHOT.jar
API接口说明
用户相关接口
- POST /users/register - 用户注册
- POST /users/login - 用户登录
- GET /users/{id} - 获取用户信息
- PUT /users/{id} - 更新用户信息
- GET /users/exists/phone/{phone} - 检查手机号是否已注册
商品相关接口
- POST /items - 创建商品
- GET /items/{id} - 获取商品详情
- GET /items - 获取所有商品列表
- GET /items/category/{category} - 按分类获取商品
- GET /items/seller/{sellerId} - 获取卖家的所有商品
- GET /items/search?keyword=xxx - 搜索商品
- GET /items/price-range?minPrice=xx&maxPrice=xx - 按价格范围筛选商品
- PUT /items/{id} - 更新商品信息
- DELETE /items/{id} - 删除商品
- PUT /items/{id}/status - 更改商品状态
- POST /items/{id}/like - 点赞商品
聊天相关接口
- POST /messages - 发送消息
- GET /messages/conversation/{userId1}/{userId2} - 获取用户间对话
- GET /messages/unread/{userId} - 获取未读消息
- PUT /messages/{id}/read - 标记单条消息已读
- PUT /messages/read-all/{userId}/{senderId} - 标记所有消息已读
- GET /messages/conversations/{userId} - 获取用户的所有会话