|
@@ -4,6 +4,12 @@ import {TestChatCompletion, TestChatMessage} from '../class-chat-completion';
|
|
|
import {ActivatedRoute} from '@angular/router';
|
|
|
import {NzCascaderOption} from "ng-zorro-antd/cascader";
|
|
|
import {Router} from '@angular/router';
|
|
|
+import * as Parse from "parse"
|
|
|
+import {NzModalRef, NzModalService} from 'ng-zorro-antd/modal';
|
|
|
+
|
|
|
+(Parse as any).serverURL = "https://web2023.fmode.cn/parse";
|
|
|
+// https://web2023.fmode.cn/s0210490/api/user/login
|
|
|
+Parse.initialize("dev")
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-mock-interviews',
|
|
@@ -22,7 +28,9 @@ export class MockInterviewsComponent {
|
|
|
showProgress: boolean = false;
|
|
|
progress: number = 0;
|
|
|
|
|
|
- finalResult: Array<any> = []
|
|
|
+ //题目
|
|
|
+ finalResult: Array<any> = [];
|
|
|
+ //回答
|
|
|
resultAnswers: Array<any> = []
|
|
|
|
|
|
startAnimation() {
|
|
@@ -36,8 +44,8 @@ export class MockInterviewsComponent {
|
|
|
nzOptions: NzCascaderOption[];
|
|
|
options = [
|
|
|
{
|
|
|
- value: '阿里面试官',
|
|
|
- label: '阿里面试官',
|
|
|
+ value: '仁慈的面试官',
|
|
|
+ label: '仁慈的面试官',
|
|
|
children: [
|
|
|
{
|
|
|
value: '技术面试',
|
|
@@ -60,11 +68,32 @@ export class MockInterviewsComponent {
|
|
|
},
|
|
|
]
|
|
|
},
|
|
|
+ {
|
|
|
+ value: "金融行业",
|
|
|
+ label: "金融行业",
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ value: '简单面',
|
|
|
+ label: '简单面',
|
|
|
+ isLeaf: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: '中等难',
|
|
|
+ label: '中等难',
|
|
|
+ isLeaf: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: '技术牛',
|
|
|
+ label: '技术牛',
|
|
|
+ isLeaf: true
|
|
|
+ },
|
|
|
+ ]
|
|
|
+ },
|
|
|
]
|
|
|
},
|
|
|
{
|
|
|
- value: '华为面试官',
|
|
|
- label: '华为面试官',
|
|
|
+ value: '凶狠的面试官',
|
|
|
+ label: '凶狠的面试官',
|
|
|
children: [
|
|
|
{
|
|
|
value: '技术面试',
|
|
@@ -90,8 +119,8 @@ export class MockInterviewsComponent {
|
|
|
]
|
|
|
},
|
|
|
{
|
|
|
- value: '苹果面试官',
|
|
|
- label: '苹果面试官',
|
|
|
+ value: '敷衍面试官',
|
|
|
+ label: '敷衍面试官',
|
|
|
children: [
|
|
|
{
|
|
|
value: '技术面试',
|
|
@@ -119,10 +148,12 @@ export class MockInterviewsComponent {
|
|
|
];
|
|
|
|
|
|
|
|
|
- constructor(private route: ActivatedRoute, private router: Router) {
|
|
|
+ constructor(private modalService: NzModalService, private route: ActivatedRoute, private router: Router) {
|
|
|
this.completion = new TestChatCompletion(this.messagesList)
|
|
|
|
|
|
this.nzOptions = this.options;
|
|
|
+ //判断是否有未完成的进度
|
|
|
+ this.initialize();
|
|
|
|
|
|
}
|
|
|
|
|
@@ -180,15 +211,13 @@ export class MockInterviewsComponent {
|
|
|
|
|
|
// 滚动到底部
|
|
|
scrollToBottom() {
|
|
|
- console.log(1)
|
|
|
const chatWindow = this.chatWindowRef.nativeElement;
|
|
|
chatWindow.scrollTop = chatWindow.scrollHeight;
|
|
|
- const chatContainer = this.chatContainerRef.nativeElement;
|
|
|
- const chatWindowOther = chatContainer.querySelector('.chat-window');
|
|
|
- chatWindowOther.scrollTop = chatWindowOther.scrollHeight;
|
|
|
}
|
|
|
|
|
|
createReport: boolean = false
|
|
|
+ //弹出框里面的值
|
|
|
+ errorMessage = '';
|
|
|
|
|
|
|
|
|
async handleButton() {
|
|
@@ -202,20 +231,154 @@ export class MockInterviewsComponent {
|
|
|
//空消息弹出提示框
|
|
|
isVisible = false;
|
|
|
|
|
|
- showModal(): void {
|
|
|
- this.isVisible = true;
|
|
|
+ //是否继续上次未完成的答题
|
|
|
+ isContinue = false;
|
|
|
+
|
|
|
+ modalRef!: NzModalRef;
|
|
|
+
|
|
|
+ showModal(): Promise<void> {
|
|
|
+ return new Promise<void>((resolve) => {
|
|
|
+ this.modalRef = this.modalService.create({
|
|
|
+ nzTitle: '面试环节',
|
|
|
+ nzContent: this.errorMessage,
|
|
|
+ nzOnCancel: () => {
|
|
|
+ this.handleCancel();
|
|
|
+ resolve();
|
|
|
+ },
|
|
|
+ nzOnOk: () => {
|
|
|
+ this.handleOk();
|
|
|
+ resolve();
|
|
|
+ },
|
|
|
+ });
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
handleOk(): void {
|
|
|
- console.log('Button ok clicked!');
|
|
|
+ this.isContinue = true;
|
|
|
this.isVisible = false;
|
|
|
}
|
|
|
|
|
|
handleCancel(): void {
|
|
|
- console.log('Button cancel clicked!');
|
|
|
+ this.isContinue = false;
|
|
|
this.isVisible = false;
|
|
|
}
|
|
|
|
|
|
+ async saveUserInterviewData() {
|
|
|
+ // 获取当前用户
|
|
|
+ const currentUser: any = Parse.User.current();
|
|
|
+
|
|
|
+ // 创建 LjUserInterviewData 对象
|
|
|
+ const UserInterviewData = Parse.Object.extend('LjUserInterviewData');
|
|
|
+ const userInterviewData = new UserInterviewData();
|
|
|
+
|
|
|
+
|
|
|
+ // 设置指针字段 user 关联到当前用户
|
|
|
+ userInterviewData.set('user', currentUser);
|
|
|
+ userInterviewData.set('number', this.typeQuestion);
|
|
|
+ userInterviewData.set('question', this.finalResult);
|
|
|
+ userInterviewData.set('answer', this.resultAnswers);
|
|
|
+ userInterviewData.set('userList', this.messagesListUser);
|
|
|
+ userInterviewData.set('aiList', this.messagesList);
|
|
|
+ //判断当前是否结束了
|
|
|
+ let isOver = 0
|
|
|
+ if (this.isStart != 0) {
|
|
|
+ isOver = 1
|
|
|
+ }
|
|
|
+ userInterviewData.set('interviewResult', isOver);
|
|
|
+
|
|
|
+
|
|
|
+ // 保存 LjUserInterviewData 对象到 Parse 服务器
|
|
|
+ await userInterviewData.save().then(async (savedUserInterviewData: any) => {
|
|
|
+ console.log(savedUserInterviewData)
|
|
|
+ }).catch((error: any) => {
|
|
|
+ console.error('Error saving LjUserInterviewData:', error);
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ async initialize() {
|
|
|
+ const currentUser: any = Parse.User.current();
|
|
|
+
|
|
|
+ // 创建查询
|
|
|
+ const query = new Parse.Query('LjUserInterviewData');
|
|
|
+
|
|
|
+ // 设置查询条件为当前用户
|
|
|
+ query.equalTo('user', currentUser);
|
|
|
+
|
|
|
+ // 设置 interviewResult 字段降序排列
|
|
|
+ query.descending('interviewResult');
|
|
|
+
|
|
|
+ // 查询 LjUserInterviewData 表中当前用户的数据
|
|
|
+ await query.find().then(async (results: any) => {
|
|
|
+ console.log(results[0].get('interviewResult'))
|
|
|
+ if (results[0].get('interviewResult') == 1) {
|
|
|
+ this.errorMessage = '您有未完成的面试环节,请问您是否要继续';
|
|
|
+ await this.showModal()
|
|
|
+ if (this.isContinue) {
|
|
|
+ console.log("继续面试")
|
|
|
+ this.messagesListUser = results[0].get('userList');
|
|
|
+ this.finalResult = results[0].get('question');
|
|
|
+ this.resultAnswers = results[0].get('answer');
|
|
|
+ this.messagesList = results[0].get('aiList');
|
|
|
+ this.typeQuestion = results[0].get('number');
|
|
|
+ this.isStart = results[0].get('interviewResult');
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ async getUserInterviewData() {
|
|
|
+ // 获取当前用户
|
|
|
+ const currentUser: any = Parse.User.current();
|
|
|
+
|
|
|
+ // 创建查询
|
|
|
+ const query = new Parse.Query('LjUserInterviewData');
|
|
|
+
|
|
|
+ // 设置查询条件为当前用户
|
|
|
+ query.equalTo('user', currentUser);
|
|
|
+
|
|
|
+ // 设置 interviewResult 字段降序排列
|
|
|
+ query.descending('interviewResult');
|
|
|
+
|
|
|
+ // 查询 LjUserInterviewData 表中当前用户的数据
|
|
|
+ await query.find().then(async (results: any) => {
|
|
|
+ console.log(results.length)
|
|
|
+ if (results[0].get('interviewResult') != 0) {
|
|
|
+ const userInterviewData = results[0];
|
|
|
+
|
|
|
+ // 修改数据
|
|
|
+ userInterviewData.set('number', this.typeQuestion);
|
|
|
+ userInterviewData.set('question', this.finalResult);
|
|
|
+ userInterviewData.set('answer', this.resultAnswers);
|
|
|
+ userInterviewData.set('userList', this.messagesListUser);
|
|
|
+ userInterviewData.set('aiList', this.messagesList);
|
|
|
+ userInterviewData.set('interviewResult', this.isStart);
|
|
|
+
|
|
|
+ //判断当前是否结束了
|
|
|
+ let isOver = 0;
|
|
|
+ if (this.isStart != 0) {
|
|
|
+ isOver = 1;
|
|
|
+ }
|
|
|
+ userInterviewData.set('interviewResult', isOver);
|
|
|
+
|
|
|
+ // 保存修改后的数据
|
|
|
+ await userInterviewData.save().then((savedUserInterviewData: any) => {
|
|
|
+ console.log('User Interview Data updated:', savedUserInterviewData);
|
|
|
+ }).catch((error: any) => {
|
|
|
+ console.error('Error updating User Interview Data:', error);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ await this.saveUserInterviewData()
|
|
|
+ console.log("saveU")
|
|
|
+ }
|
|
|
+
|
|
|
+ }).catch((error: any) => {
|
|
|
+ console.error('Error retrieving User Interview Data:', error);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
async send() {
|
|
|
// if (this.isStart == 0) {
|
|
|
// this.getQuestion()
|
|
@@ -233,20 +396,22 @@ export class MockInterviewsComponent {
|
|
|
// }
|
|
|
console.log(this.typeQuestion)
|
|
|
if (this.typeQuestion == 9) {
|
|
|
+ this.isStart = 0
|
|
|
+ await this.getUserInterviewData()
|
|
|
this.typeQuestion = 0
|
|
|
this.createReport = true
|
|
|
this.messagesListUser.push({
|
|
|
role: "user",
|
|
|
content: this.inputText += '回答完毕',
|
|
|
});
|
|
|
- await this.scrollToBottom()
|
|
|
+ this.scrollToBottom()
|
|
|
this.messagesListUser.push(
|
|
|
{
|
|
|
role: 'user',
|
|
|
content: "感谢您的回答,请稍等,正在生成报告.....",
|
|
|
}
|
|
|
)
|
|
|
- await this.scrollToBottom()
|
|
|
+ this.scrollToBottom()
|
|
|
setTimeout(async () => {
|
|
|
await this.createAiReport()
|
|
|
}, 1000)
|
|
@@ -262,7 +427,7 @@ export class MockInterviewsComponent {
|
|
|
role: "assistant",
|
|
|
content: "请等待,对话生成中....."
|
|
|
});
|
|
|
- await this.scrollToBottom()
|
|
|
+ this.scrollToBottom()
|
|
|
|
|
|
|
|
|
await this.getQuestion();
|
|
@@ -274,11 +439,11 @@ export class MockInterviewsComponent {
|
|
|
role: "assistant",
|
|
|
content: this.finalResult[this.typeQuestion].question
|
|
|
});
|
|
|
- await this.scrollToBottom()
|
|
|
-
|
|
|
+ this.scrollToBottom()
|
|
|
|
|
|
this.isStart++;
|
|
|
this.typeQuestion++;
|
|
|
+ await this.getUserInterviewData()
|
|
|
|
|
|
|
|
|
} else {
|
|
@@ -289,7 +454,7 @@ export class MockInterviewsComponent {
|
|
|
role: "user",
|
|
|
content: this.inputText += '回答完毕',
|
|
|
});
|
|
|
- await this.scrollToBottom()
|
|
|
+ this.scrollToBottom()
|
|
|
this.resultAnswers.push(this.inputText);
|
|
|
|
|
|
this.messagesListUser.push(
|
|
@@ -299,19 +464,17 @@ export class MockInterviewsComponent {
|
|
|
}
|
|
|
);
|
|
|
console.log(this.resultAnswers);
|
|
|
+ this.scrollToBottom()
|
|
|
this.inputText = "";
|
|
|
// 将滚动条滚动到底部
|
|
|
- await this.scrollToBottom()
|
|
|
-
|
|
|
this.typeQuestion++;
|
|
|
+ await this.getUserInterviewData()
|
|
|
} else {
|
|
|
+ this.errorMessage = '您的输入为空,请检查输入';
|
|
|
this.showModal()
|
|
|
return
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -344,7 +507,7 @@ export class MockInterviewsComponent {
|
|
|
content: this.messagesList[this.messagesList.length - 1].content,
|
|
|
}
|
|
|
);
|
|
|
- await this.scrollToBottom()
|
|
|
+ this.scrollToBottom()
|
|
|
resolve(undefined);
|
|
|
});
|
|
|
}
|