# things **Repository Path**: yookoo/things ## Basic Information - **Project Name**: things - **Description**: 轻松管理生活中的每一件物品 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-01-28 - **Last Updated**: 2026-01-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 物品收纳管理系统 基于 Spring Boot 开发的物品收纳管理系统,用于管理生活中的物品及其放置位置。 ## 功能特性 ### 物品管理 - 物品的增删改查 - 物品属性:ID、名称、图片、类型、购买渠道、购买日期、有效期、价格、规格、使用状态、数量、位置、备注 - 多条件筛选: - 按名称搜索 - 按类型筛选 - 按使用状态筛选 - 按位置筛选 - 按价格范围筛选 - 按购买日期范围筛选 - 按购买渠道筛选 - 查询即将过期物品 ### 位置管理 - 收纳位置的增删改查 - 位置属性:ID、房间、位置、建议存放物品、备注 - 按房间搜索位置 ## 技术栈 - Spring Boot 3.2.0 - Spring Data JPA - Thymeleaf - Layui 2.9.8 - MySQL 8.0 - Lombok - Maven ## 数据库配置 在 `src/main/resources/application.yml` 中配置数据库连接: ```yaml spring: datasource: url: jdbc:mysql://localhost:3306/things_db?createDatabaseIfNotExist=true username: root password: your_password ``` ## 启动项目 1. 确保已安装 MySQL 8.0+ 和 JDK 17+ 2. 创建数据库:`CREATE DATABASE things_db;` 3. 修改 `application.yml` 中的数据库配置 4. 运行项目:`mvn spring-boot:run` 5. 打开浏览器访问:`http://localhost:8080` ## 前端页面 ### 页面导航 | 页面 | 路径 | 说明 | |------|------|------| | 首页 | `/` | 系统首页,功能介绍 | | 物品列表 | `/items` | 查看和管理所有物品 | | 物品表单 | `/items/new` 或 `/items/edit/{id}` | 添加或编辑物品 | | 位置列表 | `/locations` | 查看和管理所有位置 | | 位置表单 | `/locations/new` 或 `/locations/edit/{id}` | 添加或编辑位置 | ### 前端特性 - 响应式布局,支持移动端访问 - 现代化 UI 设计 - 表格分页、排序 - 表单验证 - 图片上传支持 - 无需登录即可使用 ## API 接口 ### Web 接口(页面访问) | 方法 | 路径 | 说明 | |------|------|------| | GET | `/` | 首页 | | GET | `/items` | 物品列表页 | | GET | `/items/new` | 添加物品表单 | | GET | `/items/edit/{id}` | 编辑物品表单 | | POST | `/items/save` | 保存物品 | | GET | `/items/delete/{id}` | 删除物品 | | GET | `/locations` | 位置列表页 | | GET | `/locations/new` | 添加位置表单 | | GET | `/locations/edit/{id}` | 编辑位置表单 | | POST | `/locations/save` | 保存位置 | | GET | `/locations/delete/{id}` | 删除位置 | | POST | `/upload/image` | 上传图片 | ### REST API 接口(JSON) #### 位置管理接口 | 方法 | 路径 | 说明 | |------|------|------| | GET | `/api/locations` | 获取所有位置 | | GET | `/api/locations/{id}` | 根据ID获取位置 | | GET | `/api/locations/search?room=xxx` | 按房间搜索位置 | | POST | `/api/locations` | 创建位置 | | PUT | `/api/locations/{id}` | 更新位置 | | DELETE | `/api/locations/{id}` | 删除位置 | ### 物品管理接口 | 方法 | 路径 | 说明 | |------|------|------| | GET | `/api/items` | 获取所有物品 | | GET | `/api/items/{id}` | 根据ID获取物品 | | GET | `/api/items/search?name=xxx` | 按名称搜索物品 | | GET | `/api/items/filter/type?type=xxx` | 按类型筛选 | | GET | `/api/items/filter/status?status=xxx` | 按使用状态筛选 | | GET | `/api/items/filter/location?locationId=xxx` | 按位置筛选 | | GET | `/api/items/expiring?days=30` | 查询即将过期物品 | | GET | `/api/items/filter/price?minPrice=0&maxPrice=1000` | 按价格范围筛选 | | GET | `/api/items/filter/purchase-date?startDate=2024-01-01&endDate=2024-12-31` | 按购买日期筛选 | | GET | `/api/items/filter/channel?channel=xxx` | 按购买渠道筛选 | | POST | `/api/items` | 创建物品 | | PUT | `/api/items/{id}` | 更新物品 | | DELETE | `/api/items/{id}` | 删除物品 | ## 数据模型 ### Location(位置) - id: Long(主键) - room: String(房间) - position: String(位置) - suggestedItems: String(建议存放物品) - remark: String(备注) ### Item(物品) - id: Long(主键) - name: String(名称) - image: String(图片) - type: String(类型) - purchaseChannel: String(购买渠道) - purchaseDate: LocalDate(购买日期) - expiryDate: LocalDate(有效期) - price: BigDecimal(价格) - specification: String(规格) - usageStatus: String(使用状态) - quantity: Integer(数量) - location: Location(位置,关联表) - remark: String(备注) ## 项目结构 ``` things/ ├── src/ │ └── main/ │ ├── java/com/things/ │ │ ├── config/ # 配置类 │ │ ├── controller/ # 控制器层 │ │ ├── service/ # 服务层 │ │ ├── repository/ # 数据访问层 │ │ ├── entity/ # 实体类 │ │ ├── dto/ # 数据传输对象 │ │ ├── exception/ # 异常处理 │ │ └── ThingsApplication.java │ └── resources/ │ ├── templates/ # Thymeleaf 模板 │ │ ├── index.html │ │ ├── items.html │ │ ├── item-form.html │ │ ├── locations.html │ │ └── location-form.html │ └── application.yml ├── uploads/ # 上传文件存储目录 │ └── images/ └── pom.xml ``` ## 使用示例 ### 通过 Web 页面使用 1. 启动项目后,浏览器访问 `http://localhost:8080` 2. 点击"管理位置"按钮,先添加收纳位置 - 房间:卧室 - 位置:衣柜 - 建议存放物品:衣物、外套、裤子 - 备注:存放日常衣物 3. 点击"管理物品"按钮,添加物品 - 填写物品信息 - 选择存放位置 - 保存物品 ### 通过 API 接口使用 #### 创建位置 ```bash curl -X POST http://localhost:8080/locations \ -H "Content-Type: application/json" \ -d '{ "room": "卧室", "position": "衣柜", "suggestedItems": "衣物,外套,裤子", "remark": "存放日常衣物" }' ``` #### 创建物品 ```bash curl -X POST http://localhost:8080/items \ -H "Content-Type: application/json" \ -d '{ "name": "羽绒服", "image": "/images/coat.jpg", "type": "衣物", "purchaseChannel": "淘宝", "purchaseDate": "2024-01-15", "expiryDate": null, "price": 599.00, "specification": "L", "usageStatus": "正常", "quantity": 1, "locationId": 1, "remark": "冬季服装" }' ``` #### 搜索物品 ```bash curl http://localhost:8080/items/search?name=羽绒服 ``` #### 查询即将过期物品(30天内) ```bash curl http://localhost:8080/items/expiring?days=30 ``` ## 功能截图 ### 首页 - 现代化的渐变背景设计 - 功能卡片展示 - 快速导航按钮 ### 物品管理 - 表格展示所有物品 - 搜索和筛选功能 - 使用状态标签显示 - 快速编辑和删除操作 ### 位置管理 - 清晰的位置列表 - 按房间搜索 - 简洁的表单设计 ## 特色功能 1. **智能搜索**:支持按名称、类型、状态、位置等多条件筛选 2. **过期提醒**:自动标识即将过期的物品,方便及时处理 3. **灵活管理**:支持批量管理物品和位置 4. **美观界面**:基于 Layui 的现代化 UI 设计 5. **响应式布局**:适配 PC 和移动端