feat: update login api

This commit is contained in:
2026-06-05 15:36:31 +08:00
parent fd0b3e1982
commit ba9fb33062
15 changed files with 714 additions and 163 deletions
@@ -0,0 +1,30 @@
from django.core.management.base import BaseCommand
from apps.user.models import Institution
from apps.user.auth import TRIAL_INSTITUTION_NAME, TRIAL_INSTITUTION_CODE
class Command(BaseCommand):
help = '初始化预留试用机构「北大医学部(实验室)试用」'
def handle(self, *args, **options):
inst, created = Institution.objects.get_or_create(
code=TRIAL_INSTITUTION_CODE,
defaults={'name': TRIAL_INSTITUTION_NAME, 'type': 'hospital'},
)
if created:
self.stdout.write(self.style.SUCCESS(
f'[创建] 试用机构: {inst.code} / {inst.name}'
))
elif inst.name != TRIAL_INSTITUTION_NAME:
old_name = inst.name
inst.name = TRIAL_INSTITUTION_NAME
inst.save(update_fields=['name'])
self.stdout.write(self.style.WARNING(
f'[更新] 试用机构名称: {old_name} -> {inst.name}'
))
else:
self.stdout.write(self.style.WARNING(
f'[已存在] 试用机构: {inst.code} / {inst.name}'
))
@@ -73,15 +73,6 @@ class Command(BaseCommand):
'training_stage': '规培',
'learning_target': '掌握常见病诊断',
},
{
'username': 'teacher1',
'password': 'teacher123',
'real_name': '王老师',
'role_type': 'teacher',
'phone': '13800138003',
'title_name': '副主任医师',
'major': '呼吸内科',
},
{
'username': 'content_admin',
'password': 'content123',