103 lines
3.1 KiB
Python
103 lines
3.1 KiB
Python
# -*- coding: utf-8 -*-
|
||
"""
|
||
数据库初始化脚本:创建测试数据
|
||
用于测试招聘回复与复聊功能
|
||
"""
|
||
|
||
import os
|
||
import sys
|
||
import django
|
||
|
||
# 设置 Django 环境
|
||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings')
|
||
django.setup()
|
||
|
||
from server.models import ChatScript
|
||
|
||
|
||
def create_chat_scripts():
|
||
"""创建话术示例"""
|
||
print("\n创建话术配置...")
|
||
|
||
# 删除旧的测试话术
|
||
ChatScript.objects.filter(position__in=["Python开发", "通用", "测试"]).delete()
|
||
|
||
scripts = [
|
||
{
|
||
"position": "Python开发",
|
||
"script_type": "first",
|
||
"content": "您好!看到您的简历,Python技术栈很符合我们的要求,我们这边是做XXX项目的,期待与您进一步沟通。",
|
||
"keywords": "",
|
||
},
|
||
{
|
||
"position": "Python开发",
|
||
"script_type": "followup",
|
||
"content": "您好,不知道您是否方便留个联系方式?后续沟通会更及时一些。",
|
||
"keywords": "",
|
||
},
|
||
{
|
||
"position": "Python开发",
|
||
"script_type": "wechat",
|
||
"content": "后续沟通会更及时,您方便留一下您的微信号吗?我这边加您。",
|
||
"keywords": "微信,联系方式",
|
||
},
|
||
{
|
||
"position": "通用",
|
||
"script_type": "first",
|
||
"content": "您好!看到您的简历很符合我们的要求,期待与您进一步沟通。",
|
||
"keywords": "",
|
||
},
|
||
{
|
||
"position": "通用",
|
||
"script_type": "followup",
|
||
"content": "您好,期待与您进一步沟通,方便留个联系方式吗?",
|
||
"keywords": "",
|
||
},
|
||
{
|
||
"position": "通用",
|
||
"script_type": "wechat",
|
||
"content": "后续沟通会更及时,您方便留一下您的微信号吗?我这边加您。",
|
||
"keywords": "微信,联系方式",
|
||
},
|
||
]
|
||
|
||
created_scripts = []
|
||
for script_data in scripts:
|
||
script = ChatScript.objects.create(**script_data, is_active=True)
|
||
created_scripts.append(script)
|
||
print(f"✓ 创建话术: {script.position} - {script.get_script_type_display()}")
|
||
|
||
return created_scripts
|
||
|
||
|
||
def main():
|
||
print("=" * 60)
|
||
print("BOSS招聘自动化 - 初始化测试数据")
|
||
print("=" * 60)
|
||
|
||
try:
|
||
# 创建话术
|
||
scripts = create_chat_scripts()
|
||
|
||
print("\n" + "=" * 60)
|
||
print("初始化完成!")
|
||
print("=" * 60)
|
||
print(f"\n话术配置: 共 {len(scripts)} 条")
|
||
for script in scripts:
|
||
print(f" - {script.position} / {script.get_script_type_display()}")
|
||
|
||
print("\n现在可以运行招聘任务测试新功能了!")
|
||
|
||
except Exception as e:
|
||
print(f"\n✗ 错误: {e}")
|
||
import traceback
|
||
traceback.print_exc()
|
||
return 1
|
||
|
||
return 0
|
||
|
||
|
||
if __name__ == "__main__":
|
||
sys.exit(main())
|