141 lines
4.3 KiB
Python
141 lines
4.3 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 FilterConfig, ChatScript
|
||
|
||
|
||
def create_filter_config():
|
||
"""创建筛选配置示例"""
|
||
print("创建筛选配置...")
|
||
|
||
# 删除旧的测试配置
|
||
FilterConfig.objects.filter(name__contains="测试").delete()
|
||
|
||
# 创建新配置
|
||
config = FilterConfig.objects.create(
|
||
name="Python开发筛选配置",
|
||
age_min=22,
|
||
age_max=35,
|
||
gender="不限",
|
||
education="本科",
|
||
activity="3天内活跃",
|
||
positions=["Python开发", "后端开发", "全栈开发", "Django开发"],
|
||
greeting_min=5,
|
||
greeting_max=20,
|
||
rest_minutes=30,
|
||
collection_min=10,
|
||
collection_max=50,
|
||
message_interval=30,
|
||
is_active=True
|
||
)
|
||
print(f"✓ 创建筛选配置: {config.name} (ID: {config.id})")
|
||
|
||
return config
|
||
|
||
|
||
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:
|
||
# 创建筛选配置
|
||
config = create_filter_config()
|
||
|
||
# 创建话术
|
||
scripts = create_chat_scripts()
|
||
|
||
print("\n" + "=" * 60)
|
||
print("初始化完成!")
|
||
print("=" * 60)
|
||
print(f"\n筛选配置: {config.name}")
|
||
print(f" - 年龄: {config.age_min}-{config.age_max}岁")
|
||
print(f" - 学历: {config.education}及以上")
|
||
print(f" - 活跃度: {config.activity}")
|
||
print(f" - 期望职位: {', '.join(config.positions)}")
|
||
|
||
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())
|