Commit f1c4920f authored by yuguo's avatar yuguo

fix

parent 4ae56601
......@@ -14,7 +14,11 @@
"Bash(npx tailwindcss:*)",
"Bash(npx next:*)",
"Bash(PGPASSWORD=T5sSfTZ6XYTD9bfC psql:*)",
"Bash(npm install:*)"
"Bash(npm install:*)",
"Bash(kill:*)",
"Bash(go run:*)",
"Bash(npm run:*)",
"Bash(lsof:*)"
]
}
}
......@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"github.com/google/uuid"
"golang.org/x/crypto/bcrypt"
"internet-hospital/internal/model"
)
......@@ -46,7 +47,9 @@ func (s *Service) CreatePatient(ctx context.Context, req *CreatePatientRequest)
return fmt.Errorf("密码加密失败: %w", err)
}
userID := uuid.New().String()
user := &model.User{
ID: userID,
Phone: req.Phone,
Password: string(hashedPassword),
RealName: req.RealName,
......@@ -56,7 +59,22 @@ func (s *Service) CreatePatient(ctx context.Context, req *CreatePatientRequest)
Age: req.Age,
}
return s.db.Create(user).Error
tx := s.db.Begin()
if err := tx.Create(user).Error; err != nil {
tx.Rollback()
return err
}
profile := &model.PatientProfile{
ID: uuid.New().String(),
UserID: userID,
}
if err := tx.Create(profile).Error; err != nil {
tx.Rollback()
return err
}
return tx.Commit().Error
}
// UpdatePatient 更新患者信息
......
......@@ -7,7 +7,7 @@ import {
HomeOutlined, UserOutlined, MedicineBoxOutlined, FileTextOutlined,
HeartOutlined, SettingOutlined, LogoutOutlined, BellOutlined,
RobotOutlined, VideoCameraOutlined, PayCircleOutlined,
ShoppingCartOutlined, FolderOpenOutlined,
ShoppingCartOutlined, FolderOpenOutlined, SearchOutlined,
} from '@ant-design/icons';
import { useUserStore } from '@/store/userStore';
......@@ -16,17 +16,39 @@ const { Text } = Typography;
const menuItems = [
{ key: '/patient/home', icon: <HomeOutlined />, label: '首页' },
{ key: '/patient/doctors', icon: <MedicineBoxOutlined />, label: '医生列表' },
{ key: '/patient/pre-consult', icon: <RobotOutlined />, label: 'AI预问诊' },
{ key: '/patient/consult', icon: <VideoCameraOutlined />, label: '问诊' },
{ key: '/patient/prescription', icon: <FileTextOutlined />, label: '处方' },
{ key: '/patient/payment', icon: <PayCircleOutlined />, label: '支付' },
{ key: '/patient/pharmacy/order', icon: <ShoppingCartOutlined />, label: '药品配送' },
{ key: '/patient/chronic', icon: <HeartOutlined />, label: '慢病管理' },
{ key: '/patient/health-records', icon: <FolderOpenOutlined />, label: '健康档案' },
{
key: 'consult-services', icon: <VideoCameraOutlined />, label: '问诊服务',
children: [
{ key: '/patient/doctors', icon: <SearchOutlined />, label: '找医生' },
{ key: '/patient/pre-consult', icon: <RobotOutlined />, label: 'AI预问诊' },
{ key: '/patient/consult', icon: <VideoCameraOutlined />, label: '我的问诊' },
],
},
{
key: 'rx-pharmacy', icon: <MedicineBoxOutlined />, label: '处方购药',
children: [
{ key: '/patient/prescription', icon: <FileTextOutlined />, label: '电子处方' },
{ key: '/patient/pharmacy/order', icon: <ShoppingCartOutlined />, label: '药品配送' },
{ key: '/patient/payment', icon: <PayCircleOutlined />, label: '支付管理' },
],
},
{
key: 'health-mgmt', icon: <HeartOutlined />, label: '健康管理',
children: [
{ key: '/patient/chronic', icon: <HeartOutlined />, label: '慢病管理' },
{ key: '/patient/health-records', icon: <FolderOpenOutlined />, label: '健康档案' },
],
},
{ key: '/patient/profile', icon: <UserOutlined />, label: '个人中心' },
];
// 所有可路由的 key 列表(用于选中匹配)
const allRouteKeys = [
'/patient/home', '/patient/doctors', '/patient/pre-consult', '/patient/consult',
'/patient/prescription', '/patient/pharmacy/order', '/patient/payment',
'/patient/chronic', '/patient/health-records', '/patient/profile',
];
export default function PatientLayout({ children }: { children: React.ReactNode }) {
const router = useRouter();
const pathname = usePathname();
......@@ -52,8 +74,8 @@ export default function PatientLayout({ children }: { children: React.ReactNode
};
const getSelectedKeys = () => {
const match = menuItems.find(item => currentPath.startsWith(item.key));
return match ? [match.key] : [];
const match = allRouteKeys.find(k => currentPath.startsWith(k));
return match ? [match] : [];
};
return (
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment