# rm2pt1 **Repository Path**: gereey/rm2pt1 ## Basic Information - **Project Name**: rm2pt1 - **Description**: 软件需求分析第一次实验 - **Primary Language**: Unknown - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-05-10 - **Last Updated**: 2025-05-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 一. 结构化自然语言建模(Readme中没显示图片可到Readme.docx)中看 1. 16个用户需求 2. 18个系统功能需求 ![image-20250526171829489](C:\Users\admin\Desktop\软件需求第一次\rm2pt1\image\图片 1.png) ![image-20250526171835408](C:\Users\admin\AppData\Roaming\Typora\typora-user-images\image-20250526171835408.png) # 二、UML需求建模 用例图中Actor有2个,用例有5个,顺序图有5个,14个系统操作,26个系统合约,8个概念类。 ![image-20250526171908008](C:\Users\admin\AppData\Roaming\Typora\typora-user-images\image-20250526171908008.png) # 三、需求原型化和需求确认 由于不知道如何设置自增的id以及用户状态,register之类的设置了固定值,后续都是用管理用户页面进行测试 建模页面: ![image-20250526171951203](C:\Users\admin\AppData\Roaming\Typora\typora-user-images\image-20250526171951203.png) 创建用户: ![image-20250526172006067](C:\Users\admin\AppData\Roaming\Typora\typora-user-images\image-20250526172006067.png) 结果: ![image-20250526172026028](C:\Users\admin\AppData\Roaming\Typora\typora-user-images\image-20250526172026028.png) 查看效果: ![image-20250526172036718](C:\Users\admin\AppData\Roaming\Typora\typora-user-images\image-20250526172036718.png) QueryUser: ![image-20250526172047980](C:\Users\admin\AppData\Roaming\Typora\typora-user-images\image-20250526172047980.png) 删除用户: ![image-20250526172058559](C:\Users\admin\AppData\Roaming\Typora\typora-user-images\image-20250526172058559.png) 查看结果: ![image-20250526172112652](C:\Users\admin\AppData\Roaming\Typora\typora-user-images\image-20250526172112652.png) # 第二次作业: 生成并修改模型: ![image-20250526172153491](C:\Users\admin\AppData\Roaming\Typora\typora-user-images\image-20250526172153491.png) ![image-20250526172201339](C:\Users\admin\AppData\Roaming\Typora\typora-user-images\image-20250526172201339.png) #### 指标: ![image-20250526172225245](C:\Users\admin\AppData\Roaming\Typora\typora-user-images\image-20250526172225245.png) 微服务模型: ![image-20250526172235372](C:\Users\admin\AppData\Roaming\Typora\typora-user-images\image-20250526172235372.png) ![image-20250526172242976](C:\Users\admin\AppData\Roaming\Typora\typora-user-images\image-20250526172242976.png) 生成设计模型: ![image-20250526172302495](C:\Users\admin\AppData\Roaming\Typora\typora-user-images\image-20250526172302495.png) ![image-20250526172308286](C:\Users\admin\AppData\Roaming\Typora\typora-user-images\image-20250526172308286.png) 顺序图: ![image-20250526172321272](C:\Users\admin\AppData\Roaming\Typora\typora-user-images\image-20250526172321272.png) ### 8 任务三、大模型生成设计模型 ## 🧩 一、参与者(Actors) | 参与者 | 描述 | | ----------------------- | ------------------------------------------ | | Customer(顾客) | 系统使用者,可注册、登录、搜索、借书、还书 | | Librarian(图书管理员) | 协助顾客完成还书流程 | | BookBorrowSystem | 图书借阅系统,提供全部功能支持与数据处理 | ------ ## 🏗️ 二、用例图(Use Case Diagram) 可以简单抽象如下结构(文字描述,便于手工画图): ``` pgsql复制编辑 +-------------------------+ | Customer | +-------------------------+ | | | [Register][Login][Search Book] | [Borrow Book] | [Return Book] <---> Librarian ``` 系统参与者通过不同用例与系统交互,实现系统功能。 ------ ## ⚙️ 三、系统类设计(System Design Classes) ### 1. 类图(简要类描述) #### 1.1 `Customer` 类 | 属性 | 类型 | | ----------- | ------- | | username | String | | password | String | | email/phone | String | | isVerified | Boolean | | 方法 | 返回类型 | | ---------------------- | ------------ | | register() | void | | login() | boolean | | searchBook(title) | List | | borrowBook(book, time) | BorrowRecord | | returnBook(book) | boolean | ------ #### 1.2 `Book` 类 | 属性 | 类型 | | ----------- | ------- | | title | String | | author | String | | description | String | | available | boolean | ------ #### 1.3 `BorrowRecord` 类 | 属性 | 类型 | | ---------- | -------------------------------------- | | customer | Customer | | book | Book | | borrowDate | Date | | returnDate | Date | | status | String(e.g., "borrowed", "returned") | ------ #### 1.4 `BookBorrowSystem` 类 | 方法 | 返回类型 | | ------------------------------------- | ------------ | | sendVerificationCode(user) | void | | verifyCode(user, code) | boolean | | verifyLogin(username, password) | boolean | | searchBooksByTitle(title) | List | | handleBorrowing(customer, book, time) | BorrowRecord | | handleReturning(book, customer) | boolean | | recordToDatabase(object) | void | ------ ## 🛠️ 四、顺序图(Sequence Diagrams) 以下以注册流程为例展示顺序图: **Use Case: 注册用户** ``` rust复制编辑Customer -> BookBorrowSystem : 输入用户信息 BookBorrowSystem -> Customer : 发送验证码 Customer -> BookBorrowSystem : 输入验证码 BookBorrowSystem -> BookBorrowSystem : 验证验证码 BookBorrowSystem -> Database : 保存用户信息 ``` 其他用例(登录、搜索、借书、还书)也可按照类似方式设计时序图。 ------ ## 🗄️ 五、数据库设计(简要) | 表名 | 字段 | | ------------- | -------------------------------------------------------- | | Customers | id, username, password, contact, isVerified | | Books | id, title, author, description, isAvailable | | BorrowRecords | id, customer_id, book_id, borrowDate, returnDate, status | ------ ## ✅ 六、功能模块划分(Function Modules) | 模块 | 功能描述 | | -------------- | ------------------------------------ | | 用户管理模块 | 注册、登录、用户信息校验 | | 验证码模块 | 发送和验证验证码 | | 图书搜索模块 | 模糊查询图书 | | 借阅模块 | 借书、生成借阅记录、状态更新 | | 归还模块 | 归还图书、状态更新、由图书管理员发起 | | 数据库交互模块 | 所有信息记录的持久化 | #### 生成微服务架构 ## 🧱 一、微服务列表 | 微服务名 | 主要职责 | | -------------------------------------- | ------------------------------------------------- | | **用户服务(User Service)** | 注册、登录、验证码验证等用户身份相关功能 | | **图书服务(Book Service)** | 图书信息的搜索、查询、展示 | | **借阅服务(Borrow Service)** | 借书流程处理、记录生成 | | **还书服务(Return Service)** | 还书流程处理、记录更新 | | **通知服务(Notification Service)** | 发送短信/邮件验证码 | | **认证服务(Auth Service)** | 用户登录鉴权、Token 生成 | | **数据库服务(DB Service)** | 提供数据持久化存储(如 PostgreSQL / MongoDB)接口 | | **网关服务(API Gateway)** | 对外暴露统一接口,路由转发到各微服务 | | **服务注册与发现(Service Registry)** | 注册服务、动态发现(如使用 Consul 或 Eureka) | | **配置中心(Config Service)** | 集中配置管理(如使用 Spring Cloud Config) | ------ ## 📌 二、微服务架构图(逻辑图) ``` pgsql复制编辑 +-------------------+ | API Gateway | +--------+----------+ | +---------+-----------+--------------+------------+ | | | | | v v v v v +--------+ +--------+ +---------+ +----------+ +------------+ | Auth | | User | | Book | | Borrow | | Return | |Service | |Service | | Service| | Service | | Service | +--------+ +--------+ +---------+ +----------+ +------------+ | | | | | v v v v v +------------------------------------------------------------+ | Database Service | | (Users, Books, BorrowRecords, ReturnRecords, etc.) | +------------------------------------------------------------+ +------------------+ +------------------+ | Notification | <-----> | Config Service | | Service | +------------------+ +------------------+ ^ | +----------------------+ | Service Registry | | (Eureka / Consul) | +----------------------+ ``` ------ ## ⚙️ 三、服务说明 ### 1. 用户服务(User Service) - 接口: - POST `/register` - POST `/verify-code` - GET `/profile/{userId}` - 调用: - 调用 Notification Service 发送验证码 - 写入用户信息到 DB Service ------ ### 2. 图书服务(Book Service) - 接口: - GET `/books?title=xxx` - GET `/books/{bookId}` - 功能: - 图书搜索(关键词模糊匹配) - 获取图书详细内容 ------ ### 3. 借阅服务(Borrow Service) - 接口: - POST `/borrow` - GET `/borrow/status` - 功能: - 校验用户登录状态(调用 Auth Service) - 更新图书可借状态 - 生成借阅记录 ------ ### 4. 还书服务(Return Service) - 接口: - POST `/return` - GET `/return/status` - 功能: - 验证借书记录和用户 - 更新状态为“已还书” - 更新图书库存 ------ ### 5. 通知服务(Notification Service) - 功能: - 发送验证码(邮件、短信) - 通过消息队列与 User Service 解耦 ------ ### 6. 认证服务(Auth Service) - 接口: - POST `/login` - GET `/validate-token` - 功能: - 登录验证用户名与密码 - 返回 JWT Token 供其他服务鉴权 ------ ## 🧪 四、技术选型建议(可选) | 功能 | 技术选型推荐 | | -------------- | ---------------------------- | | 服务框架 | Spring Boot / Spring Cloud | | API 网关 | Nginx / Spring Cloud Gateway | | 服务注册与发现 | Eureka / Consul | | 配置中心 | Spring Cloud Config / Nacos | | 鉴权方式 | JWT + OAuth2 | | 通信机制 | REST + RabbitMQ(异步) | | 数据库 | PostgreSQL + Redis 缓存 | | 容器与编排 | Docker + Kubernetes (K8s) |