|
|
@@ -1,146 +0,0 @@
|
|
|
-表结构
|
|
|
-heartvoiceuser(用户表)
|
|
|
-objectId (唯一标识)
|
|
|
-createdAt (创建时间)
|
|
|
-username (用户名)
|
|
|
-password (密码)
|
|
|
-email (邮箱地址)
|
|
|
-phoneNumber (手机号)
|
|
|
-
|
|
|
-Questions(问题表)
|
|
|
-objectId (唯一标识)
|
|
|
-createdAt (创建时间)
|
|
|
-questionText (问题文本)
|
|
|
-dimension (维度,例如 E/I, S/N, T/F, J/P):string
|
|
|
-
|
|
|
-option(选项表)
|
|
|
-objectId (唯一标识)
|
|
|
-createdAt (创建时间)
|
|
|
-question (Pointer) (关联的题目)
|
|
|
-optionText (选项文本)
|
|
|
-weight (权重,取值为 1, 0.5, 0, -0.5, -1):string
|
|
|
-
|
|
|
-UserResponse(用户回答表)
|
|
|
-objectId (唯一标识)
|
|
|
-createdAt (创建时间)
|
|
|
-user (Pointer) (关联的用户)
|
|
|
-question (Pointer) (关联的题目)
|
|
|
-selectedOption (Pointer) (用户选择的选项)
|
|
|
-weight (权重,取值为 1, 0.5, 0, -0.5, -1)
|
|
|
-
|
|
|
-Chat(聊天记录表)
|
|
|
-objectId (唯一标识)
|
|
|
-createdAt (创建时间)
|
|
|
-user (Pointer) (关联的用户)
|
|
|
-chatContent (聊天内容)
|
|
|
-chatTime (聊天时间)
|
|
|
-emotion (情绪状态)
|
|
|
-
|
|
|
-PersonalityReport(个性化心理报告表)
|
|
|
-objectId (唯一标识)
|
|
|
-createdAt (创建时间)
|
|
|
-user (Pointer) (关联的用户)
|
|
|
-mbtiType (用户的MBTI类型)
|
|
|
-reportContent (报告内容)
|
|
|
-suggestions (建议)
|
|
|
-
|
|
|
-Feedback(用户反馈表)
|
|
|
-objectId (唯一标识)
|
|
|
-createdAt (创建时间)
|
|
|
-user (Pointer) (关联的用户)
|
|
|
-feedbackContent (反馈内容)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-class User {
|
|
|
- +objectId: String
|
|
|
- +createdAt: Date
|
|
|
- +username: String
|
|
|
- +password: String
|
|
|
- +email: String
|
|
|
- +phoneNumber: String
|
|
|
-}
|
|
|
-
|
|
|
-class Question {
|
|
|
- +objectId: String
|
|
|
- +createdAt: Date
|
|
|
- +questionText: String
|
|
|
- +dimension: String
|
|
|
-}
|
|
|
-
|
|
|
-class Option {
|
|
|
- +objectId: String
|
|
|
- +createdAt: Date
|
|
|
- +optionText: String
|
|
|
- +weight: String
|
|
|
- +question: Pointer
|
|
|
-}
|
|
|
-
|
|
|
-class UserResponse {
|
|
|
- +objectId: String
|
|
|
- +createdAt: Date
|
|
|
- +user: Pointer
|
|
|
- +question: Pointer
|
|
|
- +selectedOption: Pointer
|
|
|
- +weight: String }
|
|
|
- class Chat {
|
|
|
- +objectId: String
|
|
|
- +createdAt: Date
|
|
|
- +user: Pointer
|
|
|
- +chatContent: String
|
|
|
- +chatTime: Date
|
|
|
- +emotion: String }
|
|
|
- class PersonalityReport {
|
|
|
- +objectId: String
|
|
|
- +createdAt: Date
|
|
|
- +user: Pointer
|
|
|
- +mbtiType: String
|
|
|
- +reportContent: String
|
|
|
- +suggestions: String }
|
|
|
- class Feedback
|
|
|
- { +objectId: String
|
|
|
- +createdAt: Date
|
|
|
- +user: Pointer
|
|
|
- +feedbackContent: String }
|
|
|
- User "1" -- "0..*" UserResponse : answered
|
|
|
- User "1" -- "0..*" Chat : has
|
|
|
- User "1" -- "0..*" PersonalityReport : generates
|
|
|
- User "1" -- "0..*" Feedback : gives
|
|
|
- Question "1" -- "0..*" Option : has
|
|
|
- Question "1" -- "0..*" UserResponse : answered by @enduml
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- async function importObject(className, data) {
|
|
|
- // 查重 srcId 数据源列表中的objectId并非数据库生成的唯一ID,因此需要有一个srcId字段进行记录,并查重
|
|
|
- let query = new CloudQuery(className);
|
|
|
- let srcId = data.objectId;
|
|
|
- query.equalTo("srcId", srcId);
|
|
|
- let importObj = await query.first();
|
|
|
- console.log(importObj);
|
|
|
-
|
|
|
- // 导入前批量处理Pointer类型数据,进行重定向
|
|
|
- Object.keys(data)?.forEach(key => {
|
|
|
- let field = data[key];
|
|
|
- let srcId = field?.objectId;
|
|
|
- if (srcId) { // 是数组字段
|
|
|
- if (key == "question") { // 处理指向问题的指针
|
|
|
- data[key] = DataMap?.["Questions"]?.[srcId]?.toPointer(); // 确保指向 Questions
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- // 若未添加,则创建新对象并保存
|
|
|
- if (!importObj?.id) {
|
|
|
- importObj = new CloudObject(className);
|
|
|
- }
|
|
|
-
|
|
|
- // 保存或更新数据
|
|
|
- data.srcId = srcId;
|
|
|
- importObj.set(data);
|
|
|
- importObj = await importObj.save();
|
|
|
-
|
|
|
- DataMap[className][srcId] = importObj;
|
|
|
-}
|