|
@@ -1,53 +1,145 @@
|
|
|
+# 类图
|
|
|
```plantuml
|
|
|
' 聊天项目类图
|
|
|
@startuml
|
|
|
' 智能陪聊
|
|
|
' 存储用户的基本信息
|
|
|
-class User {
|
|
|
- +objectId: String
|
|
|
- +createdAt: Date
|
|
|
- +username: String
|
|
|
- +password: String
|
|
|
- +email: String
|
|
|
- +profilePicture: String
|
|
|
- +bio: String
|
|
|
+class 用户 {
|
|
|
+ +对象ID: String
|
|
|
+ +创建时间: Date
|
|
|
+ +用户名: String
|
|
|
+ +密码: String
|
|
|
+ +邮箱: String
|
|
|
+ +头像: String
|
|
|
+ +个人简介: String
|
|
|
+ + 更新个人信息(): void
|
|
|
}
|
|
|
-' 存储专业陪聊师的信息
|
|
|
-class Chatbot {
|
|
|
- +objectId: String
|
|
|
- +createdAt: Date
|
|
|
- +name: String
|
|
|
- +specialization: String
|
|
|
- +rating: Float
|
|
|
- +availability: Boolean
|
|
|
- +profilePicture: String
|
|
|
- +bio: String
|
|
|
+
|
|
|
+' 存储专业陪聊师的信息
|
|
|
+class 专业陪聊机器人 {
|
|
|
+ +对象ID: String
|
|
|
+ +创建时间: Date
|
|
|
+ +名称: String
|
|
|
+ +专业领域: String
|
|
|
+ +评分: Float
|
|
|
+ +可用性: Boolean
|
|
|
+ +头像: String
|
|
|
+ +个人简介: String
|
|
|
+ + 更新评分():void
|
|
|
+}
|
|
|
+
|
|
|
+' 存储普通陪聊师的信息
|
|
|
+class 普通聊天机器人 {
|
|
|
+ +对象ID: String
|
|
|
+ +创建时间: Date
|
|
|
+ +名称: String
|
|
|
+ +描述: String
|
|
|
+ +版本: String
|
|
|
+ +可用性: Boolean
|
|
|
+ +头像: String
|
|
|
}
|
|
|
+
|
|
|
' 记录用户与陪聊师的聊天记录
|
|
|
-class ChatRecord {
|
|
|
- +objectId: String
|
|
|
- +createdAt: Date
|
|
|
- +message: String
|
|
|
- +timestamp: Date
|
|
|
- +user: Pointer
|
|
|
- +chatbot: Pointer
|
|
|
+class 聊天记录 {
|
|
|
+ +对象ID: String
|
|
|
+ +创建时间: Date
|
|
|
+ +消息: String
|
|
|
+ +时间戳: Date
|
|
|
+ +用户: 用户
|
|
|
+ +聊天机器人: 聊天机器人
|
|
|
+ +管理员: 管理员
|
|
|
+ + 保存聊天记录(): void
|
|
|
+ + 获取聊天记录(): List
|
|
|
}
|
|
|
|
|
|
-User "1" --> "*" ChatRecord
|
|
|
-Chatbot "1" --> "*" ChatRecord
|
|
|
-' 普通聊天
|
|
|
-' 存储普通陪聊师的信息
|
|
|
-class RegularChatbot {
|
|
|
- +objectId: String
|
|
|
- +createdAt: Date
|
|
|
- +name: String
|
|
|
- +description: String
|
|
|
- +version: String
|
|
|
- +availability: Boolean
|
|
|
- +profilePicture: String
|
|
|
+' 存储管理员的信息
|
|
|
+class 管理员 {
|
|
|
+ +对象ID: String
|
|
|
+ +用户名: String
|
|
|
+ +密码: String
|
|
|
+ +邮箱: String
|
|
|
+ +创建时间: Date
|
|
|
+ + 管理聊天记录(): List<聊天记录>
|
|
|
}
|
|
|
|
|
|
-RegularChatbot "1" --> "*" ChatRecord
|
|
|
+用户 "1" --> "*" 聊天记录
|
|
|
+专业陪聊机器人 "1" --> "*" 聊天记录
|
|
|
+普通聊天机器人 "1" --> "*" 聊天记录
|
|
|
+管理员 "1" --> "*" 聊天记录
|
|
|
+@enduml
|
|
|
+```
|
|
|
|
|
|
+# 时序图
|
|
|
+```plantuml
|
|
|
+@startuml
|
|
|
+actor 用户
|
|
|
+participant 专业陪聊机器人
|
|
|
+participant 管理员
|
|
|
+participant 聊天记录
|
|
|
+
|
|
|
+用户 -> 专业陪聊机器人: 发送消息
|
|
|
+专业陪聊机器人 -> 用户: 返回回复消息
|
|
|
+用户 -> 管理员: 退出聊天
|
|
|
+管理员 -> 聊天记录: 保存聊天记录
|
|
|
+聊天记录 -> 管理员: 返回记录确认
|
|
|
+@enduml
|
|
|
+```
|
|
|
+```plantuml
|
|
|
+@startuml
|
|
|
+actor 用户
|
|
|
+participant 普通聊天机器人
|
|
|
+participant 管理员
|
|
|
+participant 聊天记录
|
|
|
+
|
|
|
+用户 -> 普通聊天机器人: 发送消息
|
|
|
+普通聊天机器人 -> 用户: 返回回复消息
|
|
|
+用户 -> 管理员: 退出聊天
|
|
|
+管理员 -> 聊天记录: 保存聊天记录
|
|
|
+聊天记录 -> 管理员: 返回记录确认
|
|
|
@enduml
|
|
|
+```
|
|
|
+
|
|
|
+# 状态图
|
|
|
+```plantuml
|
|
|
+@startuml
|
|
|
+[*] --> 选择聊天页面
|
|
|
+
|
|
|
+选择聊天页面 --> 聊天中 : 开始聊天
|
|
|
+聊天中 --> 与专业陪聊机器人交互 : 选择专业陪聊机器人
|
|
|
+聊天中 --> 与普通聊天机器人交互 : 选择普通聊天机器人
|
|
|
+
|
|
|
+聊天中 --> 退出聊天 : 选择退出聊天
|
|
|
+退出聊天 --> 记录中 : 记录聊天记录
|
|
|
+
|
|
|
+记录中 --> 保存成功 : 保存记录
|
|
|
+记录中 --> 保存失败 : 保存记录失败
|
|
|
+
|
|
|
+保存成功 --> [*] : 聊天结束
|
|
|
+保存失败 --> 记录中 : 重新保存
|
|
|
+@enduml
|
|
|
+```
|
|
|
+
|
|
|
+# 活动图
|
|
|
+```plantuml
|
|
|
+@startuml
|
|
|
+|用户|
|
|
|
+start
|
|
|
+:发送消息;
|
|
|
+|专业陪聊机器人|
|
|
|
+:回复消息;
|
|
|
+|用户|
|
|
|
+repeat
|
|
|
+if (继续聊天?) then (是)
|
|
|
+ |用户|
|
|
|
+ :发送消息;
|
|
|
+ |专业陪聊机器人|
|
|
|
+ :回复消息;
|
|
|
+else (否)
|
|
|
+ |管理员|
|
|
|
+ :记录消息;
|
|
|
+ stop
|
|
|
+endif
|
|
|
+repeat while (回复消息)
|
|
|
+@enduml
|
|
|
+
|
|
|
```
|